Display file upload images in webform view

This can not be done with webform module alone.
All you need to do is get help of 2 extra modules.

File Entity
Views Field View

Further you need to do following things.

Download and enable both of the modules and clear the cache.
Webform is storing file, not only image. I am assuming here you are only uploading image files, you can further get idea to show any type of file there. So go to Image File Type Display: admin/structure/file-types/manage/image/file-display and set the preview/image style. Or if you do not want to change settings for default view mode of the file, download another module Entity View Mode. Go to it's configuration and create specific display and set image style accordingly in file display settings.
Create a view of files, it should be a block. and there add contextual filter for the fid and add field "File: Rendered". You can set file view mode by this field. For your convenience I'm exporting the view below, you just need to import this.

    $view = new view();
    $view->name = 'file_view';
    $view->description = '';
    $view->tag = 'default';
    $view->base_table = 'file_managed';
    $view->human_name = 'File view';
    $view->core = 7;
    $view->api_version = '3.0';
    $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

    /* Display: Master */
    $handler = $view->new_display('default', 'Master', 'default');
    $handler->display->display_options['title'] = 'File view';
    $handler->display->display_options['use_more_always'] = FALSE;
    $handler->display->display_options['access']['type'] = 'perm';
    $handler->display->display_options['cache']['type'] = 'none';
    $handler->display->display_options['query']['type'] = 'views_query';
    $handler->display->display_options['exposed_form']['type'] = 'basic';
    $handler->display->display_options['pager']['type'] = 'some';
    $handler->display->display_options['pager']['options']['items_per_page'] = '5';
    $handler->display->display_options['style_plugin'] = 'default';
    $handler->display->display_options['row_plugin'] = 'fields';
    /* Field: File: Name */
    $handler->display->display_options['fields']['filename']['id'] = 'filename';
    $handler->display->display_options['fields']['filename']['table'] = 'file_managed';
    $handler->display->display_options['fields']['filename']['field'] = 'filename';
    $handler->display->display_options['fields']['filename']['label'] = '';
    $handler->display->display_options['fields']['filename']['alter']['word_boundary'] = FALSE;
    $handler->display->display_options['fields']['filename']['alter']['ellipsis'] = FALSE;
    /* Field: File: Rendered */
    $handler->display->display_options['fields']['rendered']['id'] = 'rendered';
    $handler->display->display_options['fields']['rendered']['table'] = 'file_managed';
    $handler->display->display_options['fields']['rendered']['field'] = 'rendered';
    $handler->display->display_options['fields']['rendered']['label'] = '';
    $handler->display->display_options['fields']['rendered']['element_label_colon'] = FALSE;
    /* Contextual filter: File: File ID */
    $handler->display->display_options['arguments']['fid']['id'] = 'fid';
    $handler->display->display_options['arguments']['fid']['table'] = 'file_managed';
    $handler->display->display_options['arguments']['fid']['field'] = 'fid';
    $handler->display->display_options['arguments']['fid']['default_action'] = 'default';
    $handler->display->display_options['arguments']['fid']['default_argument_type'] = 'node';
    $handler->display->display_options['arguments']['fid']['summary']['number_of_records'] = '0';
    $handler->display->display_options['arguments']['fid']['summary']['format'] = 'default_summary';
    $handler->display->display_options['arguments']['fid']['summary_options']['items_per_page'] = '25';

    /* Display: Single File View */
    $handler = $view->new_display('block', 'Single File View', 'block');

Now in your main view (where you are showing submissions). Add a new relationship for Webform submissions: Data. You'll need to set the nid for the webform here and select the image component.
Add new field to the view submission data: Value (raw). This will give you the file_id for the associated file. Exclude it from display.
Add another field Global: View. Select the view you imported and the block display. In contextual filter set [!data] from replacement patterns. It was the raw value of the field which you excluded from the display. And Here you go, save the view and rock :). Thanks for asking such good question. Still if you face any problem during this tutorial, ask me.


$node->set('uid', 0); $node->save should have worked. Maybe you forgot to flush caches.
To programmatically set the author to anonymous user on any entity you can call $entitiy->setOwnerId(0); and then $entity->save();, done.
$entity->setOwnerId(0);
$entity->save();


How to move "description" below the "label" for a field in a form?

Have a look at Label help module. It just creates a second help field that will appear directly below the form element's label.

It is a simple way to turn around the problem.

Or try something like

jQuery(document).ready(function ($) {

  // move the help text from below the input field to directly below the field label

  $('.form-item .description').each(function () {  // description is the help text
    var desc = $(this);
    var label = desc.siblings('label:first');
     if (label.length) {
       desc.insertAfter(label);
     }
  })
  // the help text is tangled up in the text format stuff on a filtered text field
  $('.text-format-wrapper .description').each(function () {
    var desc = $(this);
    var label = desc.siblings('.form-item').find('label:first');
     if (label.length) {
        desc.insertAfter(label);
     }
  })
});

(thanks to El bandito !)


The Delta module allows you, via the Context module to make duplicates of your theme settings for any context on your site. This gives you the ability for alternative layouts as a reaction in Context. The Delta module was originally created to compliment the powerful Omega base theme, but now works with ANY theme (3.x Version)


How to access the external database in drupal?

First you need to setup your external database as a second database in settings.php.

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'standard_db',
      'username' => 'username',
      'password' => 'password',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
  'external' =>
  array (
    'default' =>
    array (
      'database' => 'external',
      'username' => 'username',
      'password' => 'password',
      'host' => 'db.external.com',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

Then before you do your database queries you need to set the active database. In this example, to switch to external you need to execute db_set_active('external');

When you want to switch back to the default database you execute db_set_active();

Example code to switch to and query the external database:

db_set_active('external');
$query = db_select("your_table_name", "t");
$query->addField("t", "field_name");
$result = $query->execute();
while ($row = $result->fetchAssoc()) {
  drupal_set_message($row['field_name']);
}

db_set_active();


entityfieldquery, return several results

The table in your screenshot is a field table. It stores field data for entities, for both multiple and single cardinality fields.

When you use an EntityFieldQuery, you're querying for entities, not fields. It wouldn't make sense for you to receive data for anything else.

The connection you need to encourage your brain to make is that the fields are attached to the entities. So, if you want to know about multiple field values for a node, you just need to go and get them:

// Keep track of the delta, you mentioned you wanted it...
$delta = 0;
foreach (field_get_items('node', $node, 'field_foo') as $item) {
  $field_value = $item['value'];

  $delta++;
}

If that isn't what you're looking for, then EntityFieldQuery probably isn't the tool for the job. If that's the case, and you're using MySQL as the storage backend for fields, I'd recommend manually querying the field_data_field_foo table to get what you're after directly.


Change text displayed when cart is empty

I think a theme function called commerce_cart_empty_page is used. So you should be able to add a function:
MYTHEME_commerce_cart_empty_page()
to your themes template.php file and return whatever html you want.

You can also do the same for the cart block with a theme function MYTHEME_commerce_cart_empty_block()


For the automatic referencing you could use entityreference_prepopulate. So your button to answer from the question node would link to something like node/add/answer/27 where 27 is the question node nid. The module supports to hide the field once the value is in the URL so the user dont have to see the field.


Views Bulk Operations execute php loop over reference values

For any field that has multiple values you can use field_get_items() to retrieve all values. For your specific case with the entity reference field, you'll need to retrieve the target_id property from each field item.

  $node = node_load($nid); //$nid is the node id you get from VBO
  $references = field_get_items('node', $node, 'field_MY_REFERENCE_FIELD');
  foreach($references as $index => $value) {
    $reference_nid = $value['target_id'];
    //@TODO: use $reference_nid to retrieve anything about referenced node
  }


Are there conditions where invalidated cache items are returned?

See my presentation on Drupal 8 Caching about that topic: https://md-systems.github.io/drupal-8-caching/#/6/6 for how you can still get invalid items. And https://md-systems.github.io/drupal-8-caching/#/6/5 on how cache tag invalidation works.

The reason why cache tags invalidate instead of delete is scalability. Invalidating a cache tag does not require us to touch each single cache entry, we just need a single update query to increase the invalidation counter that is checked when cache entries are loaded. Common cache tags like renderered, image style cache tags and other frequently used cache tags could be on tens or hundreds of thousands of cache entries, deleting them all at once would take a very long time on MySQL and other cache backends like Memcache have no API to do do something like that at all.


Uploading image to a node via Angular to Drupal 8 using REST

ImageItem and FileItem are represented as entity references. The ImageItem has the following schema: target_id, alt, title, width, and height.

Only the target_id column is a required property, which can be seen through ImageItem::propertyDefinitions > FileItem::propertyDefinitions >  FieldReferenceItem::propertyDefinitions parent method.

The field should be represented similar to the type property, which also is an entity reference.


How can I allow authenticated users to edit their nodes only while they are unpublished?

You could implement a special hook_node_access to return TRUE or FALSE based on the node status.


How to pass different parameters to the same form function based on different urls

Remove $form from the submit function and just keep the $form_state.

The function would look like

function parkingcalulator_form_submit(&$form_state ,$type)


It is possible to call a View using PHP code. It is also possible modify a view using code such as hook_views_pre_view() to change how a View is displayed dynamically.

I actually wouldn't do either for your request. Simply do the following:

In your View make 2 displays.

1 view display that shows the Grid format.
1 view display that shows the list format.

On the page in question use an HTML button, html link, or even a Rules Link that uses Ajax to reload the div on the page and calls the view with the correct display mode you want. Your ajax call will be calling like: $view = views_embed_view('MY_VIEW_NAME', 'display_id'); and updating the page with $view contents via Ajax.

So make 2 view displays, and learn how to call them using Ajax.


How to correctly format a POST request to the file_upload Rest Response?

Recently I have faced the same issue in a file upload. For this, I have done base64_decode() before the file_save_data() in Drupal.
Example code:

  if (isset($file_data['title']) && isset($file_data['data'])) {
      // Get base64_encode of file data and explode to get data.
      $encodedImgString = explode(',', $file_data['data'], 2)[1];
      // Decode the data.
      $decodedImgString = base64_decode($encodedImgString);
      // Get the file name.
      $file_name = preg_replace('/\\.[^.\\s]{3,4}$/', '', $file_data['title']);*/
      // Save the file using base_decode() data.
      $file = file_save_data($decodedImgString, 'public://' . $file_data['title'], FILE_EXISTS_RENAME);
      $file_result = [
        'target_id' => $file->id(),
        'title' => $file_data['title'],
      ];
    }

Hope this helps you.

Note: Here I have used custom REST API for file uploads.


How do I migrate the basic page content to another site?

As far as I understand from your short question, you want to export only some content to another Drupal installation. In this case Backup and Migrate module will not do any good for you, because it is mainly designed for backing up migrating at database level.

Node Export will allow you to export and import nodes to another Drupal installation.

  Using this module you can save yourself a lot of time setting up new
  websites that have similar nodes to websites you've already made,
  migrating nodes to new Drupal versions, or between
  development/staging/production sites.


Ajax div update to insert JS for subsequent asynchronous request to external site

I managed to solve this by escaping one more character and removing one semicolon.

In the 2nd argument of ajax_command_html I was attaching a string which had two script tags, one inner and one outter. The inner closing script tag wasn't being passed unless I escaped its forward slash, like this:

<\/script>

Lastly, I had to remove the semicolon that was following "(jQuery)", just prior to closing the outter script tag, like this:

})(jQuery)</script>');

Hopefully this can be of use to someone!


How can I hide and print a field in my tpl.php?

I think you need to use $content['product:field_NAME'] for this

See this answer for more info: Print out a Drupal Commerce field only if it has a value


How to sync content title with "synchronize translations" module?

Possibly this is because titles do not get translated in a site using the i18n module. And that is most often because of the Title module that has not been enabled. From the module's project page (bold markup added here):

  After enabling the module as usual, visit the Manage fields page of the content type, taxonomy vocabulary or "comment type" which you wish to replace fields of and click the replace link. That's all.


How can I use REST API to create a node with status/tags/data

You should have look at drupal docs but for understanding that first install Devel module - it really helps you to discover field names.


Best practices to hide elements on a page

As Alex Gill mentioned in the comments this is an open ended question.

My guidelines though are as follows:

never hide something via CSS if you can hide it via application code, especially if you don't really want it inside the HTML. Hiding stuff with CSS is only acceptable if you want to have them "preloaded" in order to display them later on using javascript
hiding something via module (e.g code from your features module, if you have one) is good since it can work with any template

In regards to hiding form elements please note that:

hiding stuff with CSS still makes it possible for "smart" users to alter the hidden defaults, possibly via Firebug etc. So you should not assume that users will not be able to alter form elements that they cannot see.
removing form elements via code may have side effects down the line in case you've removed stuff that is expected in validate functions. E.g if you've removed a mandatory form element then it'll never get submitted.


When I add a context filter, my view is wrapped in a div

Check the twig template (by turning on twig debugging) that is generating the div for your contextual filter. Then alter it with an ID or Class tag.

Let me know if you need help turning on twig debugging.

Find the twig template that is generating that div, copy it and rename it with one of the FILE NAME SUGGESTIONS. The add the following code to the div.

<div{{ attributes.addClass('my-class') }}></div>


Missing bundle property on entity of type taxonomy_term

This error is caused when there is no Vocabulary selected in the Term reference fields of the content type into which feed import is performed.

Go to the Manage fields of your content type into which you are importing. Check all the Term reference fields and reconfirm that in the Field Settings, correct Vocabulary is selected.


In addition to the usual cache rebuild, the additional need to restart the web server is due to a decision in Drupal 8 to be 'fast by default' use the APC Classloader if it is available.  It is faster, but it doesn't necessarily catch changes as you make them.  To not have to restart your web server during development, you can set your local environment to not try to use a better-for-production class loader.

For instance, in local.settings.php add:

$settings['class_loader_auto_detect'] = FALSE;

Via, and more background information at, what to do when developing a Drupal 8 module and a class file just isn't being loaded even though it is definitely there.


Ok, I've got a solution that will work for me. This d.o forum comment was very helpful.

Instead of changing the $form['submit'] array, prepend the callback to the submit callback stack! Like so:

array_unshift($form['actions']['submit']['#submit'], 'MODULE_my_custom_submit_handler');

Note that the code in the comment from d.o is a bit off, you don't need to assign the unshift'ed array, you just run array_unshift on the array itself.

Once that's added in your hook_form_alter you can do WHATEVER processing magic you want with form_set_value(). Cool! Thanks all.

EDIT: here's what the callback looks like. Also note that for some reason someone took out my fields in my original question. But these field names would make more sense if someone didn't do that.

function MODULE_my_custom_submit_handler($form, &$form_state) {
  $lang = $form['language']['#value'];

  $a = $form_state['values']['field_fruit_collection'][$lang][0]['field_watermelon']['und'][0]['value'];
  $b = $form_state['values']['field_fruit_collection'][$lang][0]['field_apples']['und'][0]['value'];

  $sum = $a + $b;
  form_set_value($form['field_total_fruit'][$lang][0]['value'], $sum, $form_state);
}


With @4k4's help I managed to find the root cause of my issue and fix it.

I was wrongfully assuming that the $form elements could be somehow modified in an AJAX call to produce my desired effect.

While it is true that the elements could be modified and re-rendered in an AJAX response, that is not the correct way to alter a form after an AJAX call.

The 2 main things to know are:

forms are rebuilt everytime an AJAX call is made (when it is declared in the #ajax array of the form element triggering the call)
the AJAX function being called should (ideally) only return the element suffering modifications. It cannot modify the $form in any way, otherwise those modification will either be lost when it is rebuilt, or trigger the An illegal choice has been detected. Please contact the site administrator. message.

This being said, the general flow for this should be:

create the buildForm function with code that builds both your select elements. Wrap in a conditional clause code that tests if the parent select was already changed or not. This will be used to determine if the nested select should be populated or not;
set an #ajax property in the parent select element of the form, referring a callback to be used;
define the callback to return only the element which needs to change in the form, ie, the nested select;
when Drupal tries to rebuild the form, your parent select will already have a value that can be used in the above mentioned test-clause to allow for population of the nested callback.

@4k4's suggested documentation was difficult for me to find, but clear enough to follow trough once found - link here. (Even though it is for Drupal 7, in Drupal 8 it functioned exactly the same way).


How to add images (as entity) in ckeditor?

I would take a look at something like Shortcode module. In general you are looking to insert a token for your image entity.


If you know that this list won't grow more than few dozens of nodes (you have to make some tests with more items) I'd just avoid loading complete nodes - it's unnecessary if you need only the title.
This call might become a significant database hit (=> page will load slower and will slow down other visitors of the site) when you add more nodes to the site.
When you call node_load(), Drupal builds the complete node object, meaning it looks for all additional fields you added, settings and calls corresponding node hooks from other modules. Avoid calling it for small details whenever you can.

Here's what you could use instead:

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

  if($form_id == 'views_exposed_form'){

      $nodes = db_select('node', 'n')
        ->fields('n', array('title'))
        ->condition('type', 'news')
        ->orderBy('n.title', 'ASC')
        ->execute();
      $dropdown_array = array('' => t('-- Any --'));
      foreach ($nodes as $node) {
        $dropdown_array[$node->title] = $node->title;
      }

      // Alter form
      $form['title'] = array(
         '#type' => 'select',
         '#default_value' => '1',
         '#options' => $dropdown_array,
      );

   }//endif

}

Check out also Chosen module for Drupal - it will allow you to have a much nicer select form element than the default one. It's pretty straightforward to install.
You can see a demo here.


Omega theme not rendering correctly when css aggregation is disabled

Can be because it needs polyfills which are only loaded with aggregation turned on.

Try with a CSS3 standards compliant browser (ie. latest version of Chrome) which would not need the polyfills at all.

Omega 4 comes with these polyfills:

Selectivizr.js
CSS3 Media Queries JS
Respond.js
CSS3 PIE
HTML5 shiv


How to add content of nested terms to Taxonomy term View

Finally found the answer and it is almost the same than for D7:

Edit the existing view Taxonomy Term (admin/structure/views/view/taxonomy_term/edit)
In Advanced, add the field Content: Has taxonomy term ID (with depth) using all the settings from already added Content: Has taxonomy term ID using the same settings. You can limit the depth by setting the depth parameter.
Remove old field Content: Has taxonomy term ID using the same settings
Set Use aggregation to yes to avoid duplicates


Reusing existing content types for very similar content

Nodes are a generic entity, with each bundle (content type) being it's own type (ie - a means of transport). This is too generalized. As such, I would say that this is a case for a custom entity, rather than nodes. Your custom entity would be means of transport. You would then create base fields on the entity type for the fields common to each means of transport. You would then create bundles (which for nodes, are known as 'content types') for each separate means of transport (car, plane, bicycle etc) and add means-specific fields to the bundle.


Entity form in ctools modal popup, whilst passing in values from current node

If anyone's interested in the answer, I just appended ?nid=5 to the end of the link url. Then I could just hook_form_alter to get the nid:

if($form['#id'] == 'whatever-entityform-edit-form'){

        $nid = $_GET['nid'];
        $node = node_load($nid);

        $form['field_whatever'][LANGUAGE_NONE][0]['target_id']['#default_value'] = "$node->title ($node->nid)";

    }

Might not be the best way, but it works.


The bad news is that having inspected the code, the form alter layer is the only place to really do this; your approach is pretty much spot on.

The good news is, Drupal implements all sorts of static caching throughout the page load, which minimises the need to go back into the database. So while altering the content table may appear cumbersome, you're not actually taking a noticeable performance hit.

The following code (or similar) should work; see the comments for more info about the caching issue:

function MYMODULE_form_node_admin_content_alter(&$form, &$form_state, $form_id) {
  // Load the nodes. This incurrs very little overhead as
  // "$nodes = node_load_multiple($nids);" has already been run on these
  // nids in node_admin_nodes(). The static cache will be used instead of
  // another db query being invoked
  $nodes = node_load_multiple(array_keys($form['admin']['nodes']['#options']));

  // Grab a list of all user ids that have been responsible for changing the node
  $uids = array();
  foreach ($nodes as $node) {
    $uids[] = $node->changed_by;
  }

  // Filter out duplicates (one user may have been the last to change more than one node)
  $uids = array_unique($uids);

  // Load a list of all involved users in one go. This is about as performant
  // as this is going to get, as you're going to need the user objects one
  // way or the other for the call to theme_username
  $users = user_load_multiple($uids);

  // Add another column to the table header
  $form['admin']['nodes']['#header']['changed_by'] = array('data' => t('Changed by'));

  // Loop through the rows in the table and add the changed by column
  foreach ($form['admin']['nodes']['#options'] as $nid => $row) {
    // Grab the user related to this node.
    $this_user = $users[$nodes[$nid]->changed_by];

    // Add data for the new column
    $form['admin']['nodes']['#options'][$nid]['changed_by'] = theme('username', array('account' => $this_user));
  }
}

The above code produces a nice shiny new column like this on the content admin page:


If the number of group types is relatively small and consistent, you might consider adding several taxonomy term fields to the base groupcontenttype, each referencing the relevant grouptype specific vocabulary, and then hiding the fields that are not relevant to a group's type.

If you hid the field on the node edit page using a switch statement (on group type) in hook_form_alter, then ensured that empty fields were not displayed on the node, then both visitor and admin would not see irrelevant fields.


Programmatically Add Features for Role assignment in Ubercart Drupal 7 product node

Don't do that. Inserting into the DB directly can cause you problems down the road; there's already been code written to do what you're trying to do.

Look at the uc_roles functions/documentation and follow how it adds product features via uc_roles_feature_form_submit submission handler and its uc_product_feature_save() call.


How would I wrap (or hard-code) HTML into a block title?

You can hard code in block template: "Drupal 7 Template Suggestions", so determine what module/delta/region appropriate for you.
Other way is using theme preprocessor.


How to enable insert module in installation profile?

You can enable insert by updating the field instance settings with these two core functions:

field_info_instance
field_update_instance

for example:

/**
 * Enable insert field settings
 */
function MODULE_field_settings_enable_insert($entity_type, $field_name, $bundle){
  // Load field instance
  $instance = field_info_instance($entity_type, $field_name, $bundle);
  // Build insert settings array, these image styles are just examples
  $insert_settings = array(
    'insert' => 1,
    'insert_absolute' => 1,
    'insert_styles' =>
    array (
      'image_236w' => 'image_236w',
      'image_237x147' => 'image_237x147',
      'image_486w' => 'image_486w',
      'colorbox__236w' => 'colorbox__236w',
      'colorbox__237x147' => 'colorbox__237x147',
      'colorbox__486w' => 'colorbox__486w',
      'auto' => 0,
      'link' => 0,
      'icon_link' => 0,
      'image' => 0,
      'image_60x60' => 0,
      'image_62x62' => 0,
      'image_62x82' => 0,
      'image_67x67' => 0,
      'image_69x52' => 0,
      'image_71x44' => 0,
      'image_71x71' => 0,
    ),
    'insert_default' => 'image_237x147',
    'insert_class' => 'caption',
  );
  // Add the insert settings to the field instance widget settings
  foreach($insert_settings as $key => $setting){
    $instance['widget']['settings'][$key] = $setting;
  }
  // Save the field instance
  field_update_instance($instance);
}

// Then you can enable insert on a field instance with
MODULE_field_settings_enable_insert('node', 'field_images', 'article')


How to hide comments below the node, but not close them?

In modules/comment/comment.module we can see that hook_node_view() (comment_node_view()) is running on line 614. This is where the functions are firing to load all comments and attach them to the node. The first 2 sets of if () { ... } appear to be handling the add comment form and action link. Then the final block of code is finally adding the comments, which I believe is what you're actually most concerned about hiding, and I assume you want this skipped for performance reasons:

// Only append comments when we are building a node on its own node detail
// page. We compare $node and $page_node to ensure that comments are not
// appended to other nodes shown on the page, for example a node_reference
// displayed in 'full' view mode within another node.
if ($node->comment && $view_mode == 'full' && node_is_page($node) && empty($node->in_preview)) {
  $node->content['comments'] = comment_node_page_additions($node);
}

I think this code is silly, because comment module should not be dependent on any particular hardcoded view mode. Hopefully this will change and become a setting in the UI.

Regardless, I've found a similar post that might interest you: Is there a way to stop comment_node_view from firing?

Basically you're wanting to use hook_module_implements_alter() to stop the comment module from being able to fire off hook_node_view(). Here is what you need to add to your custom module:

function hook_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'node_view') {
    unset($implementations['comment']);
  }
}


How do I alter the text of the input field in the search form?

@NoSssweat has provided a link, it is the answer if you want to alter a placeholder.

But reading your question I am getting other indications also.

FOR D7:

Case-1: If I read the sentence from your question "I need to alter the text of the search input field" I think you are talking about the placeholder, Now what is placeholder- you can see in following image the word "Search the site" in the text-area is called place-holder.

Case-2: But if I read your last sentence, "Is $form['search_block_form']['#title'] = ''; the right thing to do here?" then it talks about other things, this is corrosponds to Text appear when you hover on the input text-area("Enter the terms you wish to search for") as shown in following image.

I will explain both of that, The best tutorial for this is available here: How to Customize the Block Search Form.

Case-1 Paste the following code in your theme's template.php file, change the YourThemeName with your actual theme-name, save & clear the cache.

function YourThemeName_form_search_block_form_alter(&$form, &$form_state, $form_id) {
    $form['search_block_form']['#attributes']['placeholder'] = t('Search the site');
}

Case-2

function YourThemeName_form_search_block_form_alter(&$form, &$form_state, $form_id) {
    $form['search_block_form']['#attributes']['title'] = t('Place a new sentence');
}

Case-3: If you want title on the block, you can just go to block configuration and put the title whatever you want, it will appear as a title of the Block.

FOR D8: as @NoSssweat pointed out in the following comment, how to do in D8. Hence, I am just repeating that comment here as it is needed.

function YourThemeNAme_form_search_block_form_alter(&$form, FormStateInterface $form_state) {
  $form['keys']['#attributes']['placeholder'] = t('The new placeholder');
}


How can create a block that get a field value and render it?

If you use setConfigurationValue(), put the value as parameter in the function:

$this->setConfigurationValue('default_LinkA_url', $form_state->getValue('block_LinkA_url'));

Or better set the value in the configuration array like this:

$this->configuration['default_LinkA_url'] = $form_state->getValue('block_LinkA_url');

To display the url use the render element link:

https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!Element!Link.php/class/Link/8.2.x


There are many ways to add scripts to an existing page, one option is:

/**
 * Implements hook_init().
 */
mymodule_init() {
  if ($some_condition) {
    drupal_add_js(drupal_get_path('module', 'mymodule') . '/mymodule.js');
  }
}

hook_menu() probably isn't going to help you here, because each menu router item can only have one page callback.


How to make a Custom Field available as View Relationship?

I'm trying to have a filter that shows content where the name of
  logged in user is equal to the value of custom field.

Add your custom field as a Contextual Filter.

Select Provide a default value then for Type select PHP Code

PHP Contextual Filter Code

  global $user; // gets current logged in user object

  if (isset($user->name)) {
     return $user->name; // gets user name
  }


Dynamically adjust argument or filter to views entity reference filter based on value from select list in form

The simplest answer ended up being to use Entity Reference View Widget which allowed me to build a view for selecting the entity desired.  This was nice because it allowed me to add some additional information and filtering the the approach I was hoping for in my question didn't allow.  Unfortunately, it also moves me further from being able to update this site to Drupal 8 because this module doesn't exist for Drupal 8 because the maintainer decided to let another module that isn't released yet, cover this functionality for Drupal 8.  I would still welcome answers about how to do this in a more forward compatible way.


The ThemeKey module is definitely the way to go for this. Here is a quote about it (from the module's project page):

... allows you to define simple or sophisticated theme-switching rules which allow automatic selection of a theme depending on current path, taxonomy terms, language, node-type, and many, many other properties. It can also be easily extended to support additional properties exposed by other modules. In combination with Drupal's theme inheritance you can easily achieve features like:

individually-styled channels
a front-page / "splash" screen
a date/time-selected Christmas theme
mobile themes for different auto-detected mobile devices
special themes for "limited" or "old" browsers
content, user, or role -specific themes
indicating your environment (production, staging, testing, sandbox, … )
testing your redesign safely on a live server


You need to set the new value on the body, and save it.

function MYMODULE_node_presave(Drupal\Core\Entity\EntityInterface $node) {
  if ($node->bundle() == 'article') {
    $body = $node->get('body')->value;
    $token = Drupal::token();
    $body = $token->replace($body);
    $node->get('body')->value = $body;
    $node->save();
  }
}


Why is session.cookie_lifetime set to 23 days?

ini_set('session.gc_maxlifetime', 200000);

This value is for the server.
It is a settings for Session Garbage Collection.
If the users last visit happened before 200000s then this session is eligible for garbage collection.
Since it is GC, the session value may be discarded and not compulsory. If a GC action happens after the session was made eligible for the GC, it will be deleted.

ini_set('session.cookie_lifetime', 2000000);

This value is for the browser.
This is the absolute maximum time till which a browser can keep this cookie active.
A 0 value here means immediate or when the browser is closed.

To answer your question in particular.

If the user doesn't hit the server back in 2.3 days, his session will be deleted when the session garbage collection runs.
If he keeps on hitting one page on the server every 2.2 (less than 2.3 days) then his session will stay active. But it can be active only until 23 days from the time the session was first generated.
So what that means is session.cookie_lifetime is the absolute maximum lifetime of a session.


How to parse PHP variables in drupal_add_js in template.php

Just remove the print function from your code:

drupal_add_js('jQuery(document).ready(function () { alert(" '. $site_name .' "); });',
  array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)
);

Looking at the javascript Window alert() Method it has this syntax:

  alert(message)

And the message parameter has the type string

PHP's print function prints to the output buffer and returns an int. It has this definition:

  int print ( string $arg )

So your code prints the variable $site_name to the output buffer and returns an int, and your string for the alert is then an integer and you have printed to the output buffer which you did not want to do.


Cannot hide Superfish sub menu on active pages

It's both. The active trail stuff has always been, and still is, a big mess, and Superfish herited the problems. You can check this thread for some information about it, but it remains unclear.


How can I list the current user's posts?

You can use 'filter by current user' in the Views module.


Deleting field revisions directly from the database

There was a module in 7 that tried to solve this, Field SQL No Revisions. I am not sure how far along a Drupal 8 port is, but this is where you might want to start. However, that module keeps those tables empty, instead of just the 'latest' record.

Previously (7.x), I used to have hook_cron routines that would purge revision tables of any old data not being used to keep size down. We had some DBs that were huge due to that, which made backups and dev syncing take forever and be cumbersome. It really helped. You'll want to be careful and use the respective API over a database query, so the rest of Drupal is informed about what is happening and can take action (or if your site has no dependencies it might not matter, but it is always, always safer).


Display Location of node Title different in Teaser vs Full

Just a thought, have you tried using Display Suite?


You can check out Field group module. It allows you organize the fields with different transitions.


How do you print the view name on a "view page"?

This should normally just work. What do you mean by "custom template", did you make a .tpl.php file? What .tpl.php did you use?


Show external mysql database data in webform field

It seems you need Webform Views Select module.
But it works for D7 only.


Node Permission base on per Taxonomy Term

I think TAC can provide this functionality.

Here's a screen shot of the TAC config.

http://cl.ly/image/1f1Z433r0y1s


set min - max values drupal date_popup timepicker

You may find this one helpful.

Datepicker: minDate and maxDate


How can i integrate geofield module in entityform?

i got a better way to do this the thing i wanted was to create integrate multiple locations in one Maps and display the route.. I created this using a HTML file using HTML,CSS, JavaScript and using Markup module i integrated my code in my Entityform. I is working like a charm.


Settings vs Code: Can I turn off Broadcast Message through settings?

Well, I can do this via hook_menu_alter():

if (variable_get('custom_no_broadcast', true)) {
  unset($items['node/%/broadcast']);
}

And in I take the link out via hook_preprocess_block():

// If set, attempts to surpess the link to broadcast messages to all group members.
if (variable_get('custom_no_broadcast', true)) {
    $variables['block']->content  = preg_replace("/<a\shref=\"\/node\/\d+\/broadcast\">Broadcast message<\/a>/", '', $variables['block']->
}

Or just turn off the Commons Notifications module.


if you use one.com

I just find out, that you can remove or commenting

Options -IndexesOptions
Options +FollowSymlinks

in the htaccess file, and then it should work. I don't know why.


Put blocks, views, etc in git for other developers

You have several modules that allow to export configuration changes (like views, blocks, content types etc) into code. One is features and the other is configuration Features is much more heavily used and configuration isn't supported by the security team, so I tend to use Features. There are a number of good tutorials on using Features, like this one. Once you create a feature, it will exported into a code-based collection of files under custom modules, which you can then share with git.

The one caveat is that using Features (or any config changes module for that matter) in a collaborative environment can become tricky: team members have to be mindful of the branches and feature versions they are working with. For example, switching from a branch where feature was installed to a branch that does not have that feature can throw fatal errors because GIT will remove the feature files according to the branch but the database will still look for the feature. In such a case you can disable the feature before switching branches or install the feature in all the branches you are working in.


As a workaround, i ended up using the views rules module at drupal.org/project/views_rules  which "Provides Views directly as Rules actions and loops to seamlessly use view result data."


Modify custom search box added in page.tpl.php

I have finally resolved this one using a jquery which I have applied
to the element using JS Injector Module.

jQuery(document).ready(function($) {
  $('#edit-keys').attr('size', '20');
  $('#edit-keys--2').attr('size', '20');
});


Disable a Module after Fatal Error without Server/DB access?

Without access to the server, files or database?

No, there's nothing you can do.

It's the database you need to update, and if you can't get to that externally or locally to run some SQL, you're out of luck.

You could theoretically alter some code somewhere in core to bypass the issue of the broken module, but of course that would require access to the files, at which point you could've just run the SQL via PHP.


1 - you can create file page--front.tpl.php in theme dir and you can
  hide the title .

<?php print render($title_prefix); ?>
  <?php if ($title): ?>

 <?php endif; ?>
  <?php print render($title_suffix); ?>

  2 - you can use css Rule to hide this title

  3- you can use hook_page_alter or hook_preprocess_page
     add this code

if (drupal_is_front_page()) { drupal_set_title('');}


Drupal Commerce: Print order for warehouse

You will want to use the Commerce Message module: https://www.drupal.org/project/commerce_message

This module provides a !order-summary token which embeds an order's line item summary. This token only works, however, if the Message bundle has the message_commerce_order field.

You can either programmatically add this to a new Message bundle. Or, the easy route, clone the default admin notification and adjust as needed!


'image_style' entity with ID 'media_library' already exists

I was able to fix this by doing the following:

Removing the media_libary (I'm using git but if not you can move it somewhere):

rm image.style.media_library.yml
rm views.view.media_library.yml

Run configuration import:

drush cim -y

Now run database update:

drush updb -y

Now add the removed config items back in:

git checkout ./

Run configuration import again:

drush cim -y

Now you should be all set.


Open link as modal form or normal form based on user role

You can look at Menu per Role module, ie link to login form for anonymous users, and link to normal form for authenticated users. another alternative would be to add a hook into the menu in your custom module and change your link based on user's status that way. You can look at this post for info and examples.


How do I re-queue a test that has been postponed on Drupal.org?

You can post an issue to the drupal.org testbots project issue queue and get someone to look into it.


How to send E-mail and SMS notifications when one user outbid another user in drupal 7?

I would look at the Message module

  The Message module is the core of the message stack. It enables logging and displaying system events in a number of different use cases. Events that are recorded over time are sometimes call activity streams. Exportable messages subtypes can be created for different use cases with custom fields and display (view) modes.


How to programmatically save a value in a long text with summary field?

You forget the # in the #format, use this:

$form['field_name'][LANGUAGE_NONE][0]['#format'] = 'full_html';
$form['field_name'][LANGUAGE_NONE][0]['#format'] = 'filtered_html';

Read this: How to set the default format per content type at Drupal 7?


How to perform bulk operations on a view when the view is displayed but without the need to select rows?

To "trigger the execution of certain Rules when visiting the view page" (as in your question), is something you can do by using a special feature of the Rules module, i.e. a technique that is similar to what is described in the answer to "How to execute VBO list of nodes in Rules on After updating an existing user account event?". Read on for more details about the steps to be completed, specific to your question here.

Create a custom Rules that will execute the VBO list that you already have, and which looks similar to this example (which was used to process a VBO view of unread messages, with a path like user/%/messages/unread):

{ "rules_mark_all_unread_messages_read" : {
    "LABEL" : "Mark all unread messages read",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "views_bulk_operations" ],
    "ON" : { "init" : [] },
    "IF" : [
      { "text_matches" : {
          "text" : [ "site:current-page:url" ],
          "match" : "user\/\\d+\/messages\/unread",
          "operation" : "regex"
        }
      }
    ],
    "DO" : [
      { "views_bulk_operations_action_load_list" : {
          "USING" : { "view" : "messages_by_user|page_3" },
          "PROVIDE" : { "entity_list" : { "unread_msgs_list" : "A list of unread messages" } }
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "unread-msgs-list" ] },
          "ITEM" : { "current_msg" : "Current message" },
          "DO" : [
            { "component_rules_flag_a_message" : { "message_to_flag" : [ "current-msg" ] } },
            { "drupal_message" : { "message" : "The message with ID [current-msg:mid] (created [current-msg:timestamp]) was marked as read." } }
          ]
        }
      }
    ]
  }
}

Some more details about the rule above:

Rules Event: Drupal is initializing
Rules Condition: Check if the path being visited is user/%/messages/unread (adapt this path to use your path).
Rules Actions:

Create a list of unflagged messages (replace this list by your VBO list).
Loop over each of the unflagged messages found, and flag those messages (replace this action by the "execution of certain rules", as in your question).

This rule also performs an extra "set message" action, so that you can see what it does if you want to try it in your own site (it shows a message for each entry in the list). Remove that message after QA-testing if you want.

That's it, works like a charm!


how rename series legend in chart created by views

Finally I can find the answer, after keep on trying:
I have to switch to custom label. Just change to custom label in the field.


Change database column type in hook_update_N

In basic terms you just need to call db_change_field() in your update function, with the spec for the new field:

function MYMOUDLE_update_7001(&$sandbox) {
  // Create the definition for the field
  $new_field = array(
    'type' => 'decimal',
    'precision' => 16,
    'scale' => 2,
    'not null' => TRUE,
    // etc...
  );

  db_change_field('table_name', 'field_name', 'field_name', $new_field);
}

If your field is a primary key/part of an index, you'll need to manually drop those indicies and recreate them (see the documentation page for a more detailed explanation).


Can I Search an entity reference with search api db?

SearchAPI does have this limitation: Note: This is a multi-valued relationship, which is currently not supported. Only the first related entity will be shown.

Here is the issue about this. https://www.drupal.org/node/1378656


Get id of selected option in Drupal Forms API

You can use this code

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"),
        ),
        '#default_value' => 0,
        '#ajax' => array(
            'callback' => 'myid_print_all_submitted_id_callback',
            'wrapper' => 'myid_print_search_idnumber_wrapper',
        ),
    );

    $form['myid_print_search_idnumber_wrapper'] = array(
       '#type' => 'item',
    // When the form is rebuilt during ajax processing, the $selected variable
    // will now have the new value and so the options will change.
       '#markup' => isset($form_state['values']['options']) ? $form_state['values']['options'] : '',
       '#prefix' => '
',
       '#suffix' => '
',
    );
    return $form;
}
function myid_print_all_submitted_id_callback($form, $form_state){
// rebuild the form
    return $form['myid_print_search_idnumber_wrapper'];
}


Which version of Behat (Guzzle) would be okay to use on a RHEL server with PHP 5.4?

Call to undefined function GuzzleHttp\Handler\curl_reset()

Means PHP is trying to find the function curl_reset() in the namespace GuzzleHttp\Handler.

It does that because it can't find it in the global namespace (where it should be). curl_reset() was only introduced in PHP 5.5, and you have version 5.4, so your version just isn't compatible with Guzzle 5.

Guzzle isn't explicitly listed as a dependency in the Behat extension's composer.json file, so one of the other libraries must depend on it. I'm not sure it would even be worth the time trying to unpick that, upgrading php would be much quicker.


How to translate only the interface back to English?

There is a module for that: Administration Language.

This module lets the administrator see all administration pages in his/her preferred language.
You can use this to display the frontend of the site in one language and still keep most of the backend in English (or another language of your choice).
You can use the standard Languages page to choose the language of the admin pages.


Add field formatter settings to all field formats

I've managed to work this out.

hook_field_formatter_info_alter() isn't properly implemented in Drupal 7. There is however the field_formatter_settings module which exposes two hooks:

hook_field_formatter_settings_form_alter()
hook_field_formatter_settings_summary_alter()

https://drupal.org/project/field_formatter_settings

Using the dependent modules (e.g. field_delimiter) as examples I was able to achieve what I needed.


How to invalidate a views cache based on custom criteria?

It sounds like the problem is not views being cached, but that the entire page is being cached. If Drupal have a complete page cached, it doesn't matter if the view is cached or not. What you need to do, it to conditionally disable the page cache, or prevent Drupal caching that page in the first place.

There have been some talk about how to do the first, but this is not something I have tested or can advise.

Be warned, that messing with the Drupal caching system can give some unforeseen problems.

An alternative solution would be to empty the page cache or invalidate the cache for that particular page once a day/hour to make sure that it's relatively up to date. This is probably the route I would take in this situation.


Altering display mode for authoring information

As you prefer css, checkout the module Field Formatter CSS Class

  The Field formatter CSS class module allows you to set any
  text/list/option/taxonomy field to render as CSS class on the node.
  This enables the node author to select predefined CSS styling per
  node.

Also Field Formatter Class

  This module allows site administrators to add classes to the outer
  HTML wrapper for any field display.

Then you can hide your info with css based on this unique class provided by either of these two modules


What to do for "Login attempt failed for admin." and "Access denied" to path admin?

As an option you can rename path to login page, you can try Rename Admin Paths module to do it.


Search Drupal from an external application

Drupal searches can just be normal GET requests w/o going through the form.  Try it.

Make a page in your RoR app to catch the POST and parse the search needle.  Then 302 to the Drupal site with the proper URL.


You can override the block.html.twig template and handle the translation of the title directly on the template:

    {{ label|t }}

You may need to confirm the title structure (if is #markup or plain text/string)


Creating Primary Sub menu's programmatically

You could use the menu views module:

  What Menu Views Does

  Menu Views is a utility module. It provides back
  end support for replacing a standard menu item link with a menu item
  view. Menu items (in any menu) now have the option of toggling between
  two different menu item types: link or view. Depending on which option
  is selected, the appropriate configuration form is displayed on the
  admin side and the appropriate type of item is rendered on the
  front-end.

Once you create a submenu, you can attach a view to it. Your title suggests you're asking to do this programmatically. From what i know, i'm not totally sure if that's possible without a lot of headache.


Looking for the right modules for user group management

I would suggest to manage this by using roles.
Create two different roles: Buyer and Seller
As both roles have the same mandatory fields, it wont be an issue for you. Additionally, you can customise additional fields and rights for sellers.


display list of pages of content type using views + edit and delete option

I got the solution by installing Admin VBO Views module


Add help text to checkbox options on node form

I tried to do this first by overriding checkboxes theme hook theme_checkboxes($var) with preprocess hook template_preprocess_checkboxes($var) but there was not any option to set #suffix property to individual checkbox, Then i figured out that theme_checkboxes theme hook call the theme_checkbox hook for individual checkbox then i tried to override theme_checkbox($var) with template_preprocess_checkbox($var) but that also didn't worked, I was able to set #suffix and #field_suffix property on individual checkbox but that was not rendering because individual checkbox's #processed property was already set to True, I tried by setting that false but no success :(

I tried by setting pre_render callback and process callback but too didn't worked, May be i was making some mistake.

This is preprocess hook for checkboxes theme hook:

function template_preprocess_checkboxes($variables) {
  $variables['element']['element_name']['#printed'] = FALSE;
  $variables['element']['element_name']['#processed'] = FALSE;
  $variables['element']['element_name']['#suffix'] = 'This is help text';
  $variables['element']['element_name']['#pre_render'][] = 'mymodule_checkbox';

  $element = $variables['element'];
  $attributes = array();
  if (isset($element['#id'])) {
    $attributes['id'] = $element['#id'];
  }
  $attributes['class'][] = 'form-checkboxes';
  if (!empty($element['#attributes']['class'])) {
    $attributes['class'] = array_merge($attributes['class'], $element['#attributes']['class']);
  }
  if (isset($element['#attributes']['title'])) {
    $attributes['title'] = $element['#attributes']['title'];
  }
  return '<div' . drupal_attributes($attributes) . '>' . (!empty($element['#children']) ? $element['#children'] : '') . '</div>';
}

function mymodule_checkbox($var){
  $var['element']['#suffix'] = 'this is help text added by pre render callback';
}

Then i tried the same with template_preprocess_checkbox($var)

function template_preprocess_checkbox($variables) {
  $element = $variables['element'];
  $element['#attributes']['type'] = 'checkbox';

  element_set_attributes($element, array('id', 'name', '#return_value' => 'value'));

  if ($variables['element']['#parents'][0] == 'parent_field_name') {
    $variables['element']['#attributes']['#processed'] = FALSE;
    $variables['element']['#attributes']['#field_suffix'] = t('This is simple help text');
    $variables['element']['#suffix'] = 'another suffix';
  }

  // Unchecked checkbox has #value of integer 0.
  if (!empty($element['#checked'])) {
    $element['#attributes']['checked'] = 'checked';
  }
  _form_set_class($element, array('form-checkbox'));

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

Can someone help me too on this?


That's (arguably) non-standard, so you'll need a where.

For example,

$query = db_select('foo');
$query->where(':val IN ({table1}.col1, {table2}.col2)', array(':val' => $user->uid));

will get you

SELECT
FROM
{foo} foo
WHERE  (:val IN ({table1}.col1, {table2}.col2))

(with :val replaced by $user->uid).


Display users created only by the current user in Admin/People

Are you aware of the Subuser module? It appears to be capable of doing exactly what you want.

  This module allows users to be given the permission to create
  subusers. The subusers may then be automatically assigned a role or
  roles. The parent of the subusers then has the ability to manager the
  users they have created.


Is it possible to show contents in a specific sites for multilingual site?

Go to en/admin/config/regional/language/configure and make sure URL is at the top. Press configure and select Domain. There you go.


Get node values from array with Drupal API?

If it is for page view of some kind, I think you can maybe try for this more robust way of getting at field values:

$output = field_view_field('node', $node, 'field_name');

An important trick that shows one of the ways to deal with field data properly. Initially  learned a while back off this site.

Another method of getting at the data I just thought of and use quite a bit in a recent project is entity api. Highly recommended add-on.
Consider the following borrowed snippet that shows how to deal with mail field. Other fields are the same.

   $wrapper = entity_metadata_wrapper('node', $node);
   $wrapper->author->mail->value();

To update the user's mail address one could use

   $wrapper->author->mail->set('stefp@example.com');

   or

   $wrapper->author->mail = 'stef@example.com';

Last but not least, there are still yet other alternatives surely?

Best practice for language key for "und" in hook_form_alter.  I did not flag as duplicate as I did not check into detail if other question was detailed or not, but it should be enough to give you ideas.

Good-luck.


How can I use Composer with no Internet access?

I personnaly don't like to commit vendor dependencies. It makes the code review more complicated before a merge request cause the files you need to review are lost in the middle of an ocean of files you don't need to review.
In your case I would have a CI job which would be run on release branches and would exec composer install then generate a .tar.gz file containing all the files (including /vendor). That CI job would then push the .tar.gz on a repository manager like Nexus. And finally a deploy job in Jenkins would get the last hosted release on the repository manager, push it to the final host, untar it and run drush commands to update the site.


Repeated elements in translations of a block view

You have to add a filter:

FILTER CRITERIA

Taxonomy Term: Translation language (= Content language selected for page)

or if the content language is not available when configuring the filter:

Taxonomy Term: Translation language (= Interface text language selected for page)

Otherwise you get a row for each translation, which are then all rendered in the same language, the one of the page, because you have configured this in the section Language in the middle column of the View.


How to get an image url given term_image_tid using the customfield-PHP views module

You shouldn't use a PHP code field, rather you can use the Image URL formatter module to create a image URL field, exclude it from display, & then use that image URL field to feed into a Global: Custom text field with your own custom img & a markup.


How to get CSS to target new nodes being inserted?

I'm not sure I get the scenario.
What if you apply your css to both old and new classes?

Example

.old_nodes .content, .new_nodes .content {
   color:red;
}

This will give same style to both new and old nodes.


If you wanna see all variables available in your twig template file in Drupal 8 use {{ kint(_context) }}. Don't forget, you must enable kint in devel module settings.


First - ajax callback should not make any persistent changes to $form. It's only duty is to return proper part of form array. Render all elements in form creation function:

mymodule_form($form, &$form_state) {
  $form['image'] = array (
    '#type' => 'fieldset',
    '#title' => t('images'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#prefix' => '
',
    '#suffix' => '
',
  );
  if (empty($form_state['image']['count'])) {
    // Keep number of fields either in form or form state, both works.
    $form_state['image']['count'] = 4; // Default number of elements
  }
  elseif( isset($form_state['triggering_element'])
      and $form_state['triggering_element']['#machine_name'] == 'more_images_button' ) {
    // If form was triggered by proper form element, increase counter
    $form_state['image']['count']++;
  }
  // Loop to create elements
  for ($i = 0; $i < $form_state['image']['count']; $i++)
  {
    $form['image'][$i] = array (
      '#markup' => "
$i
",
    );
  }
  // And our button
  $form['image']['more'] = array (
    '#type' => 'button',
    '#value' => t('More'),
    '#ajax' => array (
      'callback' => 'product_more_images',
      'wrapper' => 'product_images',
      'method' => 'replace',
      'effect' => 'fade',
      'prevent' => 'submit',
    ),
    '#machine_name' => 'more_images_button',
  );
}

// Now callback function is trivial
function product_more_images($form, $form_state) {
  return $form['image'];
}

Of course it's only a sketch, with all off topic parts removed.


How do you migrate a site with Drupal 7 Image Styles and make sure the adjusted images migrate?

Turns out I was trying to run deployment with my files directory outside of the Drupal root, and even though I was relatively pointing to the right path, it just didn't like that. So I symlinked sites/default/files to the folder outside of the Drupal root and it works fine now.


It is probably because you do not have a setting for the super user (user/1). You need to set the account user name and password, so you can login to Drupal.

drush site-install standard --account-name=admin --account-pass=12345 --db-url=mysql://dbusername:dbpass@localhost/db_name --site-name=Example


How to group results by multiple fields?

In D7 - you can achieve your grouping structure in Views with the help of the Views Merge Rows module.

You'd use the option "Use values of this field as a filter" for the field that produces x & y. And for the file name field you'd use the option "Merge unique values of this field".


How to alter the state of a radio button in an exposed filter to "checked" based on the view URL?

You will need to use 2 contextual filters as each one takes a different argument, for example www.mysite.com/filter1/filter2.

You're confusing the difference between exposed filters and contextual filters, and their behaviour. An exposed filter is form based. As you want a radio button,  that's perfect. However, an exposed filter passes its values either via POST or GET; the only way to get these values through the URL is via the query string.


How can I remove "please wait..." from a form?

this can be done in css:

.fivestar-widget .ajax-progress
{
    display:none;
}


There's some hyphenation library on your page. That's no default Drupal behavior. Find that library and remove it or make it ignore your body fields. Probably some JS library.

OP found hyphenator.js inside MYTHEME/vendor/hyphenator.js.

To remove the library, find out where it got added to the site. drupal_add_js() in D7, or some MYTHEME.libraries.yml library declaration in D8. Or just from the theme's info file.

I'd recommend to fix the hyphenation and simply exclude it for certain fields. This probably can be done with only a few lines of custom JS. Find out how by visiting the docs of that library from the link above.


db_query() to retrieve the image path using the fid

There is no need for manual queries.

You can load a file using file_load($fid), and then the path is in $file->uri. It might look a bit stringe ('public://something.jpg'), but that's a so called stream wrapper, and it works just fine with plain PHP file functions.

It's not exactly clear to me what you are trying to achieve; if you want to render an image field from a node/user/..., there are better ways to embed title and things like that, but this would work if you really just have a field. (That you are trying to query the field data table suggests otherwise, though.)

<?php
  $file = file_load($fid);
  $variables = array(
    'path' => $file->uri,
    'style_name' => 'your_style_name',
  );
  print theme('image_style', $variables);
?>


How to use Entityfieldquery with two field conditions for the same field

You should be able to use db_or(), something like this:

$or = db_or()
  ->fieldCondition($field_example, 'tid', (array) $var1)
  ->fieldCondition($field_example, 'tid', (array) $var2);
$query->condition($or);

More info here.


Why does form ID get displayed to drupal_set_message?

You may be having hook_form_alter(&$form,&$form_state,$form_id) in your code
possible code in your custom code will be

function hook_form_alter(&$form,&$form_state,$form_id) {
//just remove the below line to disable the message
drupal_set_message($form_id);

}


Drupal 6.19 - cannot add node links to primary-links

Issue solved.

Looks like that with the large menu tree, Mysql packet size was exceeded.

I just added the following to mysql config (my.ini) and the issue resolved:

[mysqld]
max_allowed_packet = 16M


Adding DIV ID= Tags to a views table output

Btw, I ended up using a rewrite in the views UI.
I added "content:nid" to the top of the fields and then used "rewrite content" on the title field to:

[title]

Not a perfect solution but it seemed practical to me (at least at the time of writing this) ;-)


Is there a way to edit views fields in place?

Try editablefields-d7; as reported by the project page the module is a Drupal 7 port of editable fields.
The project is a sandbox project, which means it doesn't support releases, yet, and drupal.org doesn't automatically create the archive containing the module code; this means the code should be considered experimental, and you get the code using git, using git clone http://git.drupal.org/sandbox/damz/1130436.git editablefields_d7 or the link to the snapshot archive.


How to add condition in between fields in Profile2 module in drupal 7?

Yes you can do this also option wise using field conditional state module.

Go through this field_conditional_state for details.

Trigger a state when applied to a control field:

    empty - Triggers when the control field is empty
    filled - Triggers when the control field is not empty
    checked - Triggers when the control field is checked
    unchecked - Triggers when the control field is not checked
    value - Triggers when the control field's value is equal to a given string
    !value - Triggers when the control field's value is NOT equal to a given string


How do I update modules with security release only using composer?

(I am using Drupal 7 modules as example, but just because there are more examples of security updates for Drupal 7 modules.)

Without custom coding, it's not possible. Drupal.org doesn't use a different name schema for security updates. From the version number you cannot know that version 7.x-3.14 of the Views module was a security update, while version 7.x-3.13 was not a security update.

That information is kept in https://updates.drupal.org/release-history/views/7.x, for the Drupal 7 version of the Views module, or in general in https://updates.drupal.org/release-history/<project short name>/<Drupal version>.
In the list of terms associated with a release, a Release type term whose value is Security update means the release is a security update.

<release>
  <name>views 7.x-3.14</name>
  <version>7.x-3.14</version>
  <tag>7.x-3.14</tag>
  <version_major>3</version_major>
  <version_patch>14</version_patch>
  <status>published</status>
  <release_link>
    https://www.drupal.org/project/views/releases/7.x-3.14
  </release_link>
  <download_link>
    https://ftp.drupal.org/files/projects/views-7.x-3.14.tar.gz
  </download_link>
  <date>1466019539</date>
  <mdhash>168bb684c8f34297be94b03c797841e5</mdhash>
  <filesize>1656594</filesize>
  <files>...</files>
  <terms>
    <term>
      <name>Release type</name>
      <value>Security update</value>
    </term>
    <term>
      <name>Release type</name>
      <value>Bug fixes</value>
    </term>
  </terms>
</release>

The classes under the \Drupal\update namespace can help in writing the required code. UpdateProcessor::parseXml() is the method used to parse the XML data for a single project, but you would probably need to access one of the services Drupal implements.


How to Fix/Clean Lambda warnings/errors from Views PHP

Before try to explode/implode  check that data exist in them
as example

"$price_loop1"
 if($price_loop1)
     $prices_number_of_person= implode(",", $price_loop1);

and for explode

  if($prices_number_of_person)
      $split_prices_number_of_person = explode(",", $prices_number_of_person);


Since the event is a content type. You could use hook_cron to find expired events and add new event node.

Add node programmatically.

  $body_text = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.';

  $node = new stdClass();
  $node->type = 'article';
  node_object_prepare($node);

  $node->title    = 'Node Created Programmatically on ' . date('c');
  $node->language = LANGUAGE_NONE;

  $node->body[$node->language][0]['value']   = $body_text;
  $node->body[$node->language][0]['summary'] = text_summary($body_text);
  $node->body[$node->language][0]['format']  = 'filtered_html';

  $path = 'content/my-lipsum-' . date('YmdHis');
  $node->path = array('alias' => $path);

  node_save($node);

How to programmatically create node in drupal 7


How to add asc and desc sort symbols in drupal views?

Implement theme_tablesort_indicator(). Please replace your theme name with example

function example_tablesort_indicator($variables) {
  $style = $variables['style'];
  $theme_path = drupal_get_path('theme', 'example');
  if ($style == 'asc') {
    return theme('image', array('path' => $theme_path . '/images/arrow-asc.png', 'alt' => t('sort ascending'), 'width' => 13, 'height' => 13, 'title' => t('sort ascending')));
  }
  else {
    return theme('image', array('path' => $theme_path . '/images/arrow-desc.png', 'alt' => t('sort descending'), 'width' => 13, 'height' => 13, 'title' => t('sort descending')));
  }
}


Field help text is printed as input field title, not in separate field

Try to uncheck 'Smart form descriptions (via Tooltips)' in Appearance -> Bootstrap settings -> General -> Forms.


How can I change message set on form.inc?

It's notoriously difficult to target/replace specific messages in the Drupal system. It's not impossible but it's a bit 'messy'.

I'd strongly recommend instead that you install the String Overrides module and use that to replace the specific message instead. String Overrides:

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

It is available for any string in the system which is passed through the t() function, which all core error messages are.


Drupal 7 treat html 5 data attributes as text

I am not using this module. Try once this module, hope you will get some configuration settings.

HTML5

  This theme will be the official back-port of the theme-related work
  done in the Drupal 8 HTML5 initiative. We want everyone to be able to
  preview what's coming in Drupal 8 from a markup and CSS perspective.
  We want anyone to be able to easily review our progress without
  needing to create another install of an unstable, or unfamiliar
  version of Drupal.

HTML5 Tools

  HTML5 Tools is a module that allows Drupal sites to be built using
  HTML5 ... smartly.

  One of our goals is to provide as much support for HTML5 markup in a
  set of Tools provided by a module so that you can use this module with
  any HTML5 theme you'd like.

HTML5 Media

  This project has one goal. To bring a standardized, Open Source GPL
  front end media solution to Drupal core. This project is completely
  open and has no other intentions other than to provide a standard
  front end media solution that will benefit the entire Drupal
  community, so therefore, whoever would like to help in this initiative
  is welcome to contribute!


hide "Submitted by ADMIN on THU, xx/xx/xxxx - 00:00" in a view

You don't change that in view.

To perform this step, make sure you are logged on as an administrator, choose the content type you would like to edit by going to » Administration » Structure » Content types.

and under display settings tab, uncheck the display author and date information. Once you are done, save the content type


Drupal.settings.ckeditor is undefind in CKEditor module

Finally I got a clue. I had enabled HeadJs module for improving jquery loading time. This module was creating bottleneck. Just uninstalled this module and work like a charm.


Core files updated, but getting "No Pending Updates" message

Hope this is helpful for other beginners:

Turns out, what I did wrong was not copy the new core files from the modules directory. I assumed that I wouldn't need to copy those (just like the "sites" folder), and I feared losing my installed modules. Turns out, as you probably already know, the core files in the modules folder needs to be updated as well.


How to use composer for module dependency?

See this composer template for Drupal project for an example of how this works. Usage:

composer create-project drupal-composer/drupal-project:8.x-dev some-dir --stability dev --no-interaction

With composer require ... you can download new dependencies to your installation.

cd some-dir
composer require drupal/devel:~1.0


Don't show block until after a number of comments

If you are making the block using Views, you should be able to do this pretty easily by adding a view filter of "Content: Comment Count" is greater than or equal to "6"

It will then only show the block when it has results that meet your criteria.


how to store images into file_managed table from android to drupal

The Services module provide an easy to use web services enpoint to create file which do all the heavy PHP work for you.

In file_save_data(), the mime type of the file is derived automatically, likely from its filename. You can set the filename of the saved file by using the $destination argument.


How to capture form fields to programmatically create new users

As AyeshK pointed out there are several examples out there. This should have all the elements you need.

First you must create a form to use in your block with hook_form, create your custom submit handler, and use your form values found in $form_state.


How do I keep multiple sites in sync using drupal-composer/drupal-project

There are a number of different options that are all viable here; this is what I would suggest:

On your dev site, run composer update with options to suit what you want to update.
Run drush updb on your dev site.
Test thoroughly; then commit composer.json and composer.lock and push to your repository.
On your test site, pull your repository and run composer install.  This will put all of your dependencies into the exact same state they were in on your dev site, so you will get exactly what you tested.
Run drush updb on your test site.
Test thoroughly again.
When you are ready to deploy to your live site, put it in maitenance mode and use a file copy program (e.g. rsync) to move the exact files from the test site to live. Alternately, you can use composer install again.
Run drush updb on your live site.
Confirm that all is okay and take your site out of maintenance mode.


Is there an easy way to load a related entity from an entity?

You can use the entity field property. ie:

public function getOtherEntity()
{
  return $this->get('other_entity_id')->entity;
}


Content type - manage display based on roles?

As far as implementing a new view mode yourself goes it's pretty easy, without any contrib modules.

You can implement hook_entity_info_alter() to add a custom view mode to any entity. For example this code adds a new view mode called "Test View" to the node entity type:

function MYMODULE_entity_info_alter(&$info) {
  $info['node']['view modes']['test_view'] = array(
    'label' => 'Test View',
    'custom settings' => TRUE
  );
}

After a cache clear that view mode will appear in all the places you'd expect (manage display, views, etc.)


Using integer with multiple values in Form API

I got the solution from Save a new value with entity_metadata_wrapper to an entity field which is an array.

I created two separate form fields.

function createnode_form($form, &$form_state){
  $form['field_student_age'] = array(
    '#type' => 'textfield',
    '#title' => t('test'),
  );

  $form['field_student_age2'] = array(
    '#type' => 'textfield',
    '#title' => t('test2'),
  );

Then I stored them using the first method in the post quoted above.

$ewrapper->field_student_age[] = $form_state['values']['field_student_age'];
$ewrapper->field_student_age[] = $form_state['values']['field_student_age2'];

Rather than using set as I'd done with single values, I created a new entry for each value using [] =.


Config sync directory outside of webroot causes open_basedir restriction warning

PHP should have no problem with seeing outside of and jumping out of the webroot, correct?

Very much not! As the errors are telling you, your server config explicitly doesn't allow that to happen. You have PHP locked down to only be able to read from certain paths; /home/cathchar/config and/or /home/cathchar/config/sync don't belong to that list, so PHP can't read files from them.

  Do I have to inform Drupal somewhere else about a new path to work in?

No...Drupal doesn't need to be told about file system restrictions, it just consumes the environment it finds itself in, and invariably complains if it can't access what it's (implicitly) been told it can have access to.

This should ideally be solved in your vhost/FPM config by setting an open_basedir which includes all of the paths that PHP needs to be able to read from (separated by a ;).

  None of the tutorials/instructions I've read ever mention issues regarding directory access, paths, or open_basedir restrictions

The docs don't really try to cover every possible configuration scenario, it's probably assumed that if you're doing something more advanced like moving a folder out of the web root that you're happy configuring the rest of the server to allow it to happen.


This looks like something that you could use the Menu token module for. Install and enable the module, then use a link path like this:
user/[current-user:uid]/edit


Try theme_links

Like

<?php
print theme('links', array('links' => menu_navigation_links('menu-site-menu'),
'attributes' => array('class'=> array('links', 'site-menu')) ));
?>


Why xmlsitemap module implements hook_node_comment_delete this way?

It seems like the author of that function might just have been a tiny bit over-zealous in trying to strongly-type the $comment parameter.

The hook_comment_delete() docs don't really give any indication that it should be implemented in this manner; but if you look at the signature for the Drupal 8 version of the function, you'll see the parameters are typed. It might be that the author was following that 'pattern' when creating the function (rightly or wrongly). That's a complete guess though.

I haven't seen hook parameters being typed like this in any other contrib modules that I can think of, so it's probably an isolated incident (although this format is consistent across most of the hooks for the xmlsitemap node module).

I think the best way forward would be to create a patch that fixes the issue, and perhaps submit it to the XmlSitemap issue queue for others to review.


Pass parameters to external JS file with drupal_add_js()

I ended up just going with a modification of the current code. I modified the behavior above so that it just loads the variables:

var _elqQ = _elqQ || [];

(function ($) {

  Drupal.behaviors.eloquaTracking = {
    attach: function (context, settings) {

      _elqQ.push(['elqSetSiteId', Drupal.settings.eloqua.siteId]);
      _elqQ.push(['elqTrackPageView']);
    }
  };
})(jQuery);

and then used drupal_add_js() to load the tracking file in my module

drupal_add_js(drupal_get_path('module', 'eloqua') . '/elqCfg.min.js');


How to use the Features module in a 3 dev environnement?

Welcome to the land of Features Configuration Management, aka FCM! It is not only about Features, and not about Configuration Management (as introduced in Drupal version 8). Instead, it is a special case of Software Configuration Management, aka SCM. Mostly because Features can be considered as a code generator, whereas that generated code needs to be migrated through multiple environments. Read on for more details.

1 - Pros and cons of using Features

Advantages of using Features

Automate the deployment of changes applied to a Drupal development site to one or more target Drupal (pre-) production sites (instead of manual deployment).
Facilitates sharing (shipping) of ongoing Drupal development between Drupal developers / site builders (eg to make some View(s) created by a views expert available to a Drupal Themer working in another development site to theme that view).
Great integration with both GIT and Drush for shipping a copy of the code generated by Features (on the development site) to selected target (pre-) production sites.

Disadvantages of using Features

Avoiding Feature Conflicts and/or managing Feature Dependencies can be challenging!
It's not easy to start using Features on an existing (production) site.
Install/enable of the Features module is easy (just a module), but to learn to use Features correctly is a major challenge.

2 - Techniques for features packaging

Using Features it is up to your own imagination how to package (compose) the content of a feature. Here are some techniques that can be used for it.

A single super feature

This is a pretty simple packaging technique: everything is packaged together in a single feature (some call it the "God" feature ...). Seems easy, pretty forward, etc. But this technique also leads to "conflicts" (as explained below) more or less right away ...

A good usecase for this appears to be when creating a "Drupal distribution", where all users of it are assumed to use the same set of modules, configuration, etc. If however such distribution consists of multiple website functionalities (to not use the word "features" ...), it seems more appropriate to split such features in multiple features, as explained below.

Based on website functionality

This packaging technique creates a separated feature for each functionality of a website, such as:

Feature A = implement a "*Gallery".
Feature B = implementg a "*Blog".
Feature C = implement a "*Event Calendar".

Based on Drupal admin sections

This packaging technique creates separated features for each of the (major) admin sections of a Drupal website that is used to create the site, such as:

All required modules are contained in feature A,
All base field definitions are contained in feature B,
All content types are contained in feature C,
All permissions are contained in feature D,
All roles are contained in feature E,
All variables are contained in feature F,
All (custom) Views are contained in feature G,
All (custom) Rules are contained in feature H,
Etc.

The above list is virtually unlimited: in the end you could even think of it as 1 feature for each Drupal admin menu option ... if you want to go that far.

IMO it is also the most recommended approach to package features.

3 - Reducing the probability of conflicts in Features and/or GIT

Do not reuse fields

Quite a few conflicts seem to be caused by reusing fields among multiple content types. E.g. in content type A you have a field with machine name field_somefield, which is also used as field in content type B with the very same machine name field_somefield but which as another field type and/or some other field setting(s) that are different.

By not reusing fields among content types, you avoid running in this issue. Have a look at an interesting naming convention for the machine name of your content types and fields as shown in table of Wrapping Information Architecture and Documentation, which is part of the articles about "Relativity Model for Drupal". For more details on that refer to my answer to "How do I model content (types) from a database-centric point of view?".

Split features depending on who works on what

If multiple people are working on a single site, the amount of conflicts can be reduced by organizing (= creating separate) features based on who is working on what. An illustration of this could be as in this example:

Views goes in feature A,
Rules goes in feature B,
Charts goes in feature C,
Anything about Theming goes in feature D,

4 - Recommended Drupal environments

Everything above should help to somehow facilitate the usage of Features. However, to ensure that things will work as expected (designed), you also need to have an appropriate set of environments (logically related Drupal websites) for basically these reasons:

merge functionality provided by multiple features.
predict and resolve conflicts.
end-user testing of all merged features that are certified to not have any conflicts.

In the ideal world, these logically related Drupal websites should be configured, and used, like so:

Personal Dev Site - each website developer has a separated dev site. When some part of the development is ready to be shared with somebody else, an appropriate feature is created, which is shipped to the staging environment.
Sandbox Site - this is a Drupal environment which only contains Drupal core, used to unit test the completeness of a single feature. Should a feature, accidentally, have some unexpected dependencies (eg some module the feature depends on, which is not enabled in the Sandbox), then this is where that dependency will become clear.
Staging Site - here is where one or more features (created in a dev site) are delivered to. It could be just some hotfix for some production problem, or it could be where all development for a new release of the website is consolidated. If any conflicts between multiple features do exist, then this is the environment where they will first show up ... and need to be resolved somehow.
QA Site - after the Staging environment is considered stable, it's time to move on with the relevant features and make them available also at some higher level where they can be used for QA testing, acceptance testing, volume testing, etc. At this level you should be extremely careful in allowing any additional changes (if any). Because any such change may invalidate all prior testing efforts already completed in this environment.
Shadow Production Site - To prepare the activation in real production, you might want to first further promote the relevant features to an environment that is considered a copy (shadow) of your real production environment. If at this point during the migration process anything still breaks, then that is a red flag to revert some of your prior steps. Get it fixed, and try again, until all parties involved approve the changes.
Production Site(s) - If you completed all prior steps, then this step should be self explaining, and pretty easy. Depending on your needs, this could be a single site, or something equivalent to Drupal's Multi-sites whereas all the sites involved are running the very same versions of all features.
Baseline Site - In my experience, there are not many (if any at all) Drupal implementations where this type of site is used (also). It is simply a copy of the Production Site(s), but available to the Drupal developers, testers, etc that can be used to verify what the production sites look like, or to perform user training, etc. And any time a new development cycle is started, the components of a site that will be impacted (need to be changed) should be "copied somehow" using this Baseline Site as input, with as target a Personal Development Site.

Obviously, the above inventory of types of Drupal sites is like the ideal world. Depending on the size of your development team, and / or the available budgets to create and maintain them, not all of them may be used (or affordable). This inventory is modelled after best practises in the area of SCM, used in mostly all huge/global corporations (banks, airlines, etc).

5 - Related modules

Strongarm

The Strongarm module allows for exporting variables (of modules which store their settings in variables) with the Features module.

Node Export

The Node export module allows users to export nodes and then import it into another Drupal installation.

Role Export

The Role Export module allows roles to have machine_names and generates a unique role id (rid) based off of the machine_name. Roles can be exported with Features and get the exact same rid if imported on other sites.

Features Banish

The Features Banish module allows for completely excluding individual features components from the features UI and features exports. Here is a quote about it from its project page:

   This module is useful when there are features components that you want to make sure NEVER get exported. If you are using features for site building or deployment then you've probably ran into the issue of someone accidentally exporting timestamp variables like cron_last or update_last_check. You may also want to banish permissions for developer modules so they don't get caught up with the rest of the site permissions you want to export. Banished items will not show up in your feature module OR ANY OTHER FEATURES MODULE, so use with caution. For a central list of features that should never be exported, see https://www.drupal.org/node/2400531

BEAN

The Bean module makes your blocks exportable. Here is a quote about it from its project page:

  Think of a Bean as a method to provide new types (compared to node this would be a content type) which then provides an add content interface to create as many blocks as you require (see screenshot below). The bean content can then be placed around the site just like any other block.

This module also works great in combination with the UUID and UUID Features Integration modules. This module only started as of D7, but it has been included with Drupal 8 core already. The video tutorial Drupal Bean module tutorial - using Bean Admin UI provides a great introduction to really understand the power of this module, and the kind of things you can do with it (by only using site building techniques, no custom coding involved).

Habitat

The Habitat module makes most sense in a Features-based workflow. Here is a quote about it from its project page:

  In a multi-environment setup (e.g. prod, test, dev, local) there are some modules that you'd like to always be enabled or disabled on certain environments. Each time you sync a database down though you have to re-enable/disable the same modules. Worse, you get lazy and keep development modules enabled on production.

  Habitat provides settings to enable or disable certain modules on each environment (habitat). Just set a variable with e.g. $conf['habitat'] = 'local'; in your settings.php file (the actual variable to use there is configurable for your current workflow). The disabling/enabling modules is done on hook_init.

6 - Recommended resources:

Community documentation about Features.
Part of this answer is based on the (amazing I think) Features debat.
Video tutorials:

Creating a Feature.
Reverting Features.
Updating Features.
Making features the right way.
Limitations of Features.

7 - Possible alternatives to using Features

If you're not able, or willing (yet), to use Features, then you may want to check to what extend the approaches/modules below may provide some type of alternative.

Manual Export/Import

These are the commonly known facilities (to avoid the word features ...) available via the admin UI, for modules such as Rules, Views, etc (incomplete list!).

Bundle copy

Some people consider the Bundle copy module as a possible alternative. It has export/import support for:

Node types.
Taxonomy.
User.
Field API fields.
Field groups.


What causes my error "Illegal choice in Sorted by element"?

I was able to figure out what view was being used on group pages (The Commons Browsing Widget) and see that there were three sorting criteria. One of them is the Radioactivity module.

I checked the general status report (admin/reports/status) to see that there was an issue with RadioActivity module.

I removed this sorting feature for now, but it should work now that I cleared up the issues with the module. I guess no one could have known that this was the cause. I'm keeping this up in case anyone else finds it helpful.


How do you pass page arguments from panels to a view?

Example scenario:

There is a panel containing View Content Pane.

Panel URL: /panel_url

Example with argument: /panel_url/term_name

With BEF: /panel_url?category=123

How to set up (having existing panel and added Content Pane):

Add Contextual filter to the View.
E.g.: Views contextual filters taxonomy name
Change settings in 'View -> Pane settings -> Argument input' to load the argument 'From panel argument' (e.g. First).

Done.

In addition, if you're using Better Exposed Filters, you could do the following improvements.

To set the current active link based on the argument (if you're using select_as_links):

/**
 * Implements hook_preprocess_[themeFunctionName]().
 */
function foo_preprocess_select_as_links(&$variables) {
  $options = isset($variables['element']['#options']) ? array_change_key_case(array_flip($variables['element']['#options']), CASE_LOWER) : array();
  $selected = end((arg()));
  if (array_key_exists($selected, $options)) {
    $variables['element']['#value'] = $options[$selected];
  }
}

To set the current active link based on the argument (if you're using select):

/**
 * Implements hook_preprocess_[themeFunctionName]().
 */
function foo_preprocess_select(&$variables) {
  switch (arg(0)) {
    case 'panel_url':
      if (@$variables['element']['#name'] == 'DROPDOWN_NAME') { // name of your select list
        $options = isset($variables['element']['#options']) ? array_change_key_case(array_flip($variables['element']['#options']), CASE_LOWER) : array();
        $selected = end((arg()));
        if (array_key_exists($selected, $options)) {
          if ($variables['element']['#value'] <> $options[$selected]) {
            $variables['element']['#value'] = $options[$selected];
          } else {
            // drupal_goto('panel_url');
          }
        }
      }
    break;
  }
}

To make the links SEO friendly, you can try something like:

/**
 * Implements hook_url_inbound_alter().
 */
function foo_url_outbound_alter(&$path, &$options, $original_path){
  if (arg(0) == 'panel_url') {
    // Convert URL like: /panel_url?category=29 into /panel_url/term_name (SEO friendly)
    $path_info = parse_url($path);
    switch (@$path_info['path']) {
      case 'panel_url/term_name':
      case 'panel_url/term_name2':
        $path = 'panel_url/all'; // Convert loopy urls into base url
    }
    if (strpos($path, '?category=') !== FALSE) { // Convert term id into human name
      list(, $tid) = explode('=', current(explode('&', $path_info['query']))); // get tid from URL
      $term_name = strtolower(taxonomy_term_load((int)$tid)->name);
      $path = '/panel_url' . '/' . $term_name; // See also: $path_info['path']
    }
  }
}


How to track site search with using Google Analytics without installing additional modules?

I think the module serves well, but if you don't want to use the module for some reason, you can always create a new block and copy/paste the code provided by Google Analytics in there. Make sure you select the Text Format as Full HTML or similar which doesn't strip out <script> tags.

And of course, enable the block and move it to a footer region.


Is there anyway to show all results in a view initially, but only show 1 result after user sets an exposed filter?

For the record, this seems like a really odd thing to want to do! How would you narrow it down to a single result if more than one matches the filter?

Anyway,  you should be able to use this hook:
https://api.drupal.org/api/views/views.api.php/function/hook_views_query_alter/7

If you check for the existence of filter values, you can then apply a "LIMIT 1" to the query.


Drupal fails to send password reset mail

Long answer in short: mod_rewrite was not active in apache :(

Failure drove me crazy so I finally started to think outside of the box :) Misleading point was initial error with msmtp configuration (owner of the config file must be wwwroot (in openSUSE case))...


Which Apache module is required by Drupal system

The most common enabled module (or installed if not available) is mod_rewrite which helps your site have nice and clean urls. But even this isn't really required ... you can live without it but your site won't have nice links instead they will look like : www.example.com?q=node/12345. If PHP is working than that means that you have the necessary config to run Drupal.