Each entity needs a lot of classes for access, forms, storage, listing, viewing,  etc... so you would have to create a module with default classes that would be somehow generic and you would have to handle the discovery of these new entity types since D8 uses annotations. Overall a quite a lot of work.

The same goes for config entities but that would be easier since they do not need that much handling compared to content entities.


Similar Products don´t get grouped on review Page

You have to go to admin/structure/types/manage/YOUR_DISPLAY_TYPE/display, search for the product field / add_to_cart form
and set it to combine like items : enabled

That's it.


You can pass the node as an argument to your form builder and store it there.

$form = drupal_get_form('redirect_button_form', $node);

function redirect_button_form($form, &$form_state, $node) {
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Show on map'),
    );

    return $form;
}

function redirect_button_form_submit($form, &$form_state) {
    $node = $form_state['build_info']['args'][0];

    $geofield = field_get_items('node', $node, 'field_location_exif');
    $location = array(lat => $geofield[0][lat], lon => $geofield[0][lon]);
    $path = '<front>';
    $options = array('query' => $location);
    drupal_goto($path, $options);
}

drupal_get_form can take additional arguments besides $form_id.

  Any additional arguments are passed on to the functions called by
  drupal_get_form(), including the unique form constructor function. For
  example, the node_edit form requires that a node object is passed in
  here when it is called.

Also, to do a form redirect you can use:

$form_state['redirect'] = path...

Instead of drupal_goto which should not be used here.

  When $form_state['redirect'] is an array it should be populated with
  arguments appropriate for drupal_goto() - which is to say, the second
  element in the array can itself be an array holding all the properties
  expected by url()'s $options argument, including fragment, query,
  absolute, etc.


Finding out if panelizer displays are in use

This info is not saved in the theme registry, and it's not really available per page or per node. However, it is stored per configured Panels display. Many don't have a title but since I'm using Panelizer, they do have a Panels display ID. Here's a query that returns those:

select did, title from panels_display where layout = 'mytemplate';

Entity IDs correspond to DIDs in the panelizer_entity table. Once you have queried for the DID you can query for the entity ID using the DID, like so:

select entity_id from panelizer_entity where did = 1234;

Where you replace '1234' with the DID you got from the previous query.

I have to do that second one for each DID that the first one returns in order to find all entities using mytemplate.


Why do I have two menu bars in my drupal instance?

You may have 2 toolbars enabled. One is the Drupal 7 default toolbar which in my experience most disable in favor of the the admin_menu.

drush dis toolbar -y

or

drush dis admin_menu -y

Or under the modules config page.


This is a classic GMap problem. It usually occurs when the map doesn't know it's dimensions initially. For example: when the dimensions are set in a stylesheet (.gmap {width: x; height: y;}).

You could try setting them inline on the wrapper div (<div class="gmap" style="width: x; height: y;">) or trigger a resize after the page has loaded, as explained here: How do I resize a Google Map with JavaScript after it has loaded?

If you are using the gmap or geolocation module, you can set the dimensions in the widget properties.


Is it possible to stop a webform form during submission?

First is I'm not sure if it's best practice to do validations in the submit handler because as you've said, you need to validate first. So I can only answer your second question.
To make your validation run after every validation present for that form, you need to add it in the end of the #validate attribute. Example is like:
$form['submit']['#validate'][] = 'your_last_needed_validation_func';
To check if there are validation errors before your validation function, you can use the form_get_errors function.


It's called Link to Content.

Path field could also be used in older 8 versions (you could construct the full URL with replacement patterns while overwriting the field output).

But the Path field is deprecated in 8.5 and you can use Link to Content instead, with Output the URL as text option.

Read more here, you can also see screenshots: Path field deprecation and backwards compatibility for existing views.

There is still work being done related to this, and if you get the wrong link in 8.5.1 there is a patch that seems to help: RSS view with fields give wrong URL from path field.


Recover content from "story" after content type was deleted accidentally

I had this same situation - deleted nodes, only titles left.

With D7, I used phpmyadmin to go into the database

open the field_data_body table

Sort this by type and locate the type you deleted - there should be a "1" in the deleted column.  I did two as a test and then cleared caches and checked the node on the site - the content was back.

Then I ran this sql query, copied from the changes I did:
UPDATE  databasename.field_data_body SET  deleted =  '0' WHERE  field_data_body.entity_type =  'content type name' AND  field_data_body.deleted =1

Everything was back. Yay!

change database name to your database and content type name to the content type you deleted.

And be sure to backup your DB before doing this in case of disasters. Like deleting a node type.


I found the answer in this comment. For Drupal to find the theme's template overrides, I had to change my theme keys to underscore versions of my dashed template names.

function mymodule_theme($existing, $type, $theme, $path)
{
  return array(

    'my_theme_key' => array(
      'template' => 'my-theme-key',
      'variables' => array(
        ...
      ),
    )
  );
}


Add the user picture before the username in user listings?

theme_user_picture is not a Drupal 7 function, whereas in the example you provide you are using Drupal 7's theme_username function code. Moreover, even in Drupal 6, theme_user_picture returns nothing because in that version of Drupal it's merely a placeholder and the actual themeing of the user entry is handled via the corresponding template file user-picture.tpl.php. This is possibly the reason your theme call returns nothing. Please refer to api.drupal.org to find the correct implementation for your Drupal version.

So, assuming that you are on Drupal 7, note that $variables['account'] is not a fully populated user object and does not contain any reference to the user picture. You need to actually load the user object and give the picture some themeing in order to show it in your listing. Your code could be something like this:

function MY-THEME_username($variables) {
  if (isset($variables['link_path'])) {
    // We have a link path, so we should generate a link using l().
    // Additional classes may be added as array elements like
    // $variables['link_options']['attributes']['class'][] = 'myclass';

    // I ADDED THIS LINE

    //$output = theme('user_picture', array('account' => $variables['account']));
    $user = user_load($variables['account']->uid);
    if (isset($user->picture->uri)) {
      $output = theme('image_style', array('path' => $user->picture->uri,'style_name' => 'thumbnail'));
    }
    // ENDS

    $output .= l($variables['name'] . $variables['extra'], $variables['link_path'], $variables['link_options']);
  }
  else {
    // Modules may have added important attributes so they must be included
    // in the output. Additional classes may be added as array elements like
    // $variables['attributes_array']['class'][] = 'myclass';
    $output = '<span' . drupal_attributes($variables['attributes_array']) . '>' . $variables['name'] . $variables['extra'] . '</span>';
  }
  return $output;
}


How to replace the date field selects with one text field in Drupal 7 web forms

Since it seems like the webfrom module doesn't support this functionality yet, if found that the easiest way to do this, was to use a textfield and use form_alter to add the datepicker plugin.

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

  if($form_id != 'webform_client_form_2') return;

  // Alter textfield for date to integrate popup calendar
  $form["submitted"]["expected_move_date"] = array(
    '#type' => 'item',
    'finished_after' => array(
      '#type' => 'textfield',
      '#attributes' => array('class' => array('datepicker')),
      '#required' => TRUE,
    )
  );

  $form['#after_build'] = array('custom_form_uidatepicker');

}

function custom_form_uidatepicker($form, $form_state) {
  drupal_add_library('system', 'ui.datepicker');
  drupal_add_js("(function ($) { $('.datepicker').datepicker({
      showOn: 'both',
      buttonImage: 'sites/all/modules/custom/custom_form/images/calendar.png',
      buttonImageOnly: true,
      dateFormat: 'dd/mm/yy',
    });
    $('.datepicker').datepicker( 'option', 'minDate', 'd' );
    })(jQuery);", array('type' => 'inline', 'scope' => 'footer', 'weight' => 5));

    return $form;
}


You should be fine with the upgrade.  Back up your DB, of course.  If you are uploading the module instead of installing through the UI, then yes, you need to run /update.php.


How to properly render a Calendar view title in a month display?

There is a bug in the date module that causes this issue. I'm not sure if the latest version of the module resolves it or not. If it doesn't, then the workaround in #20 in the thread at https://www.drupal.org/node/2294973 will fix the issue.


Error in Views override template "Notice: Undefined offset: 1 in include()"

You need to use isset() to avoid such notices:

<?php if (isset($fields["title"])) { print ($fields["title"]->content); } ?>


Usually you can file an issue for webmaster to delete the nodes. But in this case they usually don't delete release node and only option is to create new release.

check: https://www.drupal.org/node/128614


How to add fields (variables) to users to be used in combination with data about events?

How about using the Flag module for this? Excerpt from its project page:

Flag is a flexible flagging system that is completely customizable by the administrator. Using this module, the site administrator can provide any number of flags for nodes, comments, users, and any other type of entity. Some possibilities include bookmarks, marking important, friends, or flag as offensive. With extensive views integration, you can create custom lists of popular content or keep tabs on important content.
Flags may be per-user, meaning that each user can mark an item individually, or global, meaning that the item is either marked or it is not marked, and any user who changes that changes it for everyone.
In this way, additional flags (similar to published and sticky) can be put on nodes, or other items, and dealt with by the system however the administration likes.

Possibly in combination with some of the Flag related modules also, such as (partial list):

Views, to create lists of flagged content, users, etc, such as in the video about Creating global flags and listing flagged content in Views.
Rules, to trigger rules for anything that is flagged, such as in the video about Triggering rules with Flag, or to set flags with the Rules module, such as in the video about Setting flags with Rules.
Flag Lists, to allow users to create custom lists.
Flag Weights, to add weights to Flags (to be used for sorting).
DraggableViews, to make Views draggable (so that they can be rearranged by Drag'n'Drop.).
Flag Friend, a pre-built flag for marking other users as friends (using the Flag module).
Flag Abuse, a pre-built flag for marking offensive content, with some extra administrative features.
Flag, Hide & Mute, for users to hide individual nodes, such as site-wide announcements or advertisements, and/or to suppress all posts by users they do not want to see.
Flag Files, to flag media files.
Flag Service, to allow Flag to be accessed via a web services interface through the Services module.
DLike, provides a Facebook like "Like" functionality using the Flag and Lightbox2 module.
Conditional Flags, provides an extra API to Flag module, for custom conditions between flags.
Organic Groups Flag Integration, extends the flag module with organic groups support allowing the administrators of each group to override the global flag settings for their group.
Context Flag, allows the use of Flags as conditional triggers for use with the Context module.

Refer to its community documentation for way more details (if you like to read), and/or various screencasts about the Flag module (if you like to watch).


How to create a slideshow of different views?

Your current approach will not work because View Fields View will insert the same view for each and every row/slide.

Here is what you need to do. For example: You want 4 slides.
Create a Slideshow View of Articles or something that has 4 or more content. Then set the view results to 4, so it only shows 4.
Now add a Global: View Result Counter and exclude from display.

Add a Global: Custom Text and for text put:
[counter]

In your view preview you should see numbers
1
2
3
4

Now we are going to override these (the custom text), and replace them with views in template.php (located in /sites/all/themes/yourtheme/) add the following code:
function yourtheme_preprocess_views_view_fields($vars){

  if ($vars['view']->name == "view_slideshow_name" && $vars['fields']['nothing']->content == 1) {
    $vars['fields']['nothing']->content = views_embed_view('view_name', 'block_1');
  }
  else if ($vars['view']->name == "view_slideshow_name" && $vars['fields']['nothing']->content == 2) {
    $vars['fields']['nothing']->content = views_embed_view('view_name', 'block_2');
  }
  else if ($vars['view']->name == "view_slideshow_name" && $vars['fields']['nothing']->content == 3) {
    $vars['fields']['nothing']->content = views_embed_view('view_name', 'block_3');
  }
  else if ($vars['view']->name == "view_slideshow_name" && $vars['fields']['nothing']->content == 4) {
    $vars['fields']['nothing']->content = views_embed_view('view_name', 'block_4');
  }
}

replace yourtheme with the actual name of your theme
replace view_slideshow_name with the name of your view slideshow.
replace view_name with the name of the view that you want to show
replace block_1 with the machine name of your view

Lastly, in Drupal, clear/flush your Cache to see the changes.

Note: The changes will show up when you see the slideshow in your page and not in the view preview.

Forgot to mention that you need to uncheck provide/add wrappers and classes.

Also, for both of your fields, do as below

It seems odd that you have to list the block name of the view you want to insert but not the block name of the view you are overriding.

That's because in my case I did not plan to add more blocks or pages to my view. When you do not specify, it affects all pages or blocks that are from your view.
But if you want to be specific here is how:
function bartik_preprocess_views_view_fields($vars){

  if ($vars['view']->name == "rotator" && $view->current_display == 'block_1' && $vars['fields']['nothing']->content == 1) {

    $vars['fields']['nothing']->content = views_embed_view('checking_home', 'block_1');
    }

  else if ($vars['view']->name == "rotator" && $view->current_display == 'block_1' && $vars['fields']['nothing']->content == 2) {

    $vars['fields']['nothing']->content = views_embed_view('home_outstanding_issues', 'block');
    }

}


Create a view of the 'Recent Log Messages'

In Drupal 8, you can simply create a view of "Log entries". Just make sure you add a "Type" filter and select "user" as the type.

Then under "Page settings", change the "Access: Permission" to "Role > Administrator". However, if you don't want this user to view other log messages, perhaps that user shouldn't be an administrator? I recommend creating a new role for that type of user.

In Drupal 7, the Views module doesn't allow you to make a view of log entries out-of-the-box, however if you install the Views Watchdog module, you can do it just like the Drupal 8 method described above.


Get entities that share the Entity Reference field

I finally found a way to do it, here are the steps:

Add a relationship: Entity Reference: Referenced Entity, select the right field to match, select "Require this relationship"
Add a relationship: Entity Reference: Referencing Entity, selection the just add relationship in step 2 and check "Require this relationship".
Add a contextual filter: Content:nid, provide default value: Content ID from URL
Add a contextual filter: Content:nid, select the relationship "Content referencing...", provide default value: Content ID from URL, then in the More fieldset, check exclude.
Add a field "Title" and select the relationship "Content Referencing..."

I will close this question, feel free to comment or propose other solutions.

Thanks.


How to hide homepage link from menu once logged in?

Try with this code

function THEME_menu_item_link($link) {
  global $user;
  if (empty($link['localized_options'])) {
    $link['localized_options'] = array();
  }
  if ( ($link['href'] == '<front>') && ($user->uid == 0) ){
       return '';
  } else {
      return l($link['title'], $link['href'], $link['localized_options']);
  }
}


How to programmatically create an exposed filter?

Can you please try with hook_views_default_views_alter function. This function should be defined in MODULE_NAME/views/MODULE_NAME.views.inc file. And don't forget to include this file on .info file as files[] = views/MODULE_NAME.views.inc.

 function MODULE_NAME_views_default_views_alter(&$views) {
        if (array_key_exists('MY_VIEW_NAME', $views)) {
          $options = array(
          0 => 'Blocked',
          1 => 'Active',
          );
          $display = $views['MY_VIEW_NAME']->display['MY_VIEW_PAGE'];
          $display->display_options['filters']['field_status']['id'] = 'field_status';
          $display->display_options['filters']['field_status']['table'] = 'field_data_field_status';
          $display->display_options['filters']['field_status']['field'] = 'field_status';
          $display->display_options['filters']['field_status']['value'] = $options;
          $display->display_options['filters']['field_status']['exposed'] = TRUE;
          $display->display_options['filters']['field_status']['expose']['operator_id'] = 'field_status_value';
          $display->display_options['filters']['field_status']['expose']['label'] = 'Status';
          $display->display_options['filters']['field_status']['expose']['operator'] = 'field_status_value';
          $display->display_options['filters']['field_status']['expose']['identifier'] = 'field_status';
          $views['MY_VIEW_NAME']->display['MY_VIEW_PAGE'] = $display;
          }
    }


Alias URL not changing when switching language in a View

An alternative would be to use i18n_page_views module - it is a display plugin that installs an item labeled i18n page into the +Add (display) button menu. It's like a page display extended by fields for entering a path for each enabled language.

While it does not offer any tool to convert existing displays into i18_page type, it's quite easy to do that manually - just export your existing view(s), change the type of the display in a notepad and re-import w/override.

Regretfully, the module does not offer UI for creating translated menu items - this also has to be done manually.

At any rate, it's advisable to bind all translation paths (created manually as jdu suggested, or created automatically) into a translation path set (admin/config/regional/i18n_translation/path/add). I found that without it the i18n_get_path_translations function worked whimsically.


Paypal express checkout doesn't add taxes

It seems that Ubercart doesn't set the billing address properly after making the API call. See uc_paypal.pages.inc around line 240.

The original snippet looked like this:

$order->delivery_street1 = check_plain($nvp_response['SHIPTOSTREET']);
$order->delivery_street2 = isset($nvp_response['SHIPTOSTREET2']) ? check_plain($nvp_response['SHIPTOSTREET2']) : '';
$order->delivery_city = check_plain($nvp_response['SHIPTOCITY']);
$order->delivery_zone = !empty($zone_id) ? $zone_id : 0;
$order->delivery_postal_code = check_plain($nvp_response['SHIPTOZIP']);
$order->delivery_country = !empty($country_id) ? $country_id : 840;

$order->billing_first_name = check_plain($nvp_response['FIRSTNAME']);
$order->billing_last_name = check_plain($nvp_response['LASTNAME']);
$order->billing_street1 = check_plain($nvp_response['EMAIL']);

You can see that the billing address is never added. I would assume that most people who experience this issue have the tax calculating by the user's state. Since there's no state, no tax is added. Since the billing address and delivery address will be the same on Paypal, simply add the delivery info into the billing info like so:

$order->billing_street1 = check_plain($nvp_response['SHIPTOSTREET']);
$order->billing_street2 = isset($nvp_response['SHIPTOSTREET2']) ? check_plain($nvp_response['SHIPTOSTREET2']) : '';
$order->billing_city = check_plain($nvp_response['SHIPTOCITY']);
$order->billing_zone = !empty($zone_id) ? $zone_id : 0;
$order->billing_postal_code = check_plain($nvp_response['SHIPTOZIP']);
$order->billing_country = !empty($country_id) ? $country_id : 840;

Hacking core/contrib modules like this sucks and I don't recommend it, but sometimes, you gotta do what you gotta do.

Enjoy your taxes!


#states attributes cannot use to invoke AJAX. See drupal_process_states

With your question, i think the solution is write an javascript file and #attached it to the form you need.

You can bind a click event to .vertical-tab-button element (better) or orverride Drupal.verticalTab.prototype.focus function (not recommend).


Automtically creating new redirects and alias on node_save

Pathauto should automatically create a new alias with the updates (unless you have it turned off on the node). pathauto.module lines 519-522:

// Skip processing if the user has disabled pathauto for the node.
if (isset($node->path['pathauto']) && empty($node->path['pathauto'])) {
  return;
}

The Global Redirect module can then provide 301 redirects to the new URL alias.


How to set header and footer for any drupal_mail messsage?

Take a look at hook_mail.  All emails from the system "should" go through that.  You can alter the $message['body'] to add your header and footer.  If you only want to do this for certain emails, you can use an IF condition on the $key.

Edit: I think I pointed you to the wrong hook.  You probably want to use hook_mail_alter to change every email that Drupal sends.


entity eck create new property type or/and behaviour

You can follow the documentation of eck modules. https://www.drupal.org/node/1370980
The last version introduces the concept of behaviour and you can create your own.

Install the module date_popup
Implement the hook hook_ctools_plugin_directory()
Create your plugin
In the default_widget callback return a renderable array where the #type is date_popup


How to use hook_theme and hook_block_view correctly

That code would be perfectly fine, if you define a theme function and use that theme function. In your case, the code is defining the youtube_pull_listing theme function, but using the popular_analytics theme function.

As for an example of hook_block_view() implementation that uses a theme function, see user_block_view(), which contains the following code.

  if (user_access('access content')) {
    // Retrieve a list of new users who have subsequently accessed the site successfully.
    $items = db_query_range('SELECT uid, name FROM {users} WHERE status <> 0 AND access <> 0 ORDER BY created DESC', 0, variable_get('user_block_whois_new_count', 5))->fetchAll();
    $output = theme('user_list', array('users' => $items));

    $block['subject'] = t('Who\'s new');
    $block['content'] = $output;
  }
  return $block;

The fact the theme function is using a template file doesn't make any difference for how the function is called. The only difference is that the variables declared in hook_theme() are the variables the template file will be able to access.

Keep in mind that, in Drupal 7, it is now preferable to return an array in $block['content'], in the same way blog_block_view() does.

  if (user_access('access content')) {
    $result = db_select('node', 'n')
      ->fields('n', array('nid', 'title', 'created'))
      ->condition('type', 'blog')
      ->condition('status', 1)
      ->orderBy('created', 'DESC')
      ->range(0, variable_get('blog_block_count', 10))
      ->addTag('node_access')
      ->execute();

    if ($node_title_list = node_title_list($result)) {
      $block['subject'] = t('Recent blog posts');
      $block['content']['blog_list'] = $node_title_list;
      $block['content']['blog_more'] = array(
        '#theme' => 'more_link',
        '#url' => 'blog',
        '#title' => t('Read the latest blog entries.'),
      );

      return $block;
    }
  }

The reasons why using theme() is bad are given in theme() renamed to _theme() and should not be called directly, even if that change record refers to Drupal 8.

It circumvents caching
It circumvents defaults of types defined in hook_element_info(), including attached assets
It circumvents the pre_render and post_render stages
It circumvents JavaScript states information


Does drush have built-in variables or macros?

If you source the file examples/example.bashrc from your ~/.bashrc file, then you can do useful things like cd %root or cd @site:%root.  Without sourcing that file, you can use cd $(drush dd %root).  If you want to go to a module or theme directory, cd $(drush dd %devel) also works.  Using the %path aliases without qualifying them with a @site alias does, of course, require that your cwd be inside some Drupal site (or $options['root'] must be set in some drushrc.php file).


Is it possible to group taxonomy list items by content type?

I assume you know how to set up the view and have difficulty only with applying the view to the specific taxonomy and letting other taxonomies render by default.

Create a custom module and put this is the main module file:

function MODULE_menu_alter(&$items){
  // change taxonomy view path for certain vocabularies
  $items['taxonomy/term/%taxonomy_term']['page arguments'][] = $items['taxonomy/term/%taxonomy_term']['page callback'];
  $items['taxonomy/term/%taxonomy_term']['page callback'] = 'custom_taxonomy_term_callback';
}

function custom_taxonomy_term_callback($term, $callback) {
  if ($term->vocabulary_machine_name == "SOME_TAXONOMY") {
    $view = views_get_view('CUSTOM_TERM_VIEW');
    $view->set_display('default');
    $view->set_arguments(array($term->tid));
    $view->pre_execute();
    $view->execute();
    return $view->render();
  }
  else {
    module_load_include('inc', 'taxonomy', 'taxonomy.pages');
    return $callback($term);
  }
}

This is what the code does:

It alters the path taxonomy is called on, then checks if the path is on your taxonomy that you want to special render. If it is it loads and renders the view for that taxonomy, and if not it passes the call back to the default taxonomy callback.

You need to alter the code to suit your taxonomy machine name and view name. And remember to clear the cache.

For your view you can create just the master view (ie no page with path) that accepts the tid as contextual filter. This view is custom rendered and therefore does not need to be on any path.


Is there a function to get the system path for the current language?

The internal path is same for all languages,though you can set different alias for different languages. From your question it seems that you want to get the path with language prefix not the alias, if so then I don't think there is any function that will return the path with language prefix.

Since you can get the language using $language->language you can write a custom function as follows.

function custom_lookup_path($action, $path = '', $path_language = NULL){
   global $language;
   if(empty($path_language)){
      $path_language=$language->language;
   }
   if(!empty($language->prefix)){
      $path = $language->prefix.'/'.drupal_lookup_path($action, $path , $path_language);
   }
   else{
      $path = drupal_lookup_path($action, $path , $path_language);
   }
   return $path
}


Drupal 8, entityQuery with operand "AND" for a multiple values field

I'm not sure if you can do that using an entity query.

You could specify the delta explicitly:

\Drupal::entityQuery('node')
  ->condition('field_tags.0.target_id', 1)
  ->condition('field_tags.1.target_id', 2)
  ->execute();

But of course that would only match if the ids are used in those specific deltas.

You probably need to use raw SQL for this, see https://stackoverflow.com/questions/3918351/sql-query-ensure-a-row-exists-for-each-value-in for the basic approach on how to do this.


Drupal 7 Views: Display a Taxonomy term as its Term-ID number for a node

Here are few things you need.

In relationships, add Content: Taxonomy terms on node.
In Filter Criteria(I think this is the one you are missing), add Content: has taxonomy term and check the "is not empty(NOT NULL)".
In Fields: Add Taxonomy term: Term ID

PS: in step 2, you may pick other operator based on what you need.


drupal 7 template suggestions based on path alias

Found solution here:
http://cheekymonkeymedia.ca/blog/gene-bernier/how-create-page-tpl-suggestions-based-path-alias-drupal-7

Here is what I used to fix the dash in titles error. I also added no node-content-type solution:

function mytheme_preprocess_page(&$variables) {
  // Get the alias for the page being viewed
  $alias = drupal_get_path_alias($_GET['q']);
  if ($alias != $_GET['q']) {
    $template_filename = 'page';
    //Break it down for each piece of the alias path
    foreach (explode('/', $alias) as $path_part) {
      // Added the str_replace becayse path parts with - were not being picked up properly by the theme_hook_suggestions
      $template_filename = $template_filename . '__' . str_replace("-", "_", $path_part);
      $variables['theme_hook_suggestions'][] = $template_filename;
    }
  }

  if (isset($variables['node'])) {
    // If the node type is "blog_madness" the template suggestion will be "page--blog-madness.tpl.php".
    $variables['theme_hook_suggestions'][] = 'page__'. $variables['node']->type;
  }
}


Problem installing Devel module onto site

Download this file http://curl.haxx.se/ca/cacert.pem save it on the desktop.

Then Copy( or move) into the  C:\Program Files (x86)\DevDesktop\common\cert\


How can I make Drupal use token for summary instead of breaking at ?

Assuming you're using Drupal 7, you can change how the content type is displayed in 'manage display'. You need to make sure you are using the correct view mode (probably teaser) which can be selected in the top left. You can then set the format to 'Summary or trimmed' and adjust the trim length by clicking the cog button.


How do I show user attributes on articles?

If you take a look at node.tpl.php, you'll notice there's already a variable for this type of data: $submitted. You could replace that variable with your own data, but to do it the Drupal way, what you want to do is modify the value of $submitted using a preprocess function.

In your theme, create a template.php file (if you don't have one already). In it, add the following function (replacing example with the short name of your theme):

function example_preprocess_node(&$variables) {
  // Linkify the URL
  $twitter_url = l('http://twitter.com/someusername', 'http://twitter.com/someusername');

  // This is the same thing as saying
  // $variables['submitted'] = $variables['submitted'] . ' ' . $twitter_url;
  $variables['submitted'] .= ' ' . $twitter_url;
}

Clear the cache (Configuration → Performance → Clear cache), and check your node pages again: you should see the Twitter URL appended to submitted line.

But this is of course, static: to load the user's Twitter URL, you'll need to load the field data:

function example_preprocess_node(&$variables) {
  // Even though there's a user object in $variables['user'], we need to
  // load a new copy because the preloaded one doesn't have have field data
  $user = user_load($variables['uid']);

  // Retrieve the data and its value for the Twitter URL field
  // Replace field_twitter_url with the short name of the field
  // found at admin/config/people/accounts/fields
  $items = field_get_items('user', $user, 'field_twitter_url');
  $field = field_view_value('user', $user, 'field_twitter_url', $items[0]);

  // Get the rendered output of the field for use in the submitted line
  $twitter_url = drupal_render($field));

  // If you wanted to get more fields, repeat the last three lines, replacing
  // field_twitter_url with the names of the other fields.

  // Linkify the URL and append it to the $submitted variable
  $variables['submitted'] .= ' ' . l($twitter_url, $twitter_url);
}

The Field API isn't the most intuitive or straightforward API in the world, but here's what's going on:

Load the user object, which contains the information about the fields attached to it.
Load the specific data associated with the field_twitter_url using field_get_items().
Get the render array for the specific field you want to display using field_view_value().
Get the final rendered output using drupal_render().

Now, if you wanted to have the Twitter URL separate (so you can move it to where ever you want in the template), just create your own variable:

function example_preprocess_node(&$variables) {
   // ...
   // Do all the stuff from the previous sample function, except
   // setting $variables['submitted']
   // ...

   $variables['twitter_url'] = $twitter_url;
}

Now, you can add $twitter_url to anywhere in node.tpl.php. If your theme doesn't already have its own node.tpl.php, navigate to the modules/node folder, copy the node.tpl.php that's there to your theme folder, and clear the cache.


Notice: Undefined index: tid in taxonomy_field_formatter_prepare_view() (line 1669 of

Your content have an taxonomy_term reference field which have invaild data, maybe it break.

You can install devel module and use error display with debug_backtrace and you will see where it comming.


How to manage programmatically the access of a content node type?

We need to set permission for doing this. Permission can be done specific to a Role not to a User. Please use below codes. Please update your role name instead of 'New Role' and machine name of your content_type instead of 'your_content_type'.

$role_name = "New Role";
$role_permissions = array(
  'create your_content_type content',
  );

$role = user_role_load_by_name($role_name);
user_role_grant_permissions($role->rid, $role_permissions);


Check if user can edit node with certain ID

You can use node_access to do this:

$node = node_load(123);
$account = user_load(456);

if (node_access("update", $node, $account) === TRUE) {
  do_something_awesome();
}

If you look at the source for node_access, you will see that the $node argument can also be a $nid.  This is how the path for the edit pages get checked (see the 'node/%node/edit' entry in node_menu).


rendered entity usage in "add node" form for an entity ref field

What you configure in Manage display has nothing to do with what is shown in the form. That's not how it works.

You can do this using a view. In field settings, configure it to use a view show possible values and then configure that view to show the values you want to see.


alter Suggestion box for apache solr autosearch

I was not able to find any hooks for the same. The alternate solution which I got is to implement hook_menu alter.

As apachesolr uses hook_menu() I altered the menu callback function.


D7: Add a class to a list item when the created date is less than 14 days old

You can do that using a preprocessor function for the view you created. You need to preprocess the view and check the creation date of nodes for each row and give them a relating class.

Given that your view's machine name is recent_news_widget, your diplay format is HTML lists, and your theme name is genesis. You need to use template_preprocess_views_view_list() function in /sites/all/themes/genesis/template.php file

genesis_preprocess_views_view_list(&$variables) {
  $view = $variables['view'];
  if ($view->name == 'recent_news_widget') {
    // dpm($view);
    // Here comes your logic
  }
}

In the above code you see 2 lines commented out. First one is a helpful function for developers to print out the given array/object/string etc in a browsable style. This function comes with Devel module, which I would strongly recommend to install it.

After browsing the variables, you will probably find where the results are listed and where the classes for the rows are assigned. You need to browse the variables until you find all values you need to build your logic to assign new classes, for example the 'created date' of the node. After you have all the variables you need, you can loop through the results, check the creation date and add a relating class.

UPDATE:
The preprocess functions for other display types than HTML List:

Grid: template_preprocess_views_view_grid()
Table: template_preprocess_views_view_table()
Unformatted: template_preprocess_views_view_unformatted()

UPDATE #2 (According the discussion on chat and your updates on the question):
I find the code in your Update #3 was in the right direction, but with a few mistakes. The corrected version should look like that:

function genesis_preprocess_views_view_list(&$variables) {
  $view = $variables['view'];
  if ($view->name == 'recent_news_widget') {
    foreach ($view->result as $key => $result) {
      if (time() - strtotime($result->node_created_day) < 14 * 24 * 60 * 60) {
        $variables['classes'][$key][] = 'new';
        $variables['classes_array'][$key] = isset($variables['classes'][$key]) ? implode(' ', $variables['classes'][$key]) : '';
      }
    }
  }
}

The 2 mistakes in your code were:

You passed the argument as &$variables to the function, but used $vars to assign classes, $vars is not defined in the function so the class was not added.
You wanted to use the key number of the result but in foreach you loop only through the values, and $result variable is an object. In the corrected version of your code above, I used $key => $result by defining the loop so that I can access the key number as well.

UPDATE #3 I added a new line that flattens the classes into classes_array.


View of Taxonomy with titles above the terms

You have an unformatted list view of node teasers. Just click Format settings on view edit page, and turn on Force using fields. After that this result will be shown as teaser, but you can add fields.

Add your taxonomy term field to the Fields, and you can use it in Format settings Grouping field Nr.1. If the teaser doesn't contains this field, you have to add a relationship to the proper taxonomy term too.


You are facing the limitations og HTML itself. All of the form fields has to be in the same form to make it work. If you split them up in two forms it will not work as the browser will see it as two different forms.

A workaround would be to render the entire form both places, hide unwanted fields with CSS and use JavaScript to sync values between the forms.


The menu structure has changed a bit from Drupal 6 to Drupal 7.

Site building is now called structure, though modules is moved from it into it own top level menu item.
Content management has been split up a bit and have items in content and structure.
For administer you probably want the Configuration item.

Anyways try clicking around and I'm sure you'll find what you need.


How to find which pages use a certain view?

You can use the Devel module and enable the Web Profiler module that comes with Devel. This module will tell you which view is being used when you visit a page.

Alternatively, you could try the answers from here, Where are my views being used?


Changes to Input Formats not saving: Default instance field is required

I was getting this error because of qTip filter (https://www.drupal.org/project/qtip) which had a required field that wasn't visible on the text format page because qTip filter wasn't selected. The required field was still part of the form (visible in source) even though it was invisible in the rendered page.


How to use Views PHP to rewrite results of a field?

Above the "Output Code" section you should check the $data variable in the "Value" field.

Usually I just dpm($data) to find the field I need.  Then you can save it to the $static['myvalue'] variable for use in the "Output Code" field.

It is confusing but for some reason if you try just the $row->xxx variables in the "Output Code" section they are empty or set to the node-id.


drupal_set_title not changing the navigation bar title

Sounds like you're setting the title too late in the theme building process for this to work, possibly using at the node layer which only affects the node title not the page title. What you want to make sure to do is use a preprocess_page function to set the title so this is in the header as well:

function mytheme_preprocess_page(&$vars){
    if (isset($vars['node'])) {
        drupal_set_title('YOUR TITLE');
    }
}

Alternatively, you can install the Page Title which gives you granular control over all of your page titles and is often recommended for SEO.


Imagecache_external: Thumbnails of external URLs aren't accessible

I think it is a bug in imagecache external when there are special characters in the URL. Try to file an issue on the module queue on drupal.org to see.

About the "cryptic" end, it's http://drupal.org/node/1934498.


db_query() not compatible with IN operator?

You can use placeholders in IN conditions, but you need to set them up correctly first.  Using the example in your first link, this should work:

$replacement_values = array();
foreach(array_values($your_values) as $i => $val) {
  $replacement_values['@val' . $i] = $val;
}
// Should look something like:
// $replacement_values = array(
//   '@val1' => 'your first value',
//   '@val2' => 'your second value',
// );

$placeholders = array_keys($replacement_values);
$placeholders = implode(', ', $placeholders);
// Should look something like:
// $placeholders = '@val1, @val2';

$res = db_query('SELECT field FROM {table} WHERE cond_field in(' . $placeholders . ')', $replacement_values);

n.b. I haven't tested this so it might need some tweaking.

That said, I'd urge you to look into dynamic queries.  They're not that hard to get your head around and if you wan't to right modules that might ever be used on another Drupal site that uses an alternative database to MySQL then they are a must.


I would group them in three, four groups, but there is no technical/internal difference between them. All are just functions that are called because of naming conventions.

Info hooks. Hooks that provide information about something, typical examples are hook_entity_info(), hook_field_info(), hook_hook_info() but also hook_permission(), hook_menu(), hook_theme(), etc. Many of these have a _info suffix but don't necessarly need to. These hooks can be called any time and the returned information is often cached (static cache or persistent cache) or stored to specific tables (e.g. hook_menu()).
Reactive/Action hooks. I just invented that name, but these are hooks which are called when something specific happenend like hook_init(), hook_node_save(), hook_user_save(), hook_node_view() and so on.
Alter hooks. Hooks that can be used to change something provided by other modules, exist for almost any info hooks (e.g. hook_menu_alter() or hook_entity_info_alter()) and also some action hooks (e.g. hook_node_view_alter()).

There is also a forth group but those are actually not really hooks and they are one of the main reasons for the typical confusion about hooks. They are often referred to as "Callbacks". This are "Hooks" which are only called for a single module, which owns something. Typical examples include node type callbacks (hook_submit, hook_view, hook_form, ...), many field hooks (e.g. hook_field_load()) but also hook_block_view(). There are plans to remove these and replace with something else (oop based) or rename them to something else than hooks.

I assume there are also some hooks that can't be correctly put in any of these groups or are a mix of those groups. If so, that might be a sign that they should be redesigned. If someone knows any examples, I can add it here.

Disclaimer: This is not official but how I see it. Use with caution. ;)


I dont know why the post date has extra options, it seems that it allows you to create a custom format "on-the-fly". But you can create a custom date format and use it for your date field, and for other date fields as well along with the "Short", "Medium" and "Long" formats.

If you go to: configuration > date and time, you should see the three default ones (Short, medium,long). You can then click the "Formats" tap and then Add format. In the text field you can write a string that provides the format you want. Use the PHP date manual to find the letters that provides the month, date and so on. E.g if you want your format to be something like:

25-03-2014 15:48

Your string would be:

d-m-Y H:i

(Hint - you dont need necessarily to have minutes, you could also just have: d-m-Y)

Save that format and go back to the "Types" tap. Click Add date type, give it a name and then select your format on the list (it is typically at the bottom).

Then head over to your view, click the date field, and under the formatter, select Date and time, and then you should see your newly created date format on the list. Save your view and your custom date should display as the date...


Moving site to new domain on the same server

Check your .htaccess

Open your htaccess and modify line 94 to match your needs.

  # Modify the RewriteBase if you are using Drupal in a subdirectory or in a
  # VirtualDocumentRoot and the rewrite rules are not working properly.
  # For example if your site is at http://example.com/drupal uncomment and
  # modify the following line:
  RewriteBase /YOUR-FOLDER-NAME
  #
  # If your site is running in a VirtualDocumentRoot at http://example.com/,
  # uncomment the following line:
  # RewriteBase /

If this not work the problem is with your cache tables or custom code in template.php or in .module files

To clear cache tables you can try

drush cc all

OR Try this in phpMyAdmin or mysql console.

TRUNCATE `cache`;
TRUNCATE `cache_block`;
TRUNCATE `cache_bootstrap`;
TRUNCATE `cache_field`;
TRUNCATE `cache_filter`;
TRUNCATE `cache_form`;
TRUNCATE `cache_image`;
TRUNCATE `cache_libraries`;
TRUNCATE `cache_menu`;
TRUNCATE `cache_page`;
TRUNCATE `cache_path`;
TRUNCATE `cache_rules`;
TRUNCATE `cache_token`;
TRUNCATE `cache_views`;
TRUNCATE `cache_views_data`;

Make sure you include all tables starting with CACHE_

More info here Can any of the cache_* be emptied safely?


How can I programmaticaly submit the user edit form in Drupal 8?

I was mistaken when I said "auth_user_id" is always zero.  It isn't.  It contains the user's ID, as you would expect.  That makes this task fairly simple.  Here is the function for my logout endpoint:

public function logout($name = NULL) {

    if ($name) {
      $user = user_load_by_name($name);
      if ($user) {
        $uid = $user->id();

        $msg = 'User ' . $name . ' (uid: ' . $uid . ') logged out of app.';
        \Drupal::logger('orb_common')->notice($msg);

        // Not sure if it would be a better practice to set the status to zero, or delete.  In this example I delete the row.
        $query = \Drupal::database()->delete('oauth2_token');
        $query->condition('auth_user_id', $uid);
        $query->execute();
      }
    }

    $response['data'] = [];
    $response['method'] = 'POST';

    return new JsonResponse($response);
  }

In my routing file I have...

orb_common.orb_common_logout:
  path: '/orb_common/logout/{name}'
  defaults:
    _controller: '\Drupal\orb_common\Controller\CommonController::logout'
    _title: 'Logout'
  requirements:
    _permission: 'edit activity entities'

The JsonResponse at the end of my logout function presumably isn't important in this case.  The main thing is to pass a UID or username to Drupal in the URL of the endpoint, and then delete/update the relevant row in the oauth2_token table.  At least, that is working in my app.


hook_node_insert() is the one you're looking for...

  This hook is invoked from node_save() after the database query that will insert the node into the node table is scheduled for execution, after the type-specific hook_insert() is invoked, and after field_attach_insert() is called.


String Field as Link to Content (replacing node title field)

If you are a Drupal module developer, the easiest way to do this would be to define a custom field formatter that would specifically do this (i.e. linking field value to the URL of the node)  for the text field and content type that you want.

If you are looking for a UI solution, I'd suggest installing the custom_formatters module. Once you have done that, import the formatter below.

$formatter = new stdClass();
$formatter->disabled = FALSE; /* Edit this to true to make a default formatter disabled initially */
$formatter->api_version = 2;
$formatter->name = 'string_to_link';
$formatter->label = 'string_to_link';
$formatter->description = 'Converts string from a text field attached to a node to a link';
$formatter->mode = 'token';
$formatter->field_types = 'text';
$formatter->code = '[node:title]';
$formatter->fapi = '';

Now, go to the "Manage Display" page of the content type where you have your Node title field, and set the formatter to *Custom: (string_to_link)*. The value of the field is immaterial now. It'll be linked to the node always.

However, linking to the node from the node view itself is not really of much use, right? So, I'm guessing you'd want this in a node listing. (A set of nodes). In that case, you might want to use the Views module where you can explicitly link the node title to its URL for a view.


Is there any way to export data to CSV file and then import updated data?

If you want to do it that way, use Views data export. Here is an excerpt about it from the module's project page:

... designed to provide a way to export large amounts of data from views. It provides a display plugin that can rendered progressively in a batch. Style plugins are included that support exporting in the following types:

CSV.
Microsoft XLS.
Microsoft DOC.
Basic TXT.
XML.

Then, re-import using the Feeds module. Here is an excerpt about it from the module's project page:

Import or aggregate data as nodes, users, taxonomy terms or simple database records.

One-off imports and periodic aggregation of content
Import or aggregate RSS/Atom feeds
Import or aggregate CSV files
Import or aggregate OPML files
PubSubHubbub support
Create nodes, users, taxonomy terms or simple database records from import
Extensible to import any other kind of content
Granular mapping of input elements to Drupal content elements
Exportable configurations
Batched import for large files


Removing the dash/hyphen character from site search queries

You can probably do it with hook_form_alter() and str_replace(). I'm not familiar with the Custom Search module, but seems like it's just altering Drupal's default search so you could make use of this:

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'search_form':
    case 'search_block_form':
      array_unshift($form['#validate'], 'mymodule_search_validation');
      break;
  }
}

function mymodule_search_validation($form, &$form_state) {
  if (isset($form_state['values']['keys'])) {
    $form_state['values']['keys'] = str_replace('-', ' ', $form_state['values']['keys']);
  }
  elseif (isset($form_state['values']['search_block_form'])) {
    $form_state['values']['search_block_form'] = str_replace('-', ' ', $form_state['values']['search_block_form']);
  }
}

The above code adds a custom validation function to the search and search block forms where any existing dashes will be replaced by a space. The reason for using array_unshift() and the form validation handler is to replace values early on for avoiding potential issues that could arise at later stages.


Why do so many classes define a ::t() method?

The point is unit testing. You can extend the class and override t() or just create a mock out of it. Global functions are not available during PHPUnit runs and in general just a pain.

Since this became so popular let me link the relevant handbook page on global functions and unit tests.


If you go to http://yoursite.com/admin/people/permissions and find the "View published content" permission, uncheck it for anonymous users and that should do the trick.


How to change the label of username field on all forms/pages that it occurs?

Add the following code at the bottom of the settings.php file:

 $conf['locale_custom_strings_en'][''] = array(
   'username'      => 'nick-name',
 );

As alternative, you can use the String Overrides module.

  Provides a quick and easy way to replace any text on the site.

  Features

  Easily replace anything that's passed through t()
  Locale support, allowing you to override strings in any language
  Ability to import/export *.po files, for easy migration from the Locale module
  Note that this is not a replacement to Locale as having thousands of overrides can cause more pain then benefit. Use this only if you need a few easy text changes.


In the Views UI, when you edit the View, open up the "Advanced" options. The penultimate option (one up from the bottom) is "Theme: Information." Here's an example:

If you click on "Information" you'll be given a list of template suggestions like this one:

And if you then click on one of the output types (i.e. "Display output," "Style output," etc), you'll be shown the boilerplate code for a template that should be named with one of the names to the right of the style type, which you can cut and paste into a file you save with the appropriate name. Like so:

Once you've got the template name to use, and some code to go in it, create your template in your theme directory and modify to rewrite the links as you require. I happened to choose the "Display output" template as my example, but you'll most likely want to use the "Field Content" template/associated template name.

Note that this is an information-only option in Views - it won't create the template for you. You'll have to do that yourself. You can cut'n'paste from the boilerplate to get started.

I hope that helps...


Can I organize my custom module's twig templates into subfolders?

This is what the docs for hook_theme say about the template property:

  If specified, the theme implementation is a template file, and this is the template name. Do not add 'html.twig' on the end of the template name. The extension will be added automatically by the default rendering engine (which is Twig.) If 'path' is specified, 'template' should also be specified. If neither 'template' nor 'function' are specified, a default template name will be assumed. For example, if a module registers the 'search_result' theme hook, 'search-result' will be assigned as its template name.

Unless you've found a bug of omission, I would expect these docs to tell you if there was any auto-scanning of sub-folders going on. The fact that you've tried it and it doesn't work might be seen to back that up.

If you've seen other official docs that reference an auto-scanning feature, you may have hit a bug.

As an aside, I'm not sure what the intent of this code is:

'#theme' => 'SUBFOLDER/mytemplate'

You would never write that; you would instead use hook_theme to register your template with the system, and put the path to the file itself in the template property. Then you'd use:

'#theme' => 'theme_key'

in the render array


How to insert values into Global custom text field of views programmatically?

You should be able to do that with hook_views_pre_render(). Please try the following code:

function YOUR_THEME_views_pre_render(&$view) {

  switch ($view->name) {
    case 'YOUR_VIEW_NAME':
      //  override the global custom text field value
      $view->field['nothing']->options['alter']['text'] = 'My custom text';
    break;
  }
}

If the global custom text value need to be different for each view result, you can configure it using replacement patterns.

In order to programmatically insert values into Global custom text field, You can use template_preprocess_views_view_fields()

function YOUR_THEME_preprocess_views_view_fields(&$vars) {
  $view = $vars['view'];

  foreach ($view->field as $id => $field) {

    // The global custom text content
    $vars['fields']['nothing']->content = 'Some global custom text content';

    // change the global custom text content depend on result (node id)
    if ($vars['row']->nid == 10) $vars['fields']['nothing']->content = 'CHANGED';
  }
}


How to ensure that features dont get overidden

There are a number of reasons why Features may automatically show as overridden after being installed and not manually changing any Drupal configurations related to the Feature. There is a documentation page about this issue: Troubleshooting: Reasons Features May Be Stuck as Overridden. That documentation page is not complete, but it links to a Features issue queue thread where a lot more of the possible problems are outlined.


Use hook_menu_alter() to remove default registration page from menu system. Simply unset($items['user/register']); and clear menu cache.


Module for cropping user picture immediately

The best solution I found is to use the Imagefield Crop module. This does NOT work on profile pictures, so simply disable user pictures and then add an image field to the user account fields. It will work with that.


You can't disable Components.

Components are configurations, so they already have an 'active' field available.
Actions would be more difficult to disable.

You may read read from here Components: enable / disable


Wierd admin_path behaviour, does it should be like this?

Thank you Clive,
I mistakenly used pattern from hook_admin_paths() and not hook_admin_paths_alter() function.

The correct way was:

function MY_MODULE_admin_paths_alter(&$paths) {
  $paths['user/*/edit'] = FALSE;
  $paths['user/*/edit/*'] = FALSE;
}


Set default value of Search form block to be searched terms

For the regular search block, the preprocessing function template_preprocess_search_block_form() runs (you can find it in the search.module file of the core search module), which assigns the search terms you've entered to the $key variable which is used by the function building the search form.

You should include your own preprocessing function (named appropriately to run before your own template file) which performs a similar task to initialize any variables you need/use (you can even grab the code from the one cited above).  Since it sounds like you want to have the keywords printed, make sure the $key variable is actually set...  If you have a custom theme, you can just include the preprocessing function in your theme's template.php file.

Does that help?  Let us know if that works!

=========== ANSWER ADDITION ====================

OK, so here's what I've just tested that does work.  I've added a search preprocessor to my custom theme in the template.php file.  If you just copy this (with your own theme's name prefixed), it should work after you clear your cache.

I actually had to bang my head against the wall for a little bit.  At first I just copied the preprocessing function exactly from the search module, with the exception of setting the field's value to the search term in that first line (since it doesn't do that be default)... But nothing rendered.  Then I realized I had to add that second line I've commented on to set the '#printed' property to false, so that drupal_render() will render them again.  Soooo... I don't know if this is a good solution or not.  There may be a better way, but this is all I can think of and it works...

Again, in short, this is my copying the search module's preprocessing function and making the two line edits I've commented on by saying 'ADDED THIS LINE' to get the extra functionality.  Hope that makes sense.

function YOUR_THEME_preprocess_search_block_form(&$variables) {
// ADDED THIS LINE -- get the search term from the URL, so you can use that as the value of the search box text field
  $variables['form']['search_block_form']['#value'] = arg(2);

  $variables['search'] = array();
  $hidden = array();
  // Provide variables named after form keys so themers can print each element independently.
  foreach (element_children($variables['form']) as $key) {
    $type = $variables['form'][$key]['#type'];
// ADDED THIS LINE -- these fields have already been rendered by the search module's preprocessing function, so they won't render again here unless you do this...
    $variables['form'][$key]['#printed'] = FALSE;
    if ($type == 'hidden' || $type == 'token') {
      $hidden[] = drupal_render($variables['form'][$key]);
    }
    else {
      $variables['search'][$key] = drupal_render($variables['form'][$key]);
    }
  }
  // Hidden form elements have no value to themers. No need for separation.
  $variables['search']['hidden'] = implode($hidden);
  // Collect all form elements to make it easier to print the whole form.
  $variables['search_form'] = implode($variables['search']);
}

p.s. The above would obviously make the change for all search block forms on your site...


Create an order as administrator user and let users continue with the checkout

Could you create a new "shopper" user for this customer, then assign the order to them? Make sure the role has proper permissions, workflow, etc. But then they will be the owner of the order and should be able to complete payment (and all the other checkout features like confirmation email).


Change the permissions needed in a service to get info from a module?

Sounds like an authentication issues - have you read up on tokens? There's a couple of modules out there, one pretty recent, plus some doc:

https://www.drupal.org/project/services_token_access
https://www.drupal.org/project/services_token
https://www.drupal.org/node/2424977


Received "An illegal choice has been detected. Please contact the site administrator" while creating node with taxonomy field via service3 drupal7

I was having the same issue. After reading this I was able to figure out the problem by doing a dsm($_POST) on hook_node_update() and inspecting the array and figuring out what it expects.

In my case my array looked like this:

'field_term_subtype[und]' => '166',

In your case it would be:

{
    "title": "your title",
    "type": "page",
    "field_category": {
        "und": 6246
    }
}


Do you have a custom theme? If so, you can implement it like this:

Place your fonts in your custom theme, following something similar to this folder structure:

themes
  custom
    my_custom_theme
      fonts
        my_font.woff2
        my_font.ttf
        my_font.svg

And then in your CSS file (it might be in themes/custom/my_custom_theme/css/style.css for example) add the following:

@font-face {
  font-family: "my_font;
  src: url('/fonts/my_font.woff');
  src: url('/fonts/my_font.ttf');
  src: url('/fonts/my_font.svg');
}


How to override "Who's online" block theme without any change to "Who's new" theme

Since they both use the same theme function it gets more complicated.

The only real choice you have to alter the markup of the one block, but not the other, is to template_preprocess_block or templates for the blocks. The problem is that by this point the markup for the actual block content has already been created, which means that you would either have to recreate the markup, or use some pattern matching to alter the created markup. Both of which is not really desirable.

Another option would be to create the block yourself like the user module does but alter the markup that is created.


Page always takes at least 30 seconds to load

It could be several things:

Views executing sql queries that have performance problems.
Cache problems (Do you have enabled the Drupal's cache?).
(If you have a VPS) maybe the server that you are sharing is under heavy load.
(If your site is integrated with web services) maybe the web service is having performance problems or connection problems.

Try to check the logs of the site to see is there are errors or anything that could be related to this problem.

Another alternative is to use a profiler like Xhprof (there is a module for drupal) or XDebug.

Could you share with us the url of the website?


Using form api to store google map location

Yes, there are couple of ways of doing this. You would need to install Geofield which has a Form API element that can be used as such:

$form['location'] = array(
  '#type' => 'geofield_latlon',
  '#title' => t('Location'),
);

That'll give you a start to work from. I'm looking at embedding a clickable Google map using the GMap module as follows:

$form['contact_us']['map'] = array(
  '#description' => t('Enter your location to be displayed as a Google map.'),
  '#type' => 'gmap',
  '#title' => t('Location'),
  '#settings' => array(
    'zoom' => 8,
    'id' => 'location_map',
  ),
);

It shows the map however that is about all, so far. But it's another starting point for you!


How to add up price values when group by month?

You can use views date format sql with simple in built views aggregation. No need to use views aggregator plus.


How do I show the members in a block, contextually filtered by the currently logged in user?

One custom solution that is doing the exact same thing in my case is to create a view-block and show group content of type group membership. Then add the relationship Group content User, require this relationship, filter by plugin Group membership. Then add a contextual filter Group content: parent group. Add all fields you want to show in the view and use the relationship Group content user to display name, id, email etc.

Now the "custom" part in my solution is a tiny module that implements the hook_views_pre_view() and adds the gid of the currently logged in user to the $args array of that specific view like this: $args[0] = $gid;


How to get comment votes using raw sql query?

Here you are SQL to get the total vote count for widget type number for each comment od node type "story"

SELECT c.cid,count(v.vote_id) FROM votingapi_vote v JOIN comment c ON v.entity_id=c.cid JOIN node n ON n.nid=c.nid WHERE n.type='story' GROUP BY v.entity_id;

If you want to get the total numer of votes for all "story" nodes then:

SELECT c.cid,count(v.vote_id) FROM votingapi_vote v JOIN comment c ON v.entity_id=c.cid JOIN node n ON n.nid=c.nid WHERE n.type='story'

Or conditional for voting type like you did:

SELECT c.cid, count(v.value) FROM votingapi_vote v JOIN comment c ON v.entity_id=c.cid JOIN node n ON n.nid=c.nid WHERE n.type='story' and v.value_type='points' GROUP BY v.entity_id;


First you need to create a Taxonomy term on node relationship to your vocabulary and name the identifier term
Then create a Taxonomy term: Parent term relationship using the previous identifier (term) as relationship and name the identifier  parent
Create a Taxonomy term: Parent term contextual filter using term as identifier
Lastly, add a Taxonomy term: Name and use the parent relationship


How to display the webform submission data in the below format in Views?

Use the Webform MySQL Views module.
Then navigate to web form, you will find separate tab MySQL views.
Generate one view form the same by navigating to that view.
When the view is generated, you will find this view under structure menu, under views section.
Then you can display it as you wanted to display, either in grid, unformatted list, tabular format, etc.

As your image seems colourful and in tabular format, you could use CSS classes for that, applying them under Advance section.


How to add a default Field when creating a Content Type?

Not fully what you're asking. But once you have defined your image field you can easily reuse it in any content type. Since defining new content types is not something you do every day, this shouldn't be to much of extra work.


You can use hook_menu_link_alter() to hide those links. For example:

/**
 * Implements hook_menu_link_alter().
 */
function MYMODULE_menu_link_alter(&$link) {
  if ($link['link_path'] == 'node/add/dummy-type')) {
    $link['hidden'] = 1;
  }
}

Or can use hook_menu_alter() to redirect to other URL. For example:

/**
 * Implements hook_menu_alter().
 */
function MYMODULE_menu_alter(&$items) {
  $items['node/add/dummy-type']['page callback'] = 'drupal_goto';
  $items['node/add/dummy-type']['page arguments'] = array('node/1');
}

You can also use hook_menu_alter() to hide the links:

/**
 * Implements hook_menu_alter().
 */
function MYMODULE_menu_alter(&$items) {
  $items['node/add/dummy-type']['access callback'] = FALSE;
}


Display content on a node which is referenced in another node

I think you forgot to add a relationship in your views.

If you use  References module it works.(i know it'll be deprecated soon but for now it works well and save my life few times:))

In your content type add a field node reference to the article
In your views add a contextual filter [node:id] (add some validation criteria about your content type)
After add relationship

After you can hide the fields (don't forget in the setting formatter: rendered node)

After that you'll have the result you want.


Long term I would take a look at ESI over authcache. Not sure when manarth will get a stable release of 7.x out. ESI has fairly strong security with rotating keys and things like that.


How to replicate this form with exposed filters

You should create a view, with display page and add some exposed filters.
Then you have to enable the function "Expose form in block", or something like this, that creates a block with your exposed filters.


Bypass drupal theme with hook_menu() function?

Just to offer an alternative to Ayesh K's solution, you can set the delivery callback of your menu item

  The function to call to package the result of the page callback function and send it to the browser. Defaults to drupal_deliver_html_page() unless a value is inherited from a parent menu item. Note that this function is called even if the access checks fail, so any custom delivery callback function should take that into account. See drupal_deliver_html_page() for an example.


How about the Commerce Customizable Products Module.  I just saw this video today, maybe it will help.

Drupal Commerce allows you to sell customizable products that require customer input when added to the cart. Use cases for this functionality include:

Business cards that require contact information and a logo upload.
Event registrations that require attendee information.
Donations the allow the customer to specify a donation amount.

The core Line Item module accommodates these scenarios by letting you add any number of fields to the Product line item type and expose them to the Add to Cart form. However, sites that sell multiple types of customizable products or a mixture of customizable and non-customizable products need to define multiple line item types to handle the different configurations of fields. That's where this Customizable Products module comes in!
It gives you the ability to define new line item types on the fly at Administration > Store > Configuration > Line item types. This is functionally equivalent to defining the new line item type in code, which is still recommended if you are able.


You should use Rules module in the following way:

Install and enable Rules module
Install and enable Webform Rules (https://drupal.org/project/webform_rules)
Create a new rule
Choose the "After a webform has been submitted" event
Optionally set your conditions
Add a new action "Create a new entity" of type "Content"
Add the neededs action to add properties to the created entity
Add the save action

Note: You can use Tokens available with "Set a data value" .


commerce drupal 7 cache module suggestion

Have you tried to use Authcache module with memcache module

http://drupal.org/project/authcache

Also check Entity cache for Drupal Commerce module

http://drupal.org/node/1588814/release


Altering relationship in Views contextually

I did eventually discover simple solution, so perhaps it comes in handy for anyone else later. views_data_alter, of course, is not meant to apply an existing relationship, but rather to create a new one. To apply an existing relationship programmatically - Nodequeque in my case - you need to call in add_item function of view class:

$view->add_item($view->current_display, 'relationship', 'node', 'nodequeue_rel', array('names'=>array('myqueue'=>'myqueue'), 'required'=>1, 'limit'=>1))

where an array is a set of options like: the name(s) of queue(s) and whether any nodes excluded from chosen queque(s) should be added (1 - bool - implies that only nodes inside the chosen queque will be added).


Creating a block that lists various posts for various categories

Views are you friend. A View can also generate a Block. The sub-links are categories ordered by publishing date? Fairly easy.


Sub folders and how to namespace classes

@Clive is correct.

The namespace is always Drupal\{module_name}. Where that module lives is irrelevant (as long as it is somewhere where Drupal can find it). That namespace always points to $path_to_module/src.

It would not possibly work in any other way. Different sites have modules in a different structure and different places, but the same code has to work no matter where.


How to add new tab in user edit page drupal

You just need one item only. Please make the following change

$items['user/%user/invoice'] = array(
    'type' => MENU_LOCAL_TASK,
    'title' => 'Subscription Invoice',
    'page arguments' => array('user', 1),
    'page callback' => 'usermail_invoice',
    'access callback' => 'user_is_logged_in',
    'weight' => 3
);


Ajax HTTP Error Occured in Theming Tables

The correct way to do this is to populate the id table inside the form generation function (checking $form_state['values']). Then the callback should only return the form element.
This is an example of how I would do it:

function myid_print_user_page_form($form, $form_state)
{
    $form = array();

    $form['options'] = array(
        '#type' => 'select',
        '#options' => array(
            0 => t('All'),
            1 => t("Printed ID's"),
            2 => t("Unprinted ID's")
        ),
        '#ajax' => array(
            'callback' => 'myid_print_all_submitted_id_callback',
            'wrapper' => 'myid_table_wrapper_div',
        ),
    );
    $table_html = '';

    // Check if option has been selected.
    if(!empty($form_state['values']['options'])){
      // Build the sortable table header.
      $header = array(
          'id_number' => array('data' => t('ID Number'), 'field' =>   'id_number','sort' => 'asc'),
          'student' => array('data' => t('Student'), 'field' => 'student', 'sort' => 'asc')
       );
       //Get the node data.
       $query = db_select('student', 't1',array('target' => 'import'));
       $result = $query
           ->fields('t1', array('studid','lastname', 'firstname', 'middlename', 'extname'))
           ->condition('t1.id_status',2,'=')
           ->distinct()
           ->execute();
       //Build the rows.
       $rows = array();
       foreach($result as $record){
           $rows[$record->studid] = array(
               'id_number' => $record->studid,
               'student' => $record->firstname . ' ' . $record->middlename . ' ' . $record->lastname . ' ' . $record->extname,
           );
       }
       $table_html = theme('table', array('header' => $header, 'rows'=> $rows));

    }

    $form['myid_table_wrapper'] = array(
        '#type' => 'item',
        '#markup' => $table_html,
        '#prefix' => '
',
        '#suffix' => '
',
    );
    return $form;
}

function myid_print_all_submitted_id_callback($form, $form_state)
{
    return $form['myid_table_wrapper'];
}

This is untested, but you get the idea.


Automatically choose specific option from select field attribute based on inbound link / previous page?

Use hook_form_alter or hook_form_FORM_ID_alter, check your stuff (get parameter maybe), then apply the selected item though the form api


link next to field to add referenced entity for site editor

This could be done without a custom module, by using the Markup module.

However, if you are looking for the ability to add a new ContentTypeB that is immediately referenced, the References Dialog module can do this.


How can I alter Entity Auto Complete Results?

I wrote a little module that shows how to alter entity autocomplete suggestions. You could try modify it to meet your needs.
https://github.com/minnur/Alter-Entity-Autocomplete


Taxonomy terms are attached to nodes using term reference fields in Drupal 7. As such, you have access to the term reference field just like any other in the list of replacement tokens.

Look for fields related to the node with a description of "Term reference field", e.g.

EDIT:

To address your edit, I know it looks ridiculous but something like this will probably work (using field_school as an example):

[node:field-school:vocabulary]/[node:field-school:parent:parent:name]/[node:field-school:parent:name]/[node:field-school:name]

Here's another screenshot showing the extra data available for term reference fields in pathauto:


Ubercart review order button redirects to cart page, does not allow checkout

It actually turned out that I had a product in my cart that was no longer on the site, and my theme did not have the proper messages outputting.  I switched the theme back to Bartik and got a message saying there were products in my cart that were no longer available.


Cloning content types and corresponding Display Suite settings

Nevermind, found a solution:

Bundle copy version 7.x-2.x-dev allows cloning directly (without exporting/importing and changing bundle's machine name).
There is a patch that gives support for display suite cloning, exporting and importing. (I had to fix the patch first to be able to apply it with patch manager.)

All worked like a charm!


You can call PathProcessorManager::processOutbound() for the internal path and you get the path alias and the prefix at the same time:

$options = ['prefix' => ''];
$path = \Drupal::service('path_processor_manager')->processOutbound('/node/1', $options);
$prefix = $options['prefix'];


Rules (not) triggered with Bulk Media Upload

As noted, your rule is setup for serial upload operations; BMU sets the entities in a batch process, rather than one reference/file at a time.

You may be able to overcome the race condition resulting from the rule firing and batch processing by triggering the rule on node save rather than individual file uploads while editing the node.  This will ensure each file has a Drupal FID assigned and has been fully added to the files table in Drupal for referencing.


How to build a url path from raw path and arguments?

I don't think core has a function like that but it's easy enough to write a simple version:

$path = '/path/to/page/%foo/%bar/view/%';
$args = array('foo1', 'foo2', 'foo3');

$wildcards = array();
foreach (explode('/', $path) as $part) {
  if (strpos($part, '%') === 0) {
    $wildcards[] = $part;
  }
}

if (count($args) != count($wildcards)) {
  // Handle it
}

foreach ($args as $key => $arg) {
  $wildcard = $wildcards[$key];
  $pos = strpos($path, $wildcard);
  if ($pos === FALSE) {
    break;
  }

  $path = substr_replace($path, $arg, $pos, strlen($wildcard));
}
print $path;

Result is: /path/to/page/foo1/foo2/view/foo3


From https://superuser.com/questions/373115/why-cant-i-delete-a-file-where-i-have-group-write-permissions-on

File deletion is based on directory perms, not file perms (*).

That said, check the directory /var/www/html/drupal_2020 permissions.


I can create content type fields pragmatically, but I set het widget options too?

I think it should look like this :

    'field_instance' => array(
  'bundle' => 'fo',
  'default_formatter' => 'text_default',
  'default_value' => NULL,
  'default_widget' => 'text_textfield',
  'deleted' => '0',
  'description' => 'blah blah blah.',
  'display' => array(
    'default' => array(
      'label' => 'above',
      'module' => 'text',
      'settings' => array(),
      'type' => 'text_default',
      'weight' => 0,
    ),
  ),
  'entity_type' => 'taxonomy_term',
  'field_name' => 'test',
  'instance_settings' => array(
    'text_processing' => 0,
  ),
  'label' => ' test',
  'required' => FALSE,
  'settings' => array(
    'max_length' => 255,
    'text_processing' => 0,
    'user_register_form' => FALSE,
  ),
  'title' => 'test',
  'widget' => array(
    'module' => 'text',
    'settings' => array(
      'size' => 60,
    ),
    'type' => 'text_textfield',
    'weight' => 31,
  ),
),


How can I display the last modified date on my site?

Assuming you just want to check nodes (and not other content, like users), you'll want to check the node table and find the row with the latest changed timestamp. This function should do the trick:

/**
 * Get the last updated date for nodes.
 *
 * @return
 *   A formatted date for the last updated time if there are published nodes,
 *   FALSE otherwise.
 */
function _mymodule_last_updated() {
  // Pull from cache if available
  if($cache = cache_get('mymodule_last_updated')) {
    $last_updated = $cache->data;
  }
  else {
    // Otherwise, find the timestamp for the latest node record
    $last_updated = db_select('node', 'n')
      ->fields('n', array('changed'))
      ->condition('status', 0, '>') // only published nodes count
      ->orderBy('changed', 'DESC')
      ->range(0, 1)
      ->execute()
      ->fetchField();

    // If nothing found, return FALSE.
    if (!$last_updated) {
      return FALSE;
    }

    // Otherwise, save the data to cache for one hour.
    cache_set('mymodule_last_updated', $last_updated, 'cache', time() + 3600);
  }

  return format_date($last_updated);
}

Now, wherever you wanted to put the information, just call _mymodule_last_updated():

if ($last_update = _mymodule_last_updated()) {
  $last_update_text = t('Last updated: @name', array('@date' => $last_update));
}
else {
  $last_update_text = t('There have been no updates lately.');
}

However, I'd suggest creating custom module and defining a block. This would allow you to avoid having to mess with the PHP code any time you wanted to move the information around, and expose it to others who don't have access to the source code.

Once you've created your custom module, you want to implement the hook_block_info() and hook_block_view() hooks:

/**
 * Implements hook_block_info().
 */
function mymodule_block_info() {
  $blocks['mymodule_last_updated'] = array(
    'info' => t('Last updated block'),
  );
  return $blocks;
}

/**
 * Implements hook_block_view().
 */
function mymodule_block_view($delta = '') {
  $block = array();

  // Only act if it's our block
  if ($delta == 'mymodule_last_updated') {
    $block['subject'] = t('Last updated');

    if ($last_update = _mymodule_last_updated()) {
      $block['content'] = t('The site was last updated on @date.', array('@date' => $last_update));
    }
    else {
      $block['content'] = t('There have been no updates.');
    }
  }

  return $block;
}

Once defined, your new block would show up in Structure → Blocks.

Note: in all of these snippets, you'll want to replace mymodule with your custom module's name.


How can I make a template for a product type in Commerce?

I believe that it is a product reference field, and therefore, the template suggestions are different. That is why creating random node template files is not having any effect. What you want to target is the entity being referenced.

You should check what templates or theme hooks exist in Commerce, and derive the templates from that. You can also add your own suggestions when preprocessing.

Here are some threads that will help:

https://www.drupal.org/node/1245354
https://www.drupal.org/node/1245354#comment-11788691
Is there a product.tpl.php for ALL product types in Drupal Commerce?
https://drupalcommerce.org/discussions/911/customize-way-product-displayed
https://drupalcommerce.org/discussions/337/how-theme-product-display

Note that if you add to template.php or introduce new templates, you will need to clear your caches so it is picked up by Drupal.

A bulletproof way to find out would be to do mytheme_preprocess_entity($variables) in your themes template.php file, and dump out $variables when it is preprocessing a product entity. Within it, you will see possible template suggestions for the product entity itself.

The same applies for fields as well. template_preprocess_field: https://api.drupal.org/api/drupal/modules%21field%21field.module/function/template_preprocess_field/7.x


Are Drush configuration files compatible across all Drush versions?

Drush configuration files, generally speaking, anyway, only set options for use in various Drush commands.  If an unknown option is used directly on the commandline, this will result in an error; however, Drush ignores unknown options that are set in a configuration file.  This makes it fairly safe to use the same configuration file for multiple versions of Drush.  I have been using the same config file from Drush 5 to present without an issue.

If you do end up with some configuration tricks that only work with specific versions of Drush, you can always make a drush8rc.php file; this will only be loaded by Drush version 8, and will be ignored by all other versions of Drush.


Do i really need to hack core to install Amazon S3 Module?

I think you should give a try to S3FS module

  S3 File System (s3fs) provides an additional file system to your
  drupal site, which stores files in Amazon's Simple Storage Service
  (S3) or any other S3-compatible storage service. You can set your site
  to use S3 File System as the default, or use it only for individual
  fields. This functionality is designed for sites which are
  load-balanced across multiple servers, as the mechanism used by
  Drupal's default file systems is not viable under such a
  configuration.


List items of a certain content type in another content type

A general out line is given below,

Create a content type for country, add your available
countries with images and description
Create a destination content type, with necessary fields like
image,description etc: (If you want process booking with payment, use
Ubercart and create a product class Destination, modify the required
fields)
Add a country field to destination contenttype of 'fieldtype' - Node Reference, choose widget as select list. This allows choose country on creation of a new destination
Use Views to list the destinations page, by selecting necessary fields,
Use views to create the list of related destinations based on the
country name and save it as a block. So based on the country
selection the destinations can be list in this block
If you are using online payment for booking use ubercart, otherwise
on booking you can send an enquiry to admin.

Hope you got an idea on how to proceed.

UPDATE
To get list of the destinations on clicking the country do the following

In your destination listing view, Add a 'Contextual filters'(
Arguments in D6) and choose the 'country nodereference field'.
In your four country listing view, in fields choose Nid (Nid)  also
and choose 'Exclude from display ' option for that field.
Then in the 'Country name field' - click 'Rewrite results' and choose
'Output this field as a link' checkbox. In link path give path like
below
eg: destinations/[nid]  ie: where destinations is the path of the
your destination page and [nid] is the token for the node id.
Probably you have to just change 'destinations' only with your path.

Thats it, now on clicking the country it will goto destinations page which shows all destinations belongs to the particular country


How do I redirect on flag save programmatically?

This can be done in hook_entity_presave().
function MYMODULE_flagging_presave(FlaggingInterface $flagging) {
  switch ($flagging->getFlagId()) {
    case 'FLAGTYPE':
      $redirect_url = Url::fromRoute('view.VIEW_MACHINE_NAME.VIEW_DISPLAY_ID')->toString();
      $response = new RedirectResponse($redirect_url);
      $response->send();
     break;
   }
 }


Drupal entity metadata wrapper no bundle property

I solved it applying this patch:
https://www.drupal.org/project/entity/issues/2819665

although I to be honest don't understand why...


I am not sure how you would approach this by adding the fields as entities via the GroupContentEnabler (that'd mean one custom plugin per field? Given a large number of fields that might not be the best solution). However, for an example how to implement your own custom group-content-type plugin see this answer.

Another possible approach that might be worth checking is to implement hook_entity_field_access() to define access checks for single fields programmatically (that's how I've solved a similar problem). See the group module's gnode.module file for an example how to check permissions/roles for users and add cache-tags to access results.


Isotope and Views Load More error - Javascript breaks on some Ajax calls

I did noticed that after the 1st load more, you can't zoom in, then after the 2nd load more zoom works, and after the 3rd load more zoom doesn't work again.

I believe it's your code. You need to add the zoom in/out part again inside the ajaxComplete function

(function ($) {
Drupal.behaviors.skeletonthemeCustomBehavior = {

attach: function (context, settings) {

  // $grid.isotope('destroy');

  var $grid = $('#isotope-container').isotope();

  $grid.isotope({
    masonry: {
      columnWidth: 10
    }
  });

$grid.on( 'click', '.isotope-element', function() {
  if ($( this ).hasClass( 'gigante' )) {
    $( this ).toggleClass('gigante');
  } else {
    // change size of item by toggling gigante class
    $( '.isotope-element' ).removeClass( 'gigante' );
    $( this ).toggleClass('gigante');
  }
  $grid.isotope('layout');
});

$('#destroy').bind( 'click' ,function(e) {
  event.preventDefault(e);
  $grid.isotope( 'destroy' );
});

  $('.relayout').bind( 'click' ,function(e) {
    event.preventDefault(e);
    var $grid = $('#isotope-container').isotope();
    $grid.isotope({
      masonry: {
        columnWidth: 10
      }
    });
    $grid.isotope('reloadItems');
  });

  $( document ).ajaxComplete(function() {
    var $grid = $('#isotope-container').isotope();
    $grid.isotope({
      masonry: {
        columnWidth: 10
      }
    });
    $grid.isotope('reloadItems');
    // adding the zoom in/out after ajax complete
       $grid.on( 'click', '.isotope-element', function() {
       if ($( this ).hasClass( 'gigante' )) {
       $( this ).toggleClass('gigante');
       } else {
       // change size of item by toggling gigante class
       $( '.isotope-element' ).removeClass( 'gigante' );
       $( this ).toggleClass('gigante');
       }
       $grid.isotope('layout');
       });
  });
}

};
})(jQuery);


Build and update a form based on another form

You could possibly use the #states API to react upon another option in the dropdown is selected, this will work without submits on the client side.

If you want to change your form after submission has happened only you'd have to add conditions in your custom form function that will change your form dynamically according to what is contained in the $form_state['values'] of that dropdown field.


in schema change field type to text and add translatable: true

mytheme.settings:
  type: theme_settings
  label: 'My theme settings'
  mapping:
    custom_textarea:
      type: text
      label: 'Additional settings'
      translatable: true

You may also face this problem later https://www.drupal.org/project/drupal/issues/2719553 (my reply there is the last from current date)


Open Atrium 2 or Drupal Commons or Simple Drupal with OG

Drupal Commons has a terrible track record or maintainability and upgrade path.  I only recommend using Drupal Commons or Open Atrium when they fit your needs out-of-the-box.   If you have very custom needs, definitely go with a custom D7 & OG build.

If you find that Drupal Commons or Open Atrium have features that you would like to replicate, then install them somewhere else and use them as a guide for creating your own features.

The best answer is to say you need to try them all and determine their strengths and weaknesses according to your project, but from personal experience, I have regretted every project I've used Drupal Commons on, and won't do it again.

One project I did, we started with Drupal Commons, and eventually realized that it was not a good fit.  So we just copied all the features we wanted into a normal D7's sites/all/modules directory.


Try

function MYMODULE_form_alter (&$form, &$form_state, $form_id)
{
  // comments
  // http://api.drupal.org/api/drupal/modules--comment--comment.module/function/comment_form/6

  if ($form['#id'] == 'comment-form') {
    $form['comment_filter']['format'] = array(); // nuke wysiwyg from comments
  }
}


How do I show a message about the currently executed operation?

The message will be shown just when the batch callback returns. If your intent is pausing the batch operations to let users see the pre-execution message, I would rather use the following code.

function batch_callback(&$context) {
  if (empty($context['sandbox'])) {
    $context['message']  = t('Pre-execution message...');
    $context['finished'] = FALSE;
    $context['sandbox']['step'] = 1;

    return;
  }
  elseif ($context['sandbox']['step'] == 1) {
    sleep(5);
  }
  // Do your operations.
}

You could also set the progress message using $batch_definition['progress_message'] (where $batch_definition is the value passed to batch_set(), but that just gets @current, @remaining, @total, @percentage, @estimate and @elapsed as placeholders. You could not use it to show, for example, the title of the node being processed, since it doesn't allow to use a custom placeholder. It is used more for messages like Completed @current of @total.


You can go to Admin -> Group -> Group Types -> [your group type]. On that page, click the Permissions tab. You can see all the permissions there. If you need to know the permissions string, you can inspect any checkbox for a given role/permission combo, and look at the name attribute. It will be something like admin[permission_label], where permission_label is the value you would pass as the first argument to $group->hasPermission().


How can I get the Operations Link Field back?

I had deleted the "list_builder" handler from my custom entity's annotations - thinking I didn't need a list builder since I was using a Views handler. Well, turns out that was the problem. The "Operations" link in views came back after I reinserted the list builder handler in my custom entity.


How to add classes to some images in a multi value image field?

You can create a tpl.php file for your image field.

Possible override templates are:

field.tpl.php
field--field-type.tpl.php
field--field-name.tpl.php
field--content-type.tpl.php
field--field-name--content-type.tpl.php

code for field--field-name.tpl.php file as below.

 <?php

/**
 * @file field--field-name.tpl.php
 * Default template implementation to display the value of a field.
 *
 * This file is not used and is here as a starting point for customization only.
 * @see theme_field()
 *
 * Available variables:
 * - $items: An array of field values. Use render() to output them.
 * - $label: The item label.
 * - $label_hidden: Whether the label display is set to 'hidden'.
 * - $classes: String of classes that can be used to style contextually through
 *   CSS. It can be manipulated through the variable $classes_array from
 *   preprocess functions. The default values can be one or more of the
 *   following:
 *   - field: The current template type, i.e., "theming hook".
 *   - field-name-[field_name]: The current field name. For example, if the
 *     field name is "field_description" it would result in
 *     "field-name-field-description".
 *   - field-type-[field_type]: The current field type. For example, if the
 *     field type is "text" it would result in "field-type-text".
 *   - field-label-[label_display]: The current label position. For example, if
 *     the label position is "above" it would result in "field-label-above".
 *
 * Other variables:
 * - $element['#object']: The entity to which the field is attached.
 * - $element['#view_mode']: View mode, e.g. 'full', 'teaser'...
 * - $element['#field_name']: The field name.
 * - $element['#field_type']: The field type.
 * - $element['#field_language']: The field language.
 * - $element['#field_translatable']: Whether the field is translatable or not.
 * - $element['#label_display']: Position of label display, inline, above, or
 *   hidden.
 * - $field_name_css: The css-compatible field name.
 * - $field_type_css: The css-compatible field type.
 * - $classes_array: Array of html class attribute values. It is flattened
 *   into a string within the variable $classes.
 *
 * @see template_preprocess_field()
 * @see theme_field()
 *
 * @ingroup themeable
 */
?>

<div class="<?php print $classes; ?>"<?php print $attributes; ?>>
  <?php if (!$label_hidden): ?>
    <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;

  <?php endif; ?>
  <div class="field-items"<?php print $content_attributes; ?>>
<?php $i = 0; ?>
<?php foreach ($items as $delta => $item): ?>
<?php $i++; ?>
      <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?> custom-class-<?php print $i;?>"<?php print $item_attributes[$delta]; ?>><?php print render($item); ?>

    <?php endforeach; ?>

For more info check field.tpl.php

To override node.tpl.php check

You can also check this link https://api.drupal.org/api/drupal/includes%21theme.inc/function/template_preprocess/7


Can't add a new field of type entity reference!

It was my browser's cache.

On clearing my browser cache I was able to see the Entity Reference field as well.


Passing extra image data (EXIF date) to the browser upon adding an image in a form

hook_preprocess_image_widget() worked for me.


Drupal.behaviors get results from function

Use ajax_command_settings. Here is the answer Drupal.settings merging when using AJAX