The only way I achieved something similar was using:

{% for key, item in content.field_club_history if key|first != '#' %}
    {{ content.field_club_history['#items'][key].entity.field_games.value }}
{% endfor %}

The only difference is that field_club_history was EntityReference field to Paragraph of concrete type. Paragraph type then has fields like field_games. Try to use following code example and get fields from specific item that you need.

{{ content.field_club_history['#items'][key].my_field_name }}


$result is in array of items.

Use this:

$first_nid = NULL;
if (isset($result['node'])) {
   $first_nid = array_shift(array_keys($result['node']));
}


How to theme webform elements (radio buttons etc.)?

Each webform element has it's own file in the "components" sub-directory of the webform module folder.

If you look in those files there is a _webform_theme_COMPONENTTYPE() function, for example _webform_theme_date() for the date fields.

This function defines the theme functions for that field type.

These theme functions are what you can use to override the themeing of the fields.

For exmaple theme_webform_date() can be overridden as THEMENAME_webform_date(&$variables) and you can change the output.

If it is things like the field wrappers or labels you want, then look at overriding the theme_webform_element() function.

That will let you do things like change where the label is printed in relation to the field.

You can use $element['#type'] to single out specific field types in that theme function.

Note: Webform components are a special case. Normally you can find themeable things by looking in the MODULENAME_theme() function. In this case webform_theme().

Specifically, to set classes on radio button fields:

You requirement of adding the class to a radio button is unfortunately a bit different.
This is because webform doesn't use it's own themeing, it uses drupal core's

So what you want is theme_radios() and/or theme_radio() and/or theme_form_element_label().

Something like these (there are comments to tell you what has changed):

/**
 * Theme a set of radio buttons.
 */
function THEMENAME_radios($variables) {
  $element = $variables['element'];
  $attributes = array();
  if (isset($element['#id'])) {
    $attributes['id'] = $element['#id'];
  }
  $attributes['class'] = 'form-radios';
  if (!empty($element['#attributes']['class'])) {
    $attributes['class'] .= ' ' . implode(' ', $element['#attributes']['class']);
  }
  if (isset($element['#attributes']['title'])) {
    $attributes['title'] = $element['#attributes']['title'];
  }

  // Add custom classes.
  // To target specific elements you can use the $element variable.
  // You can target the label using:
  // .your-custom-class label
  $attributes['class'] .= 'your-custom-class another-custom-class';

  return '
' . (!empty($element['#children']) ? $element['#children'] : '') . '
';
}

/**
 * Theme a single radio button.
 */
function THEMENAME_radio($variables) {
  $element = $variables['element'];
  $element['#attributes']['type'] = 'radio';
  element_set_attributes($element, array('id', 'name','#return_value' => 'value'));

  if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] == $element['#return_value']) {
    $element['#attributes']['checked'] = 'checked';
  }
  _form_set_class($element, array('form-radio'));

  // Set custom classes.
  // Use $element to target specific fields.
  $element['#attributes']['class'][] = 'your-custom-class';
  $element['#attributes']['class'][] = 'another-custom-class';

  return '<input' . drupal_attributes($element['#attributes']) . ' />';
}

Unfortunately it is not possible to add classes to a label except for overriding theme_form_element_label() because of this bug.

The are two possible ways to address this in the theme layer.

One is to add the class to the field wrapper and then target the labels via that in your css or js.

The other is to override theme_form_element_label() like this:

/**
 * Theme a form element label.
 */
function THEMENAME_form_element_label($variables) {
  $element = $variables['element'];
  // This is also used in the installer, pre-database setup.
  $t = get_t();

  // If title and required marker are both empty, output no label.
  if ((!isset($element['#title']) || $element['#title'] === '') && empty($element['#required'])) {
    return '';
  }

  // If the element is required, a required marker is appended to the label.
  $required = !empty($element['#required']) ? theme('form_required_marker', array('element' => $element)) : '';

  $title = filter_xss_admin($element['#title']);

  $attributes = array();
  // Style the label as class option to display inline with the element.
  if ($element['#title_display'] == 'after') {
    // Changed to make class an array.
    $attributes['class'][] = 'option';
  }
  // Show label only to screen readers to avoid disruption in visual flows.
  elseif ($element['#title_display'] == 'invisible') {
    // Changed to make class an array.
    $attributes['class'][] = 'element-invisible';
  }

  if (!empty($element['#id'])) {
    $attributes['for'] = $element['#id'];
  }

  // Add your classes here.
  // If you are using variables to make the class use the drupal_html_class()
  // function.
  // To target specific elements you can use the $element variable.
  // For example, based on field type:
  if ($element['#type'] == '') {
    $attributes['class'][] = 'your-custom-class';
    $attributes['class'][] = 'another-custom-class';
  }

  // The leading whitespace helps visually separate fields from inline labels.
  return ' ' . $t('!title !required', array('!title' => $title, '!required' => $required)) . "\n";
}


How can I use a views template to modify the titles of taxonomy links?

You need to create another field with the 'path' and set this to not display by default within the views UI.

You can then get the 'path' variable in your template along with the 'title' variable and create your link using Drupals l() function.

   print l($data['rendered']['#title'], $path);

http://api.drupal.org/api/drupal/includes%21common.inc/function/l/7


How to modify the value of a taxonomy field of a node using hook_node_view()?

You don't have to use the node view hook. It can be achieved using a taxonomy display as well.

Here is how to do it:

Navigate to "Administration / Structure / Display modes / View modes"
Scroll down to "Taxonomy term"
Add a new Taxonomy term view mode by clicking the according link and giving it a name
Now head to the display settings of your Taxonomy at "Administration / Structure / Taxonomy / [Your vocabulary] / Manage display"
Find the "Custom display settings" tab, tick your newly created view mode and save
A new tab with the name of your view mode will appear, where you can just add the field you like to display and disable all others; save again
Head to the manage display settings of your content type that features the entity reference field to this taxonomy at "Administration / Structure / Content types / [Your content type] / Manage display"
Find your entity reference field and switch "Format" to "Rendered entity"
Using the cogwheel at the very right, you can now choose your above created view mode for how to render the referenced taxonomy entity

Save and you have the rendered field of your taxonomy shown at the node page.

PS.: The above procedure can be used for many other referenced entities as well and does not require any custom programming.


What's the "Best Practice" approach for disabling secure pages on local Dev?

It's a best practice to create a settings.local.php file which is included at the end of the default settings.php file. Then within that file you can place whatever logic you want per server as you've done, or make the content of settings.local.php be specific per server host you're deploying too (and keep settings.local.php basically outside of version control).

This is a good practice for Drupal 7 development -- so good in fact Drupal 8 ships with such code in settings.php by default, which you can uncomment to make use of:

/** In settings.php for a drupal 8 site */

/**
 * Load local development override configuration, if available.
 *
 * Use settings.local.php to override variables on secondary (staging,
 * development, etc) installations of this site. Typically used to disable
 * caching, JavaScript/CSS compression, re-routing of outgoing emails, and
 * other things that should not happen on development and testing sites.
 *
 * Keep this code block at the end of this file to take full effect.
 */
# if (file_exists(__DIR__ . '/settings.local.php')) {
#   include __DIR__ . '/settings.local.php';
# }


How do I programmatically render a custom entity?

Make sure the entity id exists and the error disappears.


You can use String Overrides module. Also you can override strings through settings.php, look this post.

For example that you listed above, there is one string that contains variable !name. So "Surname field is required." is "!name field is required.", when you changing use "The field !name is required for this form" and you overrides all similar messages.


Saving multipage webforms after each page?

The webform module does this by default if you enable Draft mode per webform and create multi-page forms.


Add a "autocomplete" field in a buildForm

You use entity_autocomplete as #type for the form field. CommentForm::form() contains such a form field, for the administrator users to be able to change the author of a comment. This is the code it uses.

  // The uid field is only displayed when a user with the permission
  // 'administer comments' is editing an existing comment from an
  // authenticated user.
  $owner = $comment->getOwner();
  $form['author']['uid'] = [
    '#type' => 'entity_autocomplete',
    '#target_type' => 'user',
    '#default_value' => $owner->isAnonymous() ? NULL : $owner,
    // A comment can be made anonymous by leaving this field empty therefore
    // there is no need to list them in the autocomplete.
    '#selection_settings' => ['include_anonymous' => FALSE],
    '#title' => $this->t('Authored by'),
    '#description' => $this->t('Leave blank for %anonymous.', ['%anonymous' => $config->get('anonymous')]),
    '#access' => $is_admin,
  ];

As you can see from the code, you can also choose to include the anonymous user.

The result is shown in the following screenshot.


What are the really use of the ancient Project Application issue queue now that you can promote your own sandbox projects?

Apart from your actual question, you also posted a comment which contains this:

  ... the project is promoted, but now how can I obtain the shield?

Not sure if it will be a complete answer to your question, but your scenario here seems a variation of the question about "Why has my security shield for my new module on Drupal.org been removed?". Your variation now seems to be "Why has my security shield for my new module on Drupal.org not yet been added?" (or why is it not visible yet).

Here is part of my answer in that related question:

  You need to create an official release, for at least 1 version of Drupal core that is supported. In your case, for D7, like a 7.x-1.0 version of your module. Shortly after doing so, your module will have the security shield.

I'm not sure (yet) about how long that Shortly actually may take, but I also noticed that on the revisions page of OnlyOne the most current timestamp is 13 Mar 2017 at 22:32 CET (which is less then 24 hours ago). Moreover, on its project page there is also Last modified: March 14, 2017 (which is today ...). But it could well be that with only a little patience (like until tomorrow?), you will automagically get the shield that you're looking for.

Update

Debugging is the art of taking away all possible causes ... about a day later it appears that for your module "a little patience" is not the solution (the shield still doesn't show up). Sorry.


Have you tried using the Views Bulk Operations (VBO) module? This allows you to perform operations on entities from your actual View page.

I've never used it with Users before, but I've managed to use it to Publish / Unpublish nodes from my own custom View's page.


How do I check if a user may access a given route?

I don't know why

$_url = Url::fromRoute('', [], ['language' => $language]);

Doesn't work with route name <current> but it works with other route names.
For example with route with name some_module.some_route_name the following
will work.

  $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
  $_url = Url::fromRoute('some_module.some_route_name', [], ['language' => $language]);
  $userCurrent = \Drupal::currentUser();
  if ($_url->access($userCurrent)) {
    //- Do Stuff
  }

In your case for the current route. Try this out.

use Drupal\Core\Url;

  $request = \Drupal::request();
  $_url = Url::createFromRequest($request);
  $userCurrent = \Drupal::currentUser();
   if ($_url->access($userCurrent)) {
     //- Do Stuff
  }


How do I insert a user picture's thumbnail on the "Submitted by" field?

Hope this will help you.

In Drupal 7 you can achieve this using template preprocess functions - THEMENAME_preprocess_node.

Steps

First add default user picture, go to sites/default/files and create a folder user_pictures and add default user picture by name default.png
Now add default picture URL using admin/config/people/accounts.

Add this code in template.php

    function THEMENAME_preprocess_node(&$variables) {
      $node = $variables['node'];
      if ($vars['view_mode'] == 'teaser') { //check for teaser views
        //get author picture uri
        $author_picture_uri = db_query("
        SELECT uri FROM {file_managed} fm
        INNER JOIN {users} u ON u.picture = fm.fid
        WHERE u.uid = :uid", array(':uid' => $node->uid))->fetchField();
        $author_picture_uri = !empty($author_picture_uri) ? $author_picture_uri : 'public://default_user.jpg';
        $usr_pic = theme_image_style(
          array(
        'style_name' => 'thumbnail',
        'path' => $author_picture_uri,
        'attributes' => array('class' => 'author-pic'),
        'width' => NULL,
        'height' => NULL
          )
        );
        if ($variables['submitted'] && isset($node->uid)) {
          $variables['submitted'] = t('Submitted by !username !userpicture on !datetime', array('!username' => $variables['name'], '!userpicture' => $usr_pic, '!datetime' => $variables['date']));
        }
      }
    }

Where public://user_pictures/default.png equivalent to sites/default/files/user_pictures/default.png


The module allows to display a popup once after a certain delay on a
  page load. This fills a gap in popup modules family (Popups, Popup),
  which are designed to show popups only after a click on an HTML
  element, or to implement a complex behavior like modal dialog forms.

You can specify paths on which you need to display the popup without appropriate delay


You can use the handy file_create_url() function:

  Creates a web-accessible URL for a stream to an external or local file.


How to set context by url argument for node preprocess

Here's a sketch of what you could do, using a custom module:

Define a menu entry for someview/%node.
Define a callback function for the menu entry with a node argument.
Store the node ID for later use. This could be done using drupal_static or the context API.
In your preprocess function, retrieve the node ID and add a CSS class if required.

You could also use Panels to achieve a similar end, I think, but this is a fairly lightweight, if specific solution.

Let me know if you need a fuller explanation. I realise not everyone is familiar with Drupal APIs.

So your menu callback might look like:
function mymodule_callback($node) {
 context_set("mymodule", "active_nid", $node->nid);
 return views_embed_view((... ...);
}

and in the preprocess:

$active_nid= context_get("mymodule", "active_nid");
 if($active_nid==$node->nid) {
 ...
}


How to change uploaded file name after save node?

hook_entity_presave?

Description from the DocBlock:

  Act on an entity before it is created or updated.
  You can get the original entity object from $entity->original when it is an update of the entity.


Removing all unapproved comments from database dump file

From your dump file,  I would cut the part that insert the data to the comment table. Note: Leave the part that create the table.

In another file paste the part that you cut from the original dump file, using a text editor that can handle to search using regular expressions (as Sublime Text 2).
Create the regular expression that would give you as a result the complete row insert if that row has the status column value set to one.
Once that the regular expression is working, now use the search an replace.
Search all the matches and replace them with ''

When the search and replace is done, you can copy and paste to the sql tab if you are using phpMyAdmin, or even save the resulting file as .sql and import it.

Pretty much the laborious part would be to find the regular expression to use.

Hope this help!


How to get the list of nodes edited by an specific user?

This is how i ll get all nid of revision of an user :

  All node revision are store in the node_revision table.

  $connection = \Drupal::database();
  $query = $connection->query("SELECT DISTINCT(nid) FROM node_revision where revision_uid = 1");
  $result = $query->fetchAll();
  //devel module
  kint($result);

node_revision aren't entity so the only way you have is to do a manuel query.

  And if you need to filter by content type :

      $connection = \Drupal::database();
      $query = $connection->query("
      SELECT DISTINCT(node_revision.nid)
      FROM node_revision
      LEFT JOIN node ON node_revision.nid = node.nid
      WHERE node_revision.revision_uid = 1 and node.type='page'"

);
      $result = $query->fetchAll();
      //devel module
      kint($result);

In this table you can get the revision_log field too.

Then you can use entityManager for load all your node :

 \Drupal::entityManager()->getStorage('node')->loadMultiple($nids);

you need to build your $nids array with the query result.

You can load all revision too by node id.


How to fetch the existing value of a form field in the form?

You can use #default_value attribute of the managed_file to show the existing value of the field.

You can get the value of fid from database and set value into #default_value.

Example:

$form['picture'] = array(
  '#title' => t('Image'),
  '#type' => 'managed_file',
  '#description' => '',
  '#default_value' => 1, //fid from database
  '#upload_location' => 'public://image_example_images/',
);


Can't connect to DB while installing Drupal 8


node--page.tpl.php not detected in Omega subtheme

No node override templates will be repected unless the original node.tpl.php file is also in your theme folder.

Copy the standard template file to node.tpl.php in your theme, clear the caches, and you should be good to go.


Add hidden field to checkbox and submit unchecked value

Take a look at the answer to Custom validation for a form? This tells you how to add your own validation handler to the form. You will need to implement the form_alter like they show to add your custom validation, but also remove the validation that is throwing the error when the value is 0. (You can do this by unsetting that index in the array.) Then, for your custom validation method, my recommendation is to have a validation handler something like:

function my_custom_validation(&$form, &$form_state) {
  if ($form_state['values']['my_checkbox_field'] !== 0) {
    // Call the validation handler you removed in your form_alter
    // I might set the name of the method to a variable in form_state
    the_validation_handler_you_removed($form, $form_state);
  }
}

where you call the original validation handler from your method if the checkbox value is not the specific value you're looking for, in your case 0.


Authenticated user can't download audio, even though has permission

Ok, I didn't realize beyond administering the user roles that I also had to go under Configuration » Media and under private file downloads add a directory '/' under sites/default/files/private... Now it works.


You can handle this very easily in your module. Once you save the account and you have the user object just simply use _user_mail_notify(). As an example:

 _user_mail_notify('password_reset', $account);

If you want to alter the email in any way you can do that with hook_mail_alter() from within your custom module.


Following on from my comment suggesting you do this in an additional submit handler something like this should work:

Add the new submit handler:

function misc_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == 'YOUR_CONTENT_TYPE_node_form') {
    $form['actions']['submit']['#submit'][] = 'rename_files';
  }
}

And then in the new submit handler:

function rename_files($form, &$form_state) {

  $node = $form_state['node'];

  global $user;

  // Loop over the uploaded files. Be sure to re-name field_files to the name of
  // your file field.
  foreach($node->field_files[LANGUAGE_NONE] as $item) {

    // Load the file object
    $file = file_load($item['fid']);

    // To set the destination first remove the filename from the stream wrapper
    // URI.
    $destination = str_replace($file->filename, '', $file->uri);

    // Modify this line to the name of your group field.
    $group = $node->field_group[LANGUAGE_NONE][0]['value'];

    // And then append the group, uid and put the filename back on the end.
    $destination .= $group.$user->uid.$file->filename;

    // And finally rename the file.
    file_move($file, $destination);
  }

}


How to enable tag moderation using rules?

I think this module Content Moderation is help to create rules

  Some selected group should first review those changes (based one a    specific revision marked for "approval). In the meantime others
  should be able to edit and create new revisions (which are not part
  of this approval process)
  Later some group can approve that revision and make it the new    live-version
  Every state change (review, approval..) should get logged in a    history. You always want to know, who reviewed / approved what, when
  and what revisions
  You want to have a different workflow, like some other states between    review and approve and live. You want to define your own
  workflow.
  You want to create ToDo list for you reviwer / approval teams


Drupal Time field for hour:minute:second.tenth of a second

No time field will give you what you are looking for. They all work with Unix time, which is defined as 'the number of seconds since midnight, January 1, 1970'. The maximum granularity you will see is one second.

If you wish to record this information to one one-hundredth of a second, you will need to define the field and its formatting yourself.


How to check that cache is working on current page?

The easiest way is probably to inspect the HTTP response headers.

For example, with your browser DOM inspector tool ( e.g Chrome's "Network" tab )

Cache Miss

Here's some sample response headers from drupal.org showing a cache miss. In this case, using Varnish however core Drupal cache also sets similar headers.

Cache Hit

Here's one showing a standard Drupal cache hit:


How do I display a block on an edit form for particular content types?

You need to add php code in the block Visibility settings in admin section of block. You can follow below code.

$node = menu_get_object();

   if (isset($node) && $node->type == 'article' && arg(2) == 'edit') {

     return TRUE;
   }

   return FALSE

Another example:

$nid = arg(1);

   $node = node_load($nid);

   if (isset($node) && $node->type == 'article' && arg(2) == 'edit') {

     return TRUE;
   }

   return FALSE


Is there a limit on taxonomy hierarchy depth by default?

I just posted an answer to a similar question at https://drupal.stackexchange.com/a/199247/6488 but if you are wanting it to be a sitewide default you would:

remove the if ($form['#bundle'] == 'MY_VOCAB') from
hook_form_taxonomy_form_term_alter()
Change the check against current_path() in the hook_preprocess_page()

Some clever person could turn this into a module!


How to pass a Date as Contextual Filter?

Finally, I made it work.
I used mymodule_views_query_alter replacing the operator of the proper condition:

  if ($view->id() == 'services' && $view->current_display == 'embed_2') {
    foreach ($query->where as &$condition_group) {
      foreach ($condition_group['conditions'] as &$condition) {
        if ($condition['field'] == 'service.additiondate') {
          $condition['operator'] ='>=';
        }
      }
    }
  }


Get single field valure from node object

Entity API

Documentation says: The Entity API provides wrapper classes you may use to make dealing with the values of an entities properties and fields easier. Wrappers make it easier to get and set the values of fields and properties as well as to programmatically retrieve additional information about these elements and iterate over lists of values in a consistent manner.
https://drupal.org/node/1021556

    // Create wrapper around the node.
    $wrapper = entity_metadata_wrapper('node', $node);

    // We can do it also using only $nid.
    $wrapper = entity_metadata_wrapper('node', $nid);

    // Get the value of field_name of the node.
    $wrapper->field_name->value();

    // Get the value of field_name of the nodes author's profile.
    $wrapper->author->profile->field_name->value();
    $wrapper->author->profile->field_name->set('New name');


How can I get the node ID inside my implementation of hook_tokens()?

Since you are defining your own token type, you need to pass the node object to token_replace() in the $data array, for example as $data['node'] or $data['abc']->node, as you are telling Drupal the token requires the 'abc' data.

Your hook_token_info() implementation is wrong, anyway. The correct one would be the following one.

function mymodule_token_info() {
  $type = array(
    'name' => t('xyz'),
    'description' => t('The tokens for the xyz data.'),
    'needs-data' => 'xyz',
  );
  $tokens['full_html_form'] =array(
    'name' => t('Full HTML Form'),
    'description' => t('Returns full HTML Form based on the node'),
  );

  return array(
    'types' => array('abc' => $type),
    'tokens' => array('abc' => $tokens),  /* << */
  );
}

From your code is not clear, but if the token is generated for a node, then you should implement code similar to the following one. (See token_token_info() as guideline.)

function mymodule_token_info() {
  $info['tokens']['node']['full_html_form'] = array(
    'name' => t('Full HTML Form'),
    'description' => t('Returns full HTML Form based on the node'),
  );

  return $info;
}

Modules can define new tokens for token types defined from other modules. The Token module is an example of such a module.


I would guess that the URL is wrong in your javascript.

Currently, if your site is on http://localhost, the page requested will be:

http://localhost/localhost/drupal/my_currenttime/10

When I suspect it should be:

http://localhost/drupal/my_currenttime/10

To fix that just add the http:// part to the beginning of the URL variable in your JS code, or make it relative:

url: '/drupal/my_currenttime/10'


Cannot log in to drupal admin in a new installation (access denied)

It may also be a cookie problem. To check if that is what causing it, just try to use another web browser to verify if you get the same problem.

If using that other browser the problem disappaears, then DELETE the cookie in the browser where you experience this problem and try again. Pretty sure your issue will be solved then.

Curious to hear if this helps (sometimes it does ...).


Well adding JavaScript can be done through drupal_add_js().

You can add the JavaScript code in your template.php file.

Create a cool.js file where you copy the JavaScript code
Put the file in your themes/MYTHEME/js folder
In your template.php file, create a  page preprocess function

function MYTHEME_preprocess_page(&$vars) {
  drupal_add_js(drupal_get_path('theme', 'MYTHEME') . "/js/cool.js", array("preprocess" => True));
}

Clear the cache
Load your page and check the page source code to see if cool.js is being loaded; use ctrl+f to see if the file is present there
If the effect is still not coming, then verify the IDs in the HTML are correct


XML Source Won't import without a Source ID

field_guid doesn't exist until the process pipeline runs, which is too late to use as a source ID. You can either simply use guid itself as your ID (with type: string), or do the truncation in prepareRow().


order of execution of hook_node_presave and custom submit function

In the core system hook_node_presave() is only ever invoked once, from inside node_save() itself. In the context of a node add/edit form it's called by the original form submit handler, which unless you've explicitly engineered otherwise, will be run before the call to your custom submit handler.

Similar to your other question the submit handler isn't really the best place for this logic, as that code will literally only run when a form has been submitted (not when a node has been added programmatically for example).

After node_save() has saved the node data to the database, it invokes one of two other node hooks...hook_node_insert() and hook_entity_update() (obviously depending on the current operation).

One of those hooks will be called after the data has been committed to the db so will be perfect for your needs.


How to update the page breadcrumb when using theme page

If you are looking for GUI to handle breadcrumbs, take a look at Custom breadcrumbs module.
Otherwise, you can manage your breadcrumbs programatically in lot of hooks. The code you've printed is correct, so you can create for example a function with a switch case like this one :

function manager_breadcrumbs($form_id) {
  $breadcrumb = array();
  $breadcrumb[] = l('Home', '<front>');
  switch ($form_id) {
    case 'my_first_form' :
      $breadcrumb[] = l('Category', 'taxonomy/term/1');
      break;
  }
  drupal_set_breadcrumb($breadcrumb);
}

And then, call this function in a hook_form_alter() like this.

function MY_CUSTOM_MODULE_form_alter(&$form, &$form_state, $form_id) {
  manager_breadcrumbs($form_id);
}


Getting an error on field module when saving a node

I would check cck fields to find which one causes the issue first and go from there, the error message related to 'fetch entities from cache, if applicable'.


There is indeed a "Save as Draft" button in webforms. Check the permissions with "allow users to save draft" in the permission page.

There has been an issue reported here with the same problem as yours.


To clear out the confusion, a static query usually refers to a raw mysql query that you use through db_query() function. You write the entire query and pass it as the first parameter of the db_query function.

Dynamic queries, like the one you have in your question, is called dynamic query which makes it really easy to build the query dynamically. Think about a query that you need to iterate through a dynamic list of conditions. You will need to fight with string related functions to build the query, that you can now use the query builder to do for you!

If you use something like this:

$result = db_query('SELECT n.title
FROM {node} n WHERE n.uid = :uid', array(':uid' => $uid));

It's considered safe against SQL injection (when you query the node table for users, always pay attention to their access permissions).

But this:

$result = db_query('SELECT n.title
FROM {node} n WHERE n.uid = ' . $uid);

is bad! We can't make sure that $uid will be completely safe to throw into the database.

  Does this also apply to queries written with the query builder, like
  the one above?
  With Query builder, you will not need to use these parameters (:uid from above "good" example) in most queries. WHERE, ORDER BY and other clauses have their own methods that you can use in the query builder. Your code in the question is in the correct format.

In case you need to use a variable in the query, do use parameterized pattern.

Correct:

$query = db_select('node', 'n');

$table_alias = $query->join('users', 'u', 'n.uid = u.uid AND u.uid = :uid', array(':uid' => 5));

Wrong:

$query = db_select('node', 'n');

$table_alias = $query->join('users', 'u', 'n.uid = u.uid AND u.uid = ' . $uid);

(I'm aware that above query couple do not make any sense :D Just copied from the linked page in your question)


How to use hook_menu_link_alter() on taxonomy term view?

hook_menu_link_alter() is invoked from menu_link_save(), which is the function called when a menu link is saved. The code you wrote for that hook would be invoked when, for example, you add a menu link from admin/structure/menu/manage/main-menu/add, and use taxonomy/term/%taxonomy_term/edit as value for Path.

As Clive said, hook_menu_alter() is the hook you should use to change the menu item defined in hook_menu() from a module.


You may put template for user page like  user-profile.tpl.php
This template is used when viewing a registered member's profile page,

e.g., example.com/user/123. 123 being the users ID.

Available variables:

$user_profile: An array of profile items. Use render() to print them.
Field variables: for each field instance attached to the user a corresponding variable is defined; e.g., $user->field_example has a variable $field_example defined. When needing to access a field's raw values, developers/themers are strongly encouraged to use these variables. Otherwise they will have to explicitly specify the desired field language, e.g. $user->field_example['en'], thus overriding any language negotiation rule that was previously applied.

OR

use hook_menu_link_alter

function hook_menu_link_alter(&$item) {
  // Make all new admin links hidden (a.k.a disabled).
  if (strpos($item['link_path'], 'admin') === 0 && empty($item['mlid'])) {
    $item['hidden'] = 1;
  }
  // Flag a link to be altered by hook_translated_menu_link_alter().
  if ($item['link_path'] == 'devel/cache/clear') {
    $item['options']['alter'] = TRUE;
  }
  // Flag a link to be altered by hook_translated_menu_link_alter(), but only
  // if it is derived from a menu router item; i.e., do not alter a custom
  // menu link pointing to the same path that has been created by a user.
  if ($item['link_path'] == 'user' && $item['module'] == 'system') {
    $item['options']['alter'] = TRUE;
  }
}


How to include a rule variable (text) in "Set a data value" direct input mode

Okay, the answer is: What I was doing wrong was trying to use a feature that did not exist! However, milesw posted a patch on my d.o issue (  http://drupal.org/node/1547160 ) that totally worked for me (woo!) and that I hope will work for you too if you're looking for the same feature.

Edit: If you are looking for this feature please could you try milesw's patch and feed back on it.


Creating a view by comparing two fields of two different content types using the same taxonomy

This types of matching (list Taxonomy siblings) is usually done through Has Taxonomy term ID Contextual filter, but your case is a bit more indirect.

You're not showing related content on other node pages. You want to list some content on User pages, but the matching is not done between the listed content and the user (because you don't have Taxonomy on users), it is one step more removed, you're matching content through the user "bridge" to other content.

You need to go "the entity reference" way to achieve all the necessary matching and contextual filtering.

First we list the user Offer nodes because they give context, they tell us which categories to look for. Once we have that we pull into Views Needs nodes that share the same category field values as those offers, and we additionally filter out that user Needs, in case they have any, because they're only interested in seeing other people's matching Needs.

Create Page Display Views listing Offers! (filter Content type)
Change Path to user/%user/related-needs
Add Menu Tab (it will show on user profiles)
Add Relationship Taxonomy term referenced from field_category from the Content Category, you can require it since they will all have it filled in
Add a new Relationship Content using field_category from the Taxonomy term Category.

This Relationship automatically uses the first Relationship. This is where the matching is done from all Offers nodes category back to all the nodes on the system using that same category.

You have the Title field showing Offer nodes at this point. You can keep it this way just to test, but that field isn't our target since we want to see the list of Needs related to the Offers. Or if you don't need it: modify it according to the following step:
Add another Title Field and make it use the second Relationship (it will be the only one available). This will show the nodes that share the same category taxonomy as the Offer node in that same views row.

From now on, for every field you add, if you're not using a Relationship it will show Offer node data, and if you use the second Relationship it will show the data from nodes that share the same category as the Offer node from that row. This includes the Needs node we are after.
Add Contextual filter Authored by from the Content Category and configure it:
Do not use a relationship
When the filter value is NOT available
Provide default value
User ID from route context
When the filter value IS available or a default is provided
Override title
Needs matching user {{ arguments.uid }} Offerings (check your argument token under Replacement patterns)
Specify validation criteria
User ID

This Contextual filters out Offer nodes authored by the user whose profile is being viewed.
Add another Contextual filter Authored by from the Content Category and configure it:
Relationship field_category (the second one)
When the filter value is NOT available
Provide default value
Raw value from URL
2
When the filter value IS available or a default is provided
Specify validation criteria
User ID
More
Exclude

This Contextual filter excludes Needs nodes authored by the currently viewed user since it doesn't make sense to show these. This step isn't necessary if your users will never have Needs nodes that share the same category with their Offer nodes.
Since you'll probably have duplicates in your results you can sort it out by turning Aggregation on. If you have Needs fields other than Title you may need to change their Aggregation settings from Entity ID to Target_id.

Make sure you have all Sort Criteria removed since it interferes with Aggregation.

Visit the user profile page and find the tab, and check that the results are as you'd expect. It seems like a complicated procedure but it makes sense once you understand what is happening in each step.


node.tpl render field from referenced entity

You can use https://www.drupal.org/project/inline_entity_display to do that with entity reference and field collection field.


taxonomy_term_save($entity); inside "Execute Arbitrary PHP Script" will do the trick.
In D7, the variable is $entity, for D6 it is $object.


You have to create a view with two displays of type block. Arrange some region or panel method to display them in side by side fashion.

Create view, select its type as node, choose fields and filters according to your requirement.

For View display having latest item:

Click Pager from your view settings and define Items per page as 1 and set sort order Date created/posted as descending.

For View display having next three items:

Click Pager settings and define Items per page as 3 and set Offset as 1 and define the same date order as for the previous view display.

Thumbnails settings:

While selecting your fields particularly selecting image field (must be part of your post's content type) as thumbnail for post, choose image style. The image style are thumbnail sizes and formats. See the interface on example.com/admin/config/media/image-styles to add your custom image forma-tors so that a proper thumbnail can appear on each view display.


While this doesn't answer the behavior of the Entity Reference fields over different languages, switching the entity selection mode to a view seems to have solved it.

As suggested by Lester, I'm still unsure if the default 'Simple' selection mode was taking issue with the title of my fields, although rather than using the Title module - which can trip up other modules, i have found - I tend to keep the old title field and label it 'Administrative title' while adding a separate 'Translatable title' to work with - so in that sense there shouldn't have been an issue with the 'Simple' selection method.

Either way, setting up an Entity Reference View which displays and searches the 'Translatable title' of my Features node seems to have worked!

EDIT:

@Dan - these labels, are they node titles or fields which you created?

The issue with standard node titles is that they are different from other fields and as such are not 'entities' - this means that entity translation will not work on them. The workaround is to either use the Title module to replace the default title field with an entity (I had some issues with this), or use a different field which you create yourself.

Once the field you need to translate is an 'entity' (basically an field you create yourself, or one generated by the Title module) you can enable translation for it when adding the field to a content type.

Next you need to create a new view containing whatever content you want to use and click the + button to add an 'entity reference view'. After configuring this view with the fields you want to display and saving you should find that when editing the Entity Reference field in your content type, you can change the Entity selection mode to Views and select your newly created view.

I hope that makes sense!


commerce show message if anonymous user adds product to cart

OK things worked out when I changed the condition to : user has role and passed in the current user as a parameter

I would still love to know where I went wrong in my first approach


How can I present a screen that asks users to confirm their account details upon registration?

you have a function for that "function confirm_form"

see this link https://api.drupal.org/api/drupal/modules!system!system.module/function/confirm_form/7

2. add through js

<?php
    drupal_add_js('(function($){ $(function(){$("#edit-xxxxxx").click(function(){return confirm("confirm do that ?")});}); })(jQuery);', array('type' => 'inline'));
?>

refer the above link you will get three different ideas


User profile image update from a popup window

Profile Pic Changer Module Provides a modal dialog box to change user pictures

  Allow users to change their profile picture through a modal form
  directly on their profile page, without having to go to the profile
  edit form.


You should be able to use Feeds Tamper to create your URLs based on values in your CSV: https://www.drupal.org/project/feeds_tamper


Hook_form_alter in Views header PHP code

Found a solution, but if there is a better way I'd like to hear more.

$edit_page['actions']['delete']=false; //removed delete button
$edit_page['title']=false; //removed title display as well


When Drupal includes the template file, your declaration of $a = '1' is not in the global scope. You need to declare it as such:

global $a;
$a = '1';

Since you're diving into the realm of global variables though, I'd recommend using a more distinctive name, or figuring out how to avoid globals altogether.


You could use the Rules module as it integrates very well with the Flag module.

Check out the Flag video series by Johan Falk. Part 7 is specifically regarding Rules.

In short you're looking to generate a list of users that have flagged a node and then with built in Rules actions, unflag them.


Options in facets disappear when more than one value is selected

This is a bug with solr 3.5 and the search_api_solr module, the bug is described here:https://www.drupal.org/node/2474661 the bug report includes a patch that fixes the issue. With the patch in place everything works as expected.


Deprecated configuration for the temporary files path

Starting in 8.8, Drupal no longer allows setting the temp directory on the file system setting form. The form deliberately disables the field to prevent folks from using it. For full info about this change, see Deprecate file_directory_temp() and move to FileSystem service on d.o.

All you have to do is set the temp directory path in settings.php as the message indicates.

$settings['file_temp_path'] = '/path/to/tmp';

Note: if your temp directory is not /tmp, do this before running database updates. From the d.o issue where this change was implemented:

  If your site is not using /tmp, you must update settings.php before
  running database updates.

What if I run database updates before setting the temp path in settings.php?

Looking at the issue and reviewing the most recent patch (patch #121), it doesn't look like anything terrible happens. The only thing that happens during update.php is it attempts to delete the deprecated config for temp file path from system.file.path.temporary (where it's set on the /admin/config/media/file-system page). However, it'll only remove the config if it's safe to do so.

/**
 * Remove 'path.temporary' config if redundant.
 */
function system_update_8801() {
  // If settings is already being used, or the config is set to the OS default,
  // clear the config value.
  $config = Drupal::configFactory()->getEditable('system.file');
  if (Settings::get('file_temp_path') || $config->get('path.temporary') === FileSystem::getOsTemporaryDirectory()) {
    $config->clear('path.temporary')
      ->save(TRUE);
  }
}

While nothing is broken, you will end up with deprecated config just hanging around (forever?). To get your site to a state that matches where it would've been had you made the settings.php update before running updates, make sure you set $settings['file_temp_path'] in settings.php and then do one of the following:

Create a new update hook in a custom module that has the same contents of system_update_8801() then run updates again after making the update to settings.php.
Manually edit the config file in your config directory to remove the configuration, then import.
See How do I re-run updates (change module schema version)? to attempt to rerun the original update.


If your date is in one of the supported date/time formats, you can use strtotime() and date() to compare.  Wrap the printing of $time_output in an if statement.  For example:

if ( strtotime($date_output) > date() ) {
  // $date_output is greater than now, eg, not expired
  print($time_output);
}

If $date_output is already a timestamp, no need to use strtotime()


The "Hosting" li item is only active if you're on the Hosting page.  If you're on a child page of "Hosting" won't be the "active" item, it will be the "active-trail".

You can change your navigation CSS to make the link look properly by changing .active to .active-trail:

.navigation li a:hover, .navigation .active a {
    background: none repeat scroll 0 0 #FFFFFF;
    border-color: #E99719;
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
}

to

.navigation li a:hover, .navigation .active-trail a {
    background: none repeat scroll 0 0 #FFFFFF;
    border-color: #E99719;
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
}

What might have confused you is that the link itself has a class of active, but its li wrapper does not.


Remove the "Please wait" text on Ajax Call

You should be able to do this with hook_form_alter() by changing the Ajax settings that control the form's Ajax. There is a 'progress' property in Ajax that will allow you to set or change the 'Please wait...' text. From the API docs:

#ajax['progress']['message'] String. An optional message to the user; should be wrapped with t().

A sample hook_form_alter() that will accomplish this:

function mymodule_form_FORM_ID_alter($form, &$form_state) {
  unset($form['element']['#ajax']['progress']['message']);
  // or:
  $form['element']['#ajax']['progress']['message'] = '';
}

You should be able to use print_r($form); or dsm($form) (with Devel module) to locate the form element with Ajax properties set. Use that to locate the proper element and replace my $form['element'] above with the actual element in question.


How to redirect after submitting a multi-step registration form?

First, make sure no modules with a higher weight than yours are changing the value of $form_state['redirect'] in their hook_form_alter() implementations. Stepping through with Xdebug is a fairly easy way to do this.

If that is not the cause, then it sounds like a call to drupal_goto() is happening somewhere in the process and interrupting the page flow. If your multistep form is working up until the final step, it could well be your own code doing it. Otherwise, check if anything you are doing would trigger any hook implementations or other code that could contain immediate redirects (a.k.a drupal_goto).

Devel can also display a redirection page, which may be a useful feature when debugging this.

Finally, check that $_REQUEST['destination'] isn't being set via the URL or otherwise.


Change list of values dynamically with a click

You don't need to let anon visitors edit nodes to achieve this, and I wouldn't recommend it. It presents a security issue, and would store the "selected" status as a property of the node (for all visitors).

Rather, you can store the selected nodes in a session or a cookie, using a standalone drupal form. Create a form, like so:

function YOURMODULE_node_store_form($form, &$form_state, $nid) {
  $form_state['nid'] = $nid;
  $dv = (isset($_SESSION['node_store'] && in_array($nid, $_SESSION['node_store']) ? 1 : NULL;
  $form['selected'] = array(
    '#type' => 'checkbox',
    '#title' => 'Include this page in email.',
    '#default_value' => $dv,
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Submit',
  );
  return $form;
}

function YOURMODULE_node_store_form_submit($form, $form_state) {
  if($form_state['values']['selected'] && $form_state['nid']) {
    $_SESSION['node_store'][] = $form_state['nid'];
    drupal_set_message('The page will be included in the email.');
  }
}

In the template file for the Piece content type, add the form to the teaser display, like so:

<?php print render(drupal_get_form(MYMODULE_node_store_form, $node->nid);) ?>

To include the stored nodes in the mail, you can retrieve them from the $_SESSION['node_store'] array. Once the email has been sent, you should probably clear the $_SESSION['node_store'] array.

If you DO have to store it to the node, use the node_save function in your submit handler, instead:

function YOURMODULE_node_store_form_submit($form, $form_state) {
  if($form_state['values']['selected'] && $node = node_load($form_state['nid'])) {
    $node->field_selected[$node->language][0]['value'] = 1;
    node_save($node);
    $_SESSION['node_store'][] = $node->nid;
    drupal_set_message('The page will be included in the email.');
  }
}


how to get css "background-color" value from content types

Drupal 7

What you can do is have a field or just for an example a simple textfield and you can use hook_node_view() or template_preprocess_node() to get the color value and use drupal_add_css(). An example would be like:

OPTION 1 - Module layer

/**
 * Implements hook_node_view().
 */
function YOURMODULE_node_view($node, $view_mode) {

  // We check if the user is viewing the node/page in it's full view
  if ($view_mode == 'full' && $node->type == 'page') {

    $field = field_get_items('node', $node, 'field_background_color');

    // Check if the field has a value
    if ($field) {

      $color = field_view_value('node', $node, 'field_background_color', $field[0]);

      // We specify the type to inline and group so it would override any style.
      drupal_add_css("#main-wrapper { background: {$color['#markup']}; }",
        array('type' => 'inline', 'group' => CSS_THEME)
      );
    }
  }
}

OPTION 2 - Theme layer

/**
 * Implements template_preprocess_node().
 */
function YOURTHEME_preprocess_node(&$variables) {

  // We check if the user is viewing the node/page in it's full view
  if ($variables['view_mode'] == 'full' && $variables['type'] == 'article') {

    // Get the node object to be used later
    $node = node_load($variables['nid']);

    $field = field_get_items('node', $node, 'field_background_color');

    // Check if the field has a value
    if ($field) {

      $color = field_view_value('node', $node, 'field_background_color', $field[0]);

      // We specify the type to inline and group so it would override
      drupal_add_css("#main-wrapper { background: {$color['#markup']}; }",
        array('type' => 'inline', 'group' => CSS_THEME)
      );
    }
  }
}


Rotating image background in a div using Background Field

It is not a Drupal Module but a very simply jQuery plugin to use.

http://jquery.malsup.com/cycle/

A snippet of me using it from my javascript:

function handle_header_carousel() {
    if ( jQuery('#header_carousel').get(0) == undefined ) {
        return;
    }
    jQuery('#header_carousel').cycle({
        fx:     'fade',
        speed:   300,
        timeout: 3000,
        next:   '#s3',
        pause:   1
    });
}

From my template page that houses the images:

            <img src="/<?php echo drupal_get_path("theme", "tcth"); ?>/img/carousel_1.jpg" />
            <img src="/<?php echo drupal_get_path("theme", "tcth"); ?>/img/carousel_2.jpg" />
            <img src="/<?php echo drupal_get_path("theme", "tcth"); ?>/img/carousel_3.jpg" />
            <img src="/<?php echo drupal_get_path("theme", "tcth"); ?>/img/carousel_4.jpg" />


How to setup a csv-file to import image-paths into an image-field via Feeds-module?

You need to specify the full HTTP path. It's possible that something like a file schema might work (public://images/name.JPG), but in my extensive use with Feeds we import file fields (mostly images but also mp3, pdf, etc) by specifying the full HTTP path that the file can be found at, e.g.: http://example.com/sites/default/files/images/name.JPG.


Load all field collections of a given type

Lets say you have field collection with type 'field_my_dates'. So you can get field collection details using node and collection type as given below.

<?PHP
    $itemCollection = field_get_items('node', $node, 'field_my_dates');
    $wrapper = entity_metadata_wrapper('node', $node);
?>

Thanks


How to get list of activated and deactivated module using some script from database?

For disabled modules:
SELECT * FROM system WHERE type='module' AND status=0

For enabled modules:
SELECT * FROM system WHERE type='module' AND status=1

If you need to do this using drupal functions, you can try something like:

    $query = db_select('system', 's')
    ->fields('s', array('name', 'weight'))
    ->condition('type', 'module')
    ->condition('status', 0);
    $result = $query->execute();

    foreach ($result->fetchAll() as $record) {
      // do something here...
    }

And process the results from $result.


It sounds like the login_disable module will do exactly what you need.

Prevent users from logging in to your Drupal site unless they know the secret key to add to the end of the login form page. ( default: http://example.com/?q=user/login&admin )
If your site has clean urls enabled you may use http://example.com/user/login?admin instead.

That way you can set a secret key so only users who know that key are able to log in using the login form.
Another possible solution would be to disable the login form completely, like this:
function MY_MODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'user_login') {
    $form['#access'] = FALSE;
  }
}


Weform: Send email to the email field in the node reference field using rules

I have done some work around to get this functionality.

Created a hidden component to the webform.

Then through hook_form_alter, get the organiser email from the referenced node and set it as the default value to that hidden field.

Then in the webform email settings, I selected that hidden webform component as the "Email to address".


Sharing fields and their data between a user profile and a content type?

I guess one option would be to use Rules, so that when one entity is saved, the field data is also saved int the field on the other entity.


You shouldn't alter the query objects properties directly. You need to use the methods it provides. In this case, you need to use add_where(). I think you want to consider something like this:

<?php
$clauses = array("field_test_value='%s'");
$args = array('test1');
$query->add_where(1, $clauses, $args);
$query->set_group_operator('OR'); // this is the operator that goes between WHERE groups
?>


How to add link title in combine field filter

Add both link field title and link field url as fields in the views.
If you don't need title field, please  check "exclude from display".
Then try searching using the content of title field(in your example. "test")


Create a product after form submission using commerce and rules

It depends on the implementation of this submission form, but a common way to expose fields in Rules is to add a condition 'Entity has field' in your rule.

In your particular case, you would select node as entity and the particular entity reference field.

In this way the rule will only execute if the node indeed has this field, and also will allow you to use the field in your actions below.


Prevent Redis Cache from clearing ALL keys

You can set your default Drupal key up (in settings.php) then have your custom keys set to not expire or last longer.

$conf['cache_prefix'] = array('default' => 'your-redis-key');

See Redis config file for documentation on how to setup max memory and such: https://raw.githubusercontent.com/antirez/redis/2.8/redis.conf

By doing this you would be setting up the policies that Redis will use to clear the cache out and what to clear. It has to clear eventually or it will become unstable, it's just cache after all :) I wouldn't be depending on it to stay that's for sure.


Download and install this module http://drupal.org/project/login_destination

It is also possible to keep users on the currently visited page after logging in or out.

Hope it will match your requirement!!!


Panels page - node template - comments won't appear

Try checking if you are seeing the teaser view which may remove the comments, otherwise check to see if the panel settings allows the the comments to be shown


In your view, add a filter criteria of 'Content: Nid', then specify the node id of the webform in question. To locate the node id you can edit the webform and look at the url. The url will be /node/xxx/edit where xxx is the nid.


HTML markup is still stripped out, even if I am using the mimemail-message.tpl.php template

I added the htmlmail module and this fixed the problem.


Well, You need to use theme() function, which will allow to define the template name to be called, and the variables (values) to be send over to the template file defined.
Please refer documentation here - https://api.drupal.org/api/drupal/includes!theme.inc/function/theme/7

$read_more = theme('more_link', array('url' => 'aggregator/sources/' . $feed->fid, 'title' => t("View this feed's recent news.")));

In the above code "more_link" is template name and associative array of values to be passed. In Template, you will get value of $title as "View this feed's recent news."
Hope you got the point.


Search Api Solr - Pointing term links inside a view to its facet

Why would you want the fields in the search results to have taxonomy terms that are linked to the facet URL instead of the taxonomy page of the item? It just seems a little redundant, because that's what the facets there are for.

A solution would be to use FacetAPI Pretty Paths and rewrite the output link of the taxonomy term to match the URL of the facet. You'll need the fields term name and id, then format as : www.example.com/search-page/[pretty paths term]/[term name]-[term id]


Which module for responsive images without Apache?

try to use these modules. also suggest to use Adaptive theme.

http://drupal.org/project/responsive_images
http://drupal.org/project/resp_img


Is it possible to set a single member of a complex-variable inside the variable table

Drush does not support modifying elements inside a complex variable directly.  You could instead use php-eval to do this:

$ drush php-eval '$v = variable_get("theme_themeName_settings"); $v["key"] = "value"; variable_set("theme_themeName_settings", $v);'


How to show a user's age at the time of creating a node in a View?

it can be done by rules, here is a rule that calculate in DAYS the difference between two dates. my rules does the following, make necesary changes to fit your needs:
First convert both dates to an integer value, then substract them (date1-date2= diff-value in seconds), for days value divide diff-value by 86400 (24*60*60), this new variable convert it to an integer, this last value is the diference in days between those 2 dates. react on after saving(updating) your node, store this value by rules in a node hidden field, last add this field to your view.

rule's code:

{ "rules_parcialidad_calculate_dias_de_retraso" : {
"LABEL" : "parcialidad calculate dias de retraso",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "calculate retraso pago" ],
"REQUIRES" : [ "rules" ],
"ON" : { "node_update--parcialidad" : { "bundle" : "parcialidad" } },
"DO" : [
  { "data_convert" : {
      "USING" : {
        "type" : "integer",
        "value" : [ "node-unchanged:field-fecha-de-parcialidad" ]
      },
      "PROVIDE" : { "conversion_result" : { "fecha_parcialidad_converted" : "fecha_parcialidad_converted" } }
    }
  },
  { "data_convert" : {
      "USING" : { "type" : "integer", "value" : [ "node:field-fecha-de-pago" ] },
      "PROVIDE" : { "conversion_result" : { "fecha_pago_converted" : "fecha_pago_converted" } }
    }
  },
  { "data_calc" : {
      "USING" : {
        "input_1" : [ "fecha-pago-converted" ],
        "op" : "-",
        "input_2" : [ "fecha-parcialidad-converted" ]
      },
      "PROVIDE" : { "result" : { "diferencia_en_segundos" : "direfencia_en_segundos" } }
    }
  },
  { "data_calc" : {
      "USING" : {
        "input_1" : [ "diferencia-en-segundos" ],
        "op" : "\/",
        "input_2" : "86400"
      },
      "PROVIDE" : { "result" : { "diferencia_en_dias" : "diferencia_en_dias" } }
    }
  },
  { "data_convert" : {
      "USING" : { "type" : "integer", "value" : [ "diferencia-en-dias" ] },
      "PROVIDE" : { "conversion_result" : { "retraso_dias_round" : "retraso_dias_round" } }
    }
  },
  { "data_set" : {
      "data" : [ "node:field-parcialidades-dias-retraso" ],
      "value" : [ "retraso-dias-round" ]
    }
  }
]

}
}


Exclude /sites/*/files/css and /sites/*/files/js from repository. It's just a cache so it should never be committed or migrated.
Before each migration purge /sites/*/files/css and /sites/*/files/js. That way you will get rid of months old cache. After each migration, make sure these directories are writeable. mmtwln seems to be a string added by Drupal or some module to prevent proxy caching, or it may be a string added by a proxy itself. it shouldn't affect static files at all (except cache prevention, but even that isn't sure)
Your site fails at saving cookies. Check your cookie domain settings in sites/mysite/settings.php and make sure you have right data in example.org/admin/config/system/site-information

If above is insufficient:

manually (via ssh/sftp/ftp) compare offending CSS files. Does the version downloaded from server look the same as version you was sure you uploaded? If not, consult your sysadmin as your server is malfunctioning somehow.
if the version you download from server via ssh is the same you uploaded, but differs from the one you downloaded via http, check carefully your .htaccess - probably there are some redirection rules that make your server to serve file from different location. Common offender is boost module, if you used to have it installed and now only it's rewrites are left, you can easily get the exact behaviour you described.


The answer was to modify the views query!


You can switch users from blocked to active upon flagging with the Rules module, which integrates with Flag.  Create a rule on the Event "User is flagged with approval flag."  Then add the action Unblock a user  (under Users in the list).


Perhaps install and enable devel, and then look at the SQL queries to get the offending query which might give you clue about some other module that's doing an update.


move fields in the user profile form in fieldsets

As you mentioned the problem appears in user_account_form_validate() because you changed the account index from $form['account']['mail'] to $form['change_mail']['mail']

the issue is with this line form_set_value($form['account']['mail'], $mail, $form_state);

In order to achieve what you are looking for you need to replace existing form validation with a custom validation as the following code:

function MODULE_NAME_form_user_profile_form_alter(&$form, &$form_state, $form_id) {

  $form['change_mail'] = array(
    '#type' => 'fieldset',
    '#title' => 'change email address cake',
    '#weight' => 6,
    '#collapsible' => FALSE,
    '#tree' => FALSE,
  );

  $form['change_mail']['mail'] = $form['account']['mail'];
  unset($form['account']['mail']);
  $form['change_mail']['confirm_mail'] = $form['account']['confirm_mail'];
  unset($form['account']['confirm_mail']);

  $form['#validate'][0] = 'MODULE_NAME_user_account_form_validate';
}

function MODULE_NAME_user_account_form_validate($form, &$form_state) {
  $form['account']['mail'] = $form['change_mail']['mail'];
  // original validation function
  user_account_form_validate($form, $form_state);
}


Wrong and ignored language to be translated

First, you need to select source/default language from admin/config/regional/language.

After you need to import .po file of English or your selected import other import languages (https://localize.drupal.org/translate/languages/en).

Now you will able to translate your term from Config > Regional > Translate. and those are visible according to your language.


Create a module to customize the cart form. Here's how I usually do it.

function custom_cart_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'uc_cart_view_form') {

    for($i=0;$i<count($form['items']);$i++){
       //these are rows in your cart... that includes the "total" line etc, so make sure to check that the row has the data you need

       //I believe what you're looking for is in $form['items'][$i]['desc']['#value']
       //you're going to need to look for the empty tag, probably using a regex pattern and remove the whole <li> element
    }

  }
}


Sort a view by price using commerce price?

Follow the below steps and share the output:

Create a views with the same content type in which the field exists from which you need to filter easily with "filter section" in views.
Select the same field of content which you want to filter.
Select the same fields in filter with sorting order "ASC" or "DESC".

Mention please use Commerce Views plugin for the same.

Thanks.


What you need to use is the fieldCondition
, which works pretty much like entityCondition and propertyCondition, only you are adding a condition for the field and not the entity or one of it's properties.

This is how you should query fields and entities.

If you wanted to get info about the how the data of a field was stored, that information is available on the field itself. So you could do

$field = field_info_field('field_name');
$storage_details = $field['storage']['details'];

What info you get depends on how the field is stored, as Drupal support multiple storage backends for fields.


Module to add keyword search capability to content admin page?

The Admin VBO Views module provides a complementary content admin page, with a search by title (and other fields) enabled by default.

It wouldn't take much to edit the View provided by that module to provide further exposed filters to search the content with.


Make sure what you're passing in is a renderable array... and render it before assigning it to the message body field:

  $markup = ['#markup' => "We do HTML"];
  $message['body'][] = render($markup);

Note: This makes some sense i guess but i really just stumbled onto the solution, so i'm not sure how correct it is, but it works.

Incidentally, for the plain-text version i recommend doing what Drupal core's PHP mailer does in its format method:

use Drupal\Core\Mail\MailFormatHelper;

// Join the body array into one string.
$message['body'] = implode("\n\n", $message['body']);

// Convert any HTML to plain-text.
$message['body'] = MailFormatHelper::htmlToText($message['body']);
// Wrap the mail body for sending.
$message['body'] = MailFormatHelper::wrapMail($message['body']);


Assuming you need a specific template, you could also use template.php. This is the preferred method to keep logic out of the template.

Using template.php, you can do a template_preprocess_field()

This overview does a nice job walking you through altering the date. Also, using php date() function you can alter the field to display as 1 May 2015 using l M Y


restrict user from certain role to change their email

Another way is programmically in your custom module

function mymodule_form_alter(&$form,$form_state,$form_id) {
   global $user;
    if ($form_id == "user_profile_form") {
       if(in_array('your role',$user->roles) && isset($form['account'])) {
           $form['account']['mail']['#disabled']=TRUE;
          }
      }
 }


How to create options in installation profile/ distribution to enable custom content types?

I would think in either case, you should provide the Content types as modules and allow the user to enable them any time after installation. Otherwise, how do you expect them to enable the content types if he chooses to skip them during install?

The way to provide additional options during a profile install is hook_install_tasks(), also check this blog.


Admin's node set to published by default?

Assuming Drupal 6.

Define a hook_form_alter function in your custom module and set the '#default_value' of the status element to TRUE. This will only run if the user has the correct permission. This way, nodes can also be unpublished by unticking the 'Published' checkbox.

function mymodule_form_alter(&$form, &$form_state, $form_id) {
    if (user_access('administer nodes')) { // or other permission
        $form['options']['status']['#default_value'] = TRUE;
    }
}

Now your admin's nodes will be automatically published.

Thanks to andy for his comments.


How to automatically send a push notification when content is created?

Use the Rules integration of the Push Notifications module. Refer to the issue "Add support for Rules module" for more details on this (issue status = needs review ...) and also use the appropriate patch from that issue.

For the "event" part of such rule to be created, just use "After saving content", limited to (= Rules condition) content type "alert".

If you have to still install the Rules module, you'll discover tons of other use cases to also be resolved by the same Rules module (possibly complemented with the Flag module soon ...).


you need to save your signup object in MYMODULE_registration_subtask_next

like:

<?php
    function MYMODULE_registration_subtask_next (&$form_state) {
      MYMODULE_registration_set_page_cache('signup', $form_state['signup_object']);
    }

and - in MYMODULE_registration_subtask_cancel and MYMODULE_registration_subtask_finish you should clean that cache, like MYMODULE_registration_remove_page_cache('signup');


You can use

$ drush cim --partial --source=only-few-configs/

Your help says:

$ drush cim --help
Import config from a config directory.

Examples:
 drush config-import --partial             Import configuration; do not remove missing configuration.

Arguments:
 label                                     A config directory label (i.e. a key in $config_directories array in
                                           settings.php). Defaults to 'sync'

Options:
 --partial                                 Allows for partial config imports from the source directory. Only updates and new
                                           configs will be processed with this flag (missing configs will not be deleted).
 --preview=<list>                          Format for displaying proposed changes. Recognized values: list, diff. Defaults
                                           to list.
 --source                                  An arbitrary directory that holds the configuration files. An alternative to
                                           label argument

Aliases: cim


How to validate an AJAX form which uses CTools?

I have just discovered that I had mistyped mymodule_my_form_validate as my_module_my_form_validate. Your reply has made me look into the function and now it works perfectly. Somehow I thought the method was much more convoluted as involved AJAX. Sorry, this is very embarrasing. In any case, your reply saved me a lot of time.


You can do it through the UI:

Visit /admin/structure/types/manage/CONTENT-TYPE/fields/add-field.
Choose the body field from the Re-use an existing field select.
Click Save and Continue.
Configure the field for that specific content type and save.


Primary and secondary zone's links in drupal 7

You can use the Menu Position module to accomplish this.

After installing:

Visit /admin/structure/menu-position
Click "Add menu position rule"
Select the parent menu item "kandydaci"
Add a page restriction for "kandydaci/*"

This should keep the "kandydaci" menu link active on the correct pages.


if (you = JS) {

use document.getElementById('yourLinkID').click();

} else if (you = JS && you = jQuery){

use $('.content-type #LinkID').click();

} else {

// can't think of anything, either then an option in the UI. I don't have much experience with Drupal comments.

}


How to add a permission : reorder Taxonomy terms

You need to implement hook_form_alter  and remove the Sort alphabetically button based on the role.

Edit: Something like this (tested)

function mymod_form_alter(&$form, &$form_state, $form_id) {
  if (in_array('userrole', $user->roles) && ($form_id == 'taxonomy_overview_terms') {
    unset($form['actions']['reset_alphabetical']);
    drupal_add_css(drupal_get_path('module','mymod').'/css/mymod.css');
  }
}

and in css/mymod.css, do

.handle,.tabledrag-toggle-weight {display:none;}

This hides the Reset to alphabetical button, drag handles, and Show row weights link.


how to get rid of descriptions that are linked to input types?

The Better Formats module is your friend here, you can use it to remove all or part of the format descriptions/options:

  Better formats is a module to add more flexibility to Drupal's core input format system.

  ...

  Set the default format per role.
  Set the default format per content type.
  Control allowed formats per content type.
  Hide format tips.
  Hide more format tips link.
  Hide format selection for nodes, comments, and blocks seperately, forcing the default to be used.

  ...

(emphasis mine)


Drush post-installation - where can I find drushrc.php?

First off, note that alias records go in *.aliases.drushrc.php, whereas general (global) Drush settings go in drushrc.php.  You can find example.aliases.drushrc.php and example.drushrc.php in the Drush "examples" folder.  Drush will look for aliases.drushrc.php and drushrc.php in the ".drush" folder in your home directory.  On most of my systems (Linux), my home directory is /home/ga; on Linux, $HOME and ~ will expand to your home directory.  On my Windows system, my home directory is at 'c:/Users/Greg Anderson'.  To find out exactly where Drush thinks your home directory is, run:

drush ev 'print(drush_server_home());'

Create a .drush folder inside of your home directory, copy example.drushrc.php to .drush/drushrc.php, and example.aliases.drushrc.php to .drush/aliases.drushrc.php, and customize to suit.


By default Drupal form sends values using post method. If you are looking to recieve values in $_GET you will have to define #method attribute of your form to get.

$form['#method'] = 'get';


Why do I have to enter a recipient after selecting users in the VBO send emails operation?

VBO does not provide the "send email" function. It is provided by core actions and it really doesn't know the context that it is being used in. Therefore, you need to insert a token in the "Recipient" field as mentioned in the help text just below the field e.g. user:mail , node:author:mail etc.  I can't tell for sure what the base table  your view is using based on your screenshot but it looks like you can use the token [user:mail].

If you would like to have this info prepopulated you need to use the views send module. It used to support VBO but it now provides it's own UI. It's a pain if you want to combine it with a VBO view as you get double checkboxes etc...

See http://drupal.org/node/575980 for more info


Renaming a content type during migration

As you've figured out, modifying the d6_node-based migration affects how the content of a given node type is migrated, but does not affect how the actual node type itself is migrated - that is done in d6_node_type. To rename the types themselves in migration, while you could modify the source query as you did, it's simpler to modify the .yml to remap values.
In upgrade_d6_node_type.yml,  you can replace

process:
  type: type
  name: name

with

process:
  type:
    plugin: static_map
    bypass: true
    source: type
    map:
      story: post
      book_page: faq
  name:
    plugin: static_map
    bypass: true
    source: name
    map:
      story: post
      'Book Page': Faq


HTTP request status fails, but update checking works manually

This is most likely caused by an old issue, a time-out of 5 seconds which is easily exceeded when checking for updates via poor-man's cron on sites with more than a few modules. See this issue.

Easiest solution is probably to use real cron jobs if possible to avoid this altogether, although there are other suggestions on the linked site. Drupal 7.28 finally increased the limit to 30 seconds, in many cases this might suffice. However it may lead to a page load slow-down, so imho it's better to avoid poor man's cron.


How to add content type as a menu item child without displaying the link in the menu?

If your path aliases are something like, e.g., example.com/news/node_alias, you could use the menu trail by path module. That way, you don't have to add the nodes to the menu to achieve this: the News item remains active on subpaths of /news/*.


Use the strongarm module. When creating the feature select "Strongarm" from the component section then look for the variables that start with ant_{content type name}

Automatic Nodetitle can have up to 3 different variables for every content type.

ant_'{content type name}
ant_pattern_'{content type name}
ant_php_'{content type name}

Export those variables out with your content type and you should be ok.

This works in Drupal 6 & 7.


How to identify disabled fields in form submit handler?

There's not really enough information in the question to provide a definitive answer but what I'd suggest is:

add one or more hidden fields to the form to hold state information
store values in the field(s) using javascript when the state of the form changes with user action
On the server side, use the value(s) from the hidden field(s) to represent the state of the form so you can employ them in validation logic.


I think the entity reference view may help you in this case.

Ref: http://codekarate.com/daily-dose-of-drupal/entity-reference-view-widget


Drupal 7 - HTTP/AJAX/JSON responses at same URL with Accept Header (like D8)

I am not sure whether this is clean or "best practice" but I am currently using something like this:

  // If the request has the header 'Accept: application/json'
  // return the output in JSON format and stop.
  if ($_SERVER['HTTP_ACCEPT'] == 'application/json') {
    drupal_add_http_header('Content-Type', 'application/json; utf-8');
    print json_encode($strings);
    exit;
  }

To see it in the context, here is the whole function:

<?php
/**
 * Menu callback: translations/search.
 *
 * Search strings and translations using various filters.
 *
 * If the request header 'Accept: application/json' is set, then
 * the output will be in JSON, otherwise it will be an HTML page.
 * For example:
 *   curl -k -i -H 'Accept: application/json' \
 *        'https://dev.l10n.org.xx/translations/search?lng=sq&words=space'
 */
function btrClient_search() {
  // Get the search parameters from the GET request.
  $params = btrClient_get_search_params();

  // Get the strings that match the search params.
  $btr = btr_user_is_authenticated() ?
    wsclient_service_load('btr') :
    wsclient_service_load('public_btr');
  $result = $btr->search($params);
  $filter = $result['filter'];
  $pager = $result['pager'];
  $strings = $result['strings'];

  // If the request has the header 'Accept: application/json'
  // return the output in JSON format and stop.
  if ($_SERVER['HTTP_ACCEPT'] == 'application/json') {
    drupal_add_http_header('Content-Type', 'application/json; utf-8');
    print json_encode($strings);
    exit;
  }

  // Add the CSS and JS files.
  drupal_add_css(drupal_get_path('module', 'btrClient') . '/editor/editor.css');
  drupal_add_js(drupal_get_path('module', 'btrClient') . '/editor/jquery.worddiff.js');
  drupal_add_js(drupal_get_path('module', 'btrClient') . '/editor/editor.js');

  // Add RTL style if the current language's direction is RTL.
  $languages = btrClient_get_languages();
  $lng = btrClient_get_translation_lng();
  if ($languages[$lng]['direction'] == LANGUAGE_RTL) {
    drupal_add_css(drupal_get_path('module', 'btrClient') . '/editor-rtl.css');
  }

  // Set the title.
  drupal_set_title(t('Search Translations'));

  // Add the filter form.
  $output = array(
    drupal_get_form('btrClient_filter_form', $filter),
  );

  // Output the strings.
  if (empty($strings)) {
    drupal_set_message(t('No strings found. Try adjusting the filter options.'));
  }
  else {
    pager_default_initialize($pager['number_of_items'], $pager['items_per_page']);
    $output[] = drupal_get_form('btrClient_translate_form', $strings, $lng);
  }

  return $output;
}

(Or check it out here: http://cgit.drupalcode.org/btrclient/tree/includes/search.inc


List of content types

In code you can have the list of all node content types, using the node_type_get_names() method :

foreach (node_type_get_names() as $name => $type) {
     // Do something
}

After, you'll have to sort them if you do not want to use them all.

Template override

It is not a good practice to hack any files of the Drupal installation.

But you can easily override any template files provided by the core or a module, directly in your theme folder.

Have a look at this subject : Drupal 7 Template (Theme Hook) Suggestions.

To have a custom content type template, just take the default "node.tpl.php" file, and copy it in your template theme folder, with a name like "node--[type-machine-name].tpl.php" (you'll have to replace the "_" in the type_name by "-").

Custom node add form

And finally I already saw some website using a override node form page using page manager module. But I cannot say how they've done it.


Why can't anonymous users vote more than once from different browsers/machines?

Seems like that was the issue because of same IP address. But in case of  local network with hundreds of machines, how will that be taken care of, is still a question.
Right resource: Does poll not allow multiple anonymous votes?


Locating a specific position on the page

If you put whatever you want in a div or span with an id, you can then use that id for an anchor.  For example, GO HERE will GO HERE


Change sort order for view when exposed filter text field submitted

If you order your view by relevance first, then date, when there is no text entered all articles will be given the same relevance score, so this will achieve what you are after.


Taking a look at the HTML on your homepage there, I'm seeing you're loading bootstrap in your <head> section, and then calling jQuery from near the footer, way down on line 223 (that'd be the line <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>. That's why I'm at least seeing the error Uncaught Error: Bootstrap requires jQuery.  You want to load jQuery before you load Bootstrap, so ultimately your <head> should include the two lines:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script>

I hope this at least gets you closer.


How to add a custom field which dynamically renders different output according to certain conditions?

Computed Field seems to meet your needs.

  These computed fields are populated with values that you define via PHP code. You may draw on anything available to Drupal, including other fields, the current user, database tables, you name it. (Feeling the power yet? :) ) You can also choose whether to store your computed field values in the database with other content fields, or have them "calculated" on the fly during node views.

Emphasis mine. Either require it in your module and use it, or use it's code, it is open source after all.


How to get the feeds log entry from hook_feeds_after_import

From hook_feeds_after_import($source), I have access to $source->imported, which is the timestamp value in feeds_log.request_time. So I have

$result = db_query('SELECT message, variables FROM {feeds_log} WHERE request_time = :imported',
    array(':imported' => $source->imported) );


drupal commerce separate shipping for different products

You can add a shipping service dedicated for for qwerty key board and similar items and a shipping calculation that checks for a certain product in the cart. Use:
Event: Calculating a shipping rate
Condition: order contain a particular product.
Action:Add a rate for a shipping service to an order and select the shipping service that is dedicated for qwerty key board and similar items.

It may be easier for you to clone one of the existing shipping rate calculation and edit as needed.


This is quite simple and could likely be done in template.php. I would start with the following:

hook_preprocess_html() to hook into the rendering of the <body> tag.
menu_get_object() for loading the current node (in some themes it might already be present in $variables as  $variables['node']).
Grab the data the user entered into the field using field_get_items or something similar.
Pass it to drupal_clean_css_identifier to ensure it's ready to be used as a class.
Add it to the end of the $variables['classes_array'] variable.
Clear the cache to ensure your new hook is picked up.


What is the difference between $variables['elements']['#node'] and $variables['node']?

See the code executed in template_preprocess_node(), the function called before the preprocess functions implemented by modules for a node.

$variables['node'] = $variables['elements']['#node'];

So, yes, $variables['node'] and $variables['elements']['#node'] contain the same value.


Swap out blocks based on domain name extension

If you're still using D7 (there's no D8 port at the time of writing this), you could use Context Domain in conjunction with the Context module, or port the D7 version to D8. There's also option of creating a hook_block_access invocation to control display on a view operation.


Referenced entities show old value when changing properties

You can clear the static entity cache with EntityStorageBase::resetCache:

\Drupal::entityTypeManager()->getStorage('parent_entity')->resetCache([$parentEntity->id()]);


Order won't programmatically mark as completed

I figured this issue out.

I had a Rule that was firing "before a commerce order was saved" that reset the order status but did not show any errors or log any thing. Not sure why that rule wsn't working correctly, but now that I have disabled it, the status is updating successfully.


JSON Menu Link Without Invoking Init Hooks?

hook_init() is invoked before the menu system deals with the request, and in the confines of a normal Drupal bootstrap, no, it's not possible to circumvent that workflow.

It's by design though, if you look at the docs:

  Perform setup tasks for non-cached page requests.

  This hook is run at the beginning of the page request. It is typically used to set up global parameters that are needed later in the request. When this hook is called, the theme and all modules are already loaded in memory.

Emphasis mine.

So for its intended use, hook_init should only set up variables that are required for the current request. Whether that be a request for HTML, JSON, or whatever else.

You have two pretty reasonable options as far as I can tell:

Augment the code you have in hook_init implementations to check whether it should be executed based on parameters from the request (accepted content type, file extension, whatever makes the most sense for you use case).
Move the logic in hook_init to another hook, one that's invoked later in the process (I can't really say which hook that would be without knowing what the code does)


How do I hide the end date part of a Date field but not the time?

To control the display of the date field, you need to do a few things:

Add a date format that will match your requirements, for example, display time only from the date. To do that, go to Configuration > Regional and language > Date and time > tab Formats (/admin/config/regional/date-time/formats). Add a new format, for example, for time only, add g:i a
Add a date type (admin/config/regional/date-time) - for example, call it "Time only" and use that new format from #1 that was added (on the list of formats you should now see the time only value)
In your content type, under Display tab, change the date field to use that new date display "Time only". Optionally, if you want to change how the date is displayed in a View generated page, select that new date display in the date field display options.


What content type select in View related to email?

I think you want to use the content of users table so create a view as below

Add the field user:E-mail field to list users E-mail ID's
You could make use of Views Send Module
Check this Link this might help you understand Views Send Module


Taxonomy view : add token term_name in url

This does what expected.

In the content pane view, Contextual filters : Content: Has taxonomy term ID (with depth), use the filter value type "Term name converted to term ID"

In the custom page, in basics, set the path almost as in the question destinations/[term:name]/foo (I abandoned the [term:parents] part, no way).

And in arguments, choose "argument type:term name".


Cannot call function leftJoin on a SelectQuery object?

$query->leftJoin('drupal5users_roles', 'ur', 'udf.uid = ur.uid');


How to change date format to custom in Views? (drupal 6, views2)

Answer found here. Basically, you create a new date format in admin that is then available sitewide in any date format dropdown.


Using a select form field for the field that selects the groups where a node is posted

I am replying basing on what you wrote in the comment to your question.

Organic Groups shows checkboxes or a select field basing on the number of groups that are listed in the "Audience" form field. If the number of groups is less than 20, the module will use checkboxes; otherwise, it will use a select box.

There is no way to change which form field is used, except using a module that alters the form fields added by Organic Groups. The following code, contained in og.module, is the code that adds the audience form field to the node edit form.

// show multi-select. if less than 20 choices, use checkboxes.
$type = $cnt >= 20 || $is_optgroup ? 'select' : 'checkboxes';
$max_groups = variable_get('og_max_groups_'.$node->type,'');
$description_max_groups = ($max_groups && !user_access('administer nodes')) ? format_plural($max_groups," Limited to !max_groups choice."," Limited to !max_groups choices.", array('!max_groups' => $max_groups)):'';
$form['og_nodeapi']['visible']['og_groups'] = array(
  '#type' => $type,
  '#title' => t('Audience'),
  '#attributes' => array('class' => 'og-audience'),
  '#options' => $type == 'checkboxes' ? array_map('filter_xss', $options) : $options,
  '#required' => $required,
  '#description' =>  format_plural(count($options), 'Show this post in this group.', 'Show this post in these groups.') . $description_max_groups,
  '#default_value' => $groups ? $groups : array(),
  '#required' => $required,
  '#multiple' => TRUE);

It is enough to have a module that executes the following line, and the form field will always use a select box to show the list of groups to which associate a post.

$form['og_nodeapi']['visible']['og_groups']['#type'] = 'select';

The code needs to be executed inside the implementation of hook_form_alter(), or hook_form_FORM_ID_alter().


discount coupon has applied on complete order not specific product in the order

In admin/commerce/discounts/manage/ choose discount type to product discount and add the product(SKU) for which you want to apply discount and save the discount form.

For adding description you can add it in form_alter()

/**
 * Implements hook_form_alter().
 */
function my_module_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'commerce_checkout_form_checkout' ) {
    $form['commerce_coupon']['#description'] = t('Enter the coupon code <strong>***100</strong> to avail discount');
  }
}

Hope it works.


Upgrading multiple modules at once crashes the process

If you have drush try running drush updatedb.

Errors you are getting you should restore backup of your site and update modules one by one.

You can also login phpmyadmin and try to optimize and cleanup mysql if you don't have a copy as it seems your db is crashing and it could be pending database updates. If you don't have drush try going to yoursite.com/update.php to run db updates.

If at all possible use drush for managing your site gives you option to update as well as rollback any updates.


The way Drupal works out of the box, you need to separate your arguments with /. So your URL should be 'item/%'.


Node specific template with custom html header

This applies to Drupal 7...

page.tpl.php

Make a copy of page.tpl.php from your active theme's directory e.g

/sites/all/themes/your_theme/page.tpl.php

If the theme does not have page.tpl.php file then make a copy of Drupal's default version at

/modules/system/page.tpl.php

Rename your copied file in your theme folder with one of the following naming convention. Use this format for a node content type (example uses a custom content type called 'news'):

page--node--news.tpl.php

Or for a specific node use the ID number (example uses node ID of 12):

page--node--12.tpl.php

html.tpl.php

The same applies for html.tpl.php For a specific content type use:

html--node--news.tpl.php

For a specific node

html--node--12.tpl.php

These will take precedence over the generic html.tpl.php or page.tpl.php if the ID or content type matches.


Find a particular menu item within the primary links

Menu block - it provides configurable blocks of menu trees starting with any level of any menu. So if you’re only using your theme’s Main menu links feature, you can add and configure a “Main menu (levels 2+)” block. That block would appear once you were on one of the Main menu’s pages and would show the menu tree for the 2nd level (and deeper) of your Main menu and would expand as you traversed down the tree. You can also limit the depth of the menu’s tree (e.g. “Main menu (levels 2-3)”) and/or expand all the child sub-menus (e.g. “Main menu (expanded levels 2+)”).


How to let simplenews send email instantly without through cron?

Instead of using cron (either manually or waiting for it) you could use:

Drush

drush simplenews-spool-count

  Print the current simplenews mail spool count

drush simplenews-spool-send

  Send the default amount of mails, as defined by the simplenews_throttle variable.

drush simplenews-spool-send 100

  Send 100 mails.

drush simplenews-spool-send 0

  Send all mails.

Alternative cronjob usage

If you can't use drush you can trigger cron manually at /admin/reports/status/run-cron, but this will also run all other cronjobs. As an alternative you could install and use elysia cron or ultimate cron (currently the later looks like to be the more active version). Both modules will allow you to run specific cronjobs manually and separated from others.


In which folder should I install Composer on a shared linux server?

TL;DR My recommendation would be /usr/local/bin

It doesn't really matter as long as the directory is in the PATH of all users, and as long as it is not one of the locations which the OS wants full control over (those would be primarily /usr/bin and /bin).  For most situations, a reasonable location is /usr/local/bin because it should already be in the system's default PATH and it is intended precisely for this purpose -- local installations which are not part of the OS proper.

For Linux, you might want to refer to the LHS entry; this standard codifies usage inherited from the original Unix.

If it's convenient for you, installing in $HOME/bin and then moving to a system-wide location is fine.  In fact, most make install etc facilities expect you to be doing something like this.