How to fire a Rule after adding a new file in multi-value field?

To process a multi-value field with Rules,  you should use a completed different approach, which is related to the Rules Condition "List contains item" (and/or its negations).

Have a look at this rules example (in Rules export format), which processes a multi-value field also, though in my case it is a list of eMail Ids (replace "eMail ID" by "picture" to match your case):

{ "rules_verify_updates_to_selected_email_ids" : {
    "LABEL" : "Verify updates to selected eMail IDs",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules_conditional", "rules" ],
    "ON" : { "node_update--article" : { "bundle" : "article" } },
    "DO" : [
      { "LOOP" : {
          "USING" : { "list" : [ "node-unchanged:field-email-addresses" ] },
          "ITEM" : { "previous_email_id" : "Previous eMail ID" },
          "DO" : [
            { "CONDITIONAL" : [
                {
                  "IF" : { "NOT list_contains" : {
                      "list" : [ "node:field-email-addresses" ],
                      "item" : [ "previous-email-id" ]
                    }
                  },
                  "DO" : [
                    { "drupal_message" : { "message" : "Value [previous-email-id:value] was removed from the multi value field." } }
                  ]
                }
              ]
            }
          ]
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "node:field-email-addresses" ] },
          "ITEM" : { "current_email_id" : "Current eMail ID" },
          "DO" : [
            { "CONDITIONAL" : [
                {
                  "IF" : { "NOT list_contains" : {
                      "list" : [ "node-unchanged:field-email-addresses" ],
                      "item" : [ "current-email-id" ]
                    }
                  },
                  "DO" : [
                    { "drupal_message" : { "message" : "Value [current-email-id:value] was added to the multi value field." } }
                  ]
                }
              ]
            }
          ]
        }
      }
    ]
  }
}

If you just replace the machine name "field-email-addresses" by "field-pictures" (prior to import), you should be able to experiment with this rule in your own site to see it at work.

Here is a sample of the messages I get when I update an article, and while doing so I add 1 more eMail ID and at the same time I remove an existing eMail Id:

Value user3@example.com was removed from the multi value field.
Value user2@example.com was added to the multi value field.

So the clue to make this work is:

first iterate over all field values of your field of the unchanged node (to find the removed values).
then also iterate over all field values of your field of the changed node (to find the inserted values).

Obviously, this does note explain how to find the "updated" values. But think about my sample scenario: another way to look at it is that I updated value user3@example.com to user2@example.com. Not sure if it is a complete answer to your question, but admit it is already pretty close, no?

Note: As an alternative to using the Conditional Rules module (as you also seem to be doing already), you can also rework the relevant part of my Rules example into performing equivalent Rules Components. For more details on using Rules Components instead of Conditional Rules, refer to the answer to "What's the alternative to using the Conditional Rules module?".


How can I build a subscription product selling system with drupal commerce

Check Commerce subscription products module.

  Features

  Sell subscriptions via products.
  Administers can view and customize the subscription validity per user    if they have necessary field permissions.
  There are two "rule sets" (Subscription starts, Subscription ends)    that make customizing the subscription easy, e.g. one could    easily    add rules for granting/removing a user role.
  Subscriptions expire automatically once the validity time is reached    thanks to the Rules Scheduler (requires cron to function).
  Views integration, as the subscription validity date is implemented    as account field.
  Custom notifications like "Warning: Subscription expires in 2 weeks"    can be easily configured using Rules and the Rules    Scheduler.


Pulling in a title from multiple content types

I would put this as a comment, but I'm new so I can't comment on things yet, but what you could do is add the relationship of the chapter, then add a field using that relationship that shows the node reference that the chapter has to the program. As long as you're using that relationship, it should show the proper program.


Is it possible to make a entity reference field translatable and keep content in existing translations?

Normally you don't need to make the entity reference field translatable to translate the content. This is only necessary if you want to define for each language different target ids.

But this is a different issue. If you enable translation for a field the translated fields have not yet content. This is not specific to reference fields, it is the same for all field types. Only when you create new translations the field values are copied, so that the form is prefilled with the untranslated values. So if you change the field structure in this way and you want to start with all existing translations prefilled you may need an update script for the existing field data.


How to specify the file path for the private file system?

In order for this question to be marked as answered, @Clive pointed out here that the problem was the leading # character, which made the 1st line a comment, meaning that the file_private_path was never set.

The correct line should be

$settings['file_private_path'] = '/home/someuser/public_html/private_files/stuff';


How to update the blocks db-table correctly

Use INSERT INTO. I've spent hours and hours using block_rehash and variants to no effect.


Create a view in D7 that displays and links the taxanomy term and displays and links nodes associated with the term

Views tree

This module provides a tree-based style plugin for Views. It is
equivalent to the tree-based style template from Views 1.
It is based off of the list style. Although it generates a nested
view, there is still only a single query run for the view making it
quite performant.
Compatibility
This module has been tested and used with the following
relationship-oriented modules:

Taxonomy (in core) - parent/child relationships References - node and
user references Relation
references between any entities (D7 only)
Entity reference - references between any entities (D7 only)
Organic Groups (D7 only)

Example:


Language selector for Apache Solr search form

The Solr Multilingual module should do what you appear to want.

  ... provides a way to offer language-specific searches for different
  languages at once on multilingual websites ...

I'm using the not-yet-released 7x dev version with some success.  A registered-user's primary language selection, or override from a drop-down in the site-wide menu sets a $var which I carry through to the Solr search module, language-specific content, and Drupal language overlays for standard markup, etc.


if title available print $title if disabled print somthing else

Found the Solution.

Go to -> (advanced_forum/styles/naked/advanced-forum.naked.post.tpl.php)

  <?php if (!empty($title)): ?>

      <?php print $title ?>

  <?php endif; ?>

Then replace it with:

<?php if (!empty($title)): ?>

        <?php print $title; ?>

<?php else: ?>

<a href="#comment-<?php print $comment->cid; ?>"> Re : <?php print $node->title ?>

<? endif; ?>


Clean field value handling inside views_handler_field subclass?

field_get_items() and field_view_value() are as clean as it gets without Entity API.


Show custom view before input entered on exposed form

Looks like the required_filter_input module is the way to go, as it requires one exposed filter to have a value before returning results, which triggers the custom "no results" view without any input by default.


Solved.
In the menu block configuration, Advanced Options, I checked Make the starting level follow the active menu item.


Create a view to list all contents that uses media through any entity reference field

Mostly yes, by adding relationships to a view. The drawback is that is not done automatically: you manually have to add all entities/fields that possibly can refenrence a media entity. Create a view showing media entities. Then add the related tables and filter criterias "related/foreign field referencing media -- is not empty"

I'd not recommend the "File usage" relation and its "Use count" field. It doesn't seem to count correctly in my projects.


How to get attached files outputted by views for given node id (programatically)

I thought I'd come back and explain my solution. It involves a series of loops through the following: getting regions available for current nid, then the blocks displayed on that nid, then loading each view that has blocks on that nid to obtain access to the fields. I can't provide any code but in theory that's what it involves.


is there any way to make the webform components labels translatable?

Similar (a litte bit more generic) solution but still not a clean one:

function mymodule_node_view($node, $view_mode, $langcode) {
  if($node->type == 'webform' && $view_mode == 'full') {
    // translate the webform component labels
    foreach(element_children($node->content['webform']['#form']['submitted']) as $key){
      $node->content['webform']['#form']['submitted'][$key]['#title'] = t($node->content['webform']['#form']['submitted'][$key]['#title']);
    }
  }
}


How to add to 'Secondary Local Tasks' on Order page

Just emulate what you see in the other modules:

  if (module_exists('commerce_order_ui')) {
    $items['admin/commerce/orders/%commerce_order/edit/refresh'] = array(
      'title' => 'Apply pricing rules',
      'description' => 'Executes the cart order refresh used to apply all current pricing rules on the front end.',
      'page callback' => 'drupal_get_form',
      'page arguments' => array('commerce_cart_order_refresh_form', 3),
      'access callback' => 'commerce_cart_order_refresh_form_access',
      'access arguments' => array(3),
      'type' => MENU_LOCAL_ACTION,
      'file' => 'includes/commerce_cart.admin.inc',
    );
  }

The important thing is the type and the path.


You should remove the entire file.

Also,  this is not enough to fix your site.  I would recommend exporting your content and doing a fresh install, with a fully updated version of Drupal.


How to set default reply-to address in webform?

in your form, create an email field  that contains the email you want to have for your reply-to.  now hide it(don't display..making it private might suit, or use css).  This hidden email field value will be accessible in the component pulldown


Use REPLACE in update query using db_update

The replace function doesn't work when the field is a placeholder. This will insert the field string as new value in the database. I've solved this problem removing the placeholder. Check it out:

foreach ($tables as $table => $field) {
  $num_updated_1 = db_update($table)
    ->expression($field, 'replace(' . $field . ', :old, :new)', array(
      ':old' => 'old_value',
      ':new' =>  'new_value',
    ))
    ->execute();
}

This way the code will work perfectly. I hope this may help someone.


How to (reliably) add jQuery plugin to Drupal

You embedded your module the right way. The error stems probably from the fact, that ScrollMe needs jQuery 1.8 minimum, whereas Drupal 7 only ships with 1.4.

You have many options of updating your jQuery version in Drupal.


Need advice on remote storage for load balanced drupal site

Upon further research, I decided to boot up another VM instance and mount my two web servers to it then installed NFS server and client respectively. This seems to work very well.


Queue doesn't enter on worker function with Elysia cron

Below code perfectly works for me...

/**
 * Implements hook_cron_queue_info().
*/
function drup_custom_cron_queue_info() {
  $queue['drup_custom_queue'] = array(
      'worker callback' => 'drup_custom_queue_worker',
      'time' => 10,
  );
  return $queue;
}

/**
 * Implements hook_cron().
 */
function drup_custom_cron() {
  $items = array('1', '2', '3', '4', '5', '6', '7');
  $queue = DrupalQueue::get('drup_custom_queue'); // grab queue
  foreach ($items as $i) {
    $item = new stdClass();
    $item->created = time();
    $item->sequence = $i;
    $queue->createItem($item);
  }
}

/**
 * Worker callback
 *
 * @see mymodule_cron_queue_info().
 */
function drup_custom_queue_worker($item) {
  watchdog('drup_custom', 'Queue worker processed item with @sequence created at @time',
    array(
      '@sequence' => $item->sequence,
      '@time' => date_iso8601($item->created),
    )
  );
}

Check your custom callback which returns results as mentioned by David in comment..


Getting the token tree to appear contextually

The surpising answer was:
'#token_types' => array('node', 'term')
Thanks to davereid!


How Can I Enable a Multi-Lingual Catalog Block on Drupal 6.32 + Ubercart 6.x-2.13

Sorry but you CAN NOT HAVE Ubercart multilingual because the project was started on the wrong way and now the developer team have no interest/possibility/capability to rewrite a lot of code!


Thanks very much Sumit Madan,

he gives me the solution:

Mapping:

for the file class of the image field enter this as "standard value": MigrateFileFid

set "TRUE" for preserve_files of your image-field.

thanks again!


How do I make a block appear in a panels display based on the state of a field

If I understand your case you could :
 - have a Static field, containing your link
 - use Conditional Fields Module and set up a condition with :

"dependee"  = your checkbox
"dependent" = your static field (containing your link to another page)
condition = dependent is visible if dependee has value 1


Where in The Database does File Usage Data Come From

I couldn't find any /usage path in core. You must be using a custom or contrib file manager module.

  From what tables does it determine a use?

According to file_usage_list the file usage info is stored in the file_usage table, so I bet the custom or contrib module must be reading from there.


Breadcrumb add content type data without any modules

It is possible using theme_breadcrumb().

Example:

/**
 * Implements theme_breadcrumb().
 */
function theme_breadcrumb($variables) {
  // global variable
  $output = '';
  $breadcrumb = $variables['breadcrumb'];
  if (!empty($breadcrumb)) {
    $nid = arg(1);
    $node = node_load($nid);
    $output = '
';
      $i = 1;
      foreach($breadcrumb as $value) {
        $output .= '
'.$value.'
';
      $i++;
      }
      if ($node->type == 'content_type') {
        $output .= '
' .  $node->type . '
';
      }
    $output .= '
'. drupal_get_title() .'
';
    $output .= '
';
    return $output;
  }
}


overriding ubercart - add to cart button

In D7, below is my solution for different product classes.

/* Overrides the Add to Cart form text*/
if ( !empty($form['nid']) ) {
  $node = $form['nid']['#value'];
}
else {
  $node = 0;
}
if (($form_id == 'uc_product_add_to_cart_form_'.$node) and ($form['node']['#value']->type =='uc_recurring_subscription')){
   $form['actions']['submit']['#value'] = t('Subscribe');
}

if (($form_id == 'uc_product_add_to_cart_form_'.$node) and ($form['node']['#value']->type =='credit')){
   $form['actions']['submit']['#value'] = t('Buy');
}

For regular product or just one product class, this should work.

/* Overrides the Add to Cart form text*/
if ( !empty($form['nid']) ) {
  $node = $form['nid']['#value'];
}
else {
  $node = 0;
}
if (($form_id == 'uc_product_add_to_cart_form_'.$node){
   $form['actions']['submit']['#value'] = t('Buy now');
}


Is it possible to leverage browser caching?

If you have a .htaccess file, you can add the following code at the top of it:

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##


How can I organize my content using hierarchical taxonomy?

I had a similar implementation on a drupal 6 site using Hierarchical Select. The drupal 7 branch turned out to be working slightly differently when I first tried to make the move.

There is also Simple hierarchical select which was probably developed because of these 'differences' between d6 and d7:

  "This module has been inspired by Hierarchical select but is much simpler (…)."

I haven't tried 'Simple hierarchical select' yet, but if I would re-build that d6 site again, I would probably go for 'Simple hierarchical select'.

Both let you generate a taxonomy tree with dependend parent-child-relationships. So instead of having one taxonomy brandand one one taxonomy model you would have a taxonomy tree taht would contain all the branches down to specific model.

In my case is was venues which then also contained the upper branches like cityand country.

PS: You could however also use entity references to build complex hierarchical content trees. You would then for example have a content type brand and a content type model referencing each other.  Nowadays I find this approach more convenient than dealing with taxonomy trees – but that's of course depending on personal preferences and/or content structure.


How Can I add a Hierarchical taxonomy Select in views filters and when editing content in Drupal 7

Response is late but I think(/hope) accurate. You can use the "Simple hierarchical select" http://drupal.org/project/shs. With the help of this module you can make use of the hierarchical select functionality both through views->exposed filters and of course when adding content.

  The widget is available in node forms and as Views exposed filter.


Where is root directory in Drupal Acquia Desktop?

Acquia desktop allows you to use any folder you wish as your root folder hence your site could be on the desktop, or documents. Use the import new site option in the settings tab to point to where drupal folder is located


Using Bootstrap with a Zen subtheme in Drupal 7

In your_theme.info do the following:

stylesheets[all][] = bootstrap.css
stylesheets[all][] = yourstyles.css

This should load both Bootstrap first and your own CSS files afterwards.


load node author uid to be used as contextual link inside template.php D7

You have just a tiny mistake , use $build['#node']->uid instead $node->uid  :)

function MYTHEME_node_view_alter(&$build) {

         $node_author = user_load($build['#node']->uid);

          // Add your own custom link
          $build['links']['node']['#links']['user-post'] = array(
            'title' => t('User post'),
            'href' => '/userview/' . $node_author . '/post',
            'html' => TRUE,
            'attributes' => array(
              'title' => 'User post',
            ),
          );

        }


How can I avoid  the "The file x.jpg is in use and cannot be deleted." warning I get when I try to delete a media file?

To be honest this is the behaviour that should be expected of the field/revision system.

If you have an image file that is attached to a node revision, Drupal (rightly) makes sure that another process in the system cannot delete it. If this wasn't done you'd end up with incomplete/erroneous node revisions.

The only options you've got (in terms of the UI anyway) are either deleting the revisions (which you already know about), or removing the reference to the file from the revision(s) in question.

If you're feeling brave you could dive straight into these tables and make the changes manually:

node
node_revision
field_data_field_FIELDNAME
field_revision_field_FIELDNAME

But I strongly advise you only go down that route if you really, really know what you're doing, and have a good backup system in place :)


How to choose language for date field in views rss feed?

I found an even easier solution, with a Custom date format simply use r, which is RFC 2822


Your problem is that Drush is running the PHP version that you have installed for your hosting environment (and Drush's own php.ini). You need to get Drush to run its own PHP that it installs with.

What host are you running on? If it is Windows then open a console and type set. That will show you the environment variables that you are using for your account. If there is a PHP variable in there, note it's contents and delete it by issuing the following command in the command windows: set PHP=

If that doesn't work set it back to what is was before. Any other platform I cannot help you with.

Also check this post: Modifying the PHP or PHP configuration that drush runs under


Filtering list of nodes with attached views by taxonomy of node

I would pursue the hook_views_query_alter() way, and using arg(1) and node_load() to load the node you are viewing and get the 'language' value from the node field. Add that value as a filter for your view programmatically.

Is this enough for you to continue on your own?


Answer really depends on your database backend. If you're using something like MySQL 5.6 or MariaDB 5.5 I would say probably not http://www.mysqlperformanceblog.com/2012/04/04/join-optimizations-in-mysql-5-6-and-mariadb-5-5/. If you're using a different database backend, it will be hard to tell without testing.

If using something like MongoDB for the field backend then it shouldn't cause any performance issues.

If you don't want to go with MongoDB or bleeding edge MySQL you can also look into using something like the Entity Cache if you find that all the fields is causing performance issues.


How to create a Default Argument based on Tags

At first glance I think you should create a taxonomy view with relationship to the content type where it was use by the user, then create a contextual filter to filter the nodes where the user is the author.

I am not sure if the tags created by the user will get the uid of the user that created out of the box, but if you can control that then the view will be even simpler just a taxonomy view with a contextual filter to the field holding the uid by the login user.


There's a patch in development for the Paragraphs module to support migration in Drupal 8. This work is currently undergoing development with recent activity. This might be a good way to get a start on your own work and contribute back to the community.


Module available for forcing users to re-enter their password to view/edit certain user account fields?

Most likely this/these fields appear on a certain page/form so you can use the securepages module to define the node/id or page path to assure that only logged in/authenticated users can access it.  If not, then the login page will display.
You could also use the loginlogout to return to the calling page upon successful login.


"Cannot declare self-referencing constant database.inc line 2101"

I suddenly got this same error on a Windows workstation.

It does not have anything to do with the content of the database (including cache); it occurs before it even connects to the database.

The only fix that worked for me was restarting apache.

Notes

The character within quotes is "EOT" ("end of transmission"), which looks empty in the error message.
The line 2101 in database.inc is the start of the DatabaseStatementBase class.


CSS lives one level further down in a libraries file; under system, module or theme. e.g.:

bootstrap:
  version: 1.x
  css:
    theme:
      css/bootstrap.min.css: {}
  js:
    js/bootstrap.min.js: {}
  dependencies:
    - core/jquery
    - core/drupal.ajax
    - core/drupal
    - core/drupalSettings
    - core/jquery.once


How to restrict a field choice allowing only one to be populated?

A bit confusing because it is rare for me to attempt any coding.

For this example I will pretend the content type is "Article".

First go to manage fields, and add a new field of list (text) to your content type. Let's say the possible values are "video" and "image". So For allowed values list, put

image|image
video|video

In /themes/your_theme_name/your_theme_name.theme add the following

/**
 * Implements hook_form_FORM_ID_alter().
 */
function your_theme_name_form_node_article_edit_form_alter(&$form, \Drupal\Core\Form\FormStateInterface &$form_state, $form_id) {
  $form['field_image']['#states'] = [
    'visible' => [
      'select[name="field_select"]' => ['value' => 'image']
    ]
  ];
  $form['field_video']['#states'] = [
     'visible' => [
       'select[name="field_select"]' => ['value' => 'video']
    ]
  ];
}

Replace your_theme_name with your actual theme name.
Replace article with your actual content type name.
Replace field_select with the machine name of your select field.
Replace field_image with the machine name of your image field.
Replace field_video with the machine name of your video field.

Lastly, clear and flush all cache to see changes.

Source: Drupal 8 - Conditionally hide a form field


Using webservice to popolute/search Address Field fields

More than likely, the best approach you can take here would be to add the AddressField reference to wherever it needs to be, and then add in logic to poll and collect address data inside a form validation call inside a module, using a hook_form_FORM_ID_alter() 1 call, when new Entity is created or edited.

This guide provides additional information on using validation calls in Forms: https://api.drupal.org/api/examples/form_example!form_example_tutorial.inc/7


Is it safe to delete default image/file styles?

You shouldn't remove the default styles (as mentionned), but you can alter them using hook_image_styles_alter

You can remove the options from selected forms using hook_form_alter (as mentionned).

I tried to find a generic approach and happily found this page.

This is how I applied the info:

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

  recursiveRemoval($form, 'thumbnail');
  recursiveRemoval($form, 'medium');
  recursiveRemoval($form, 'large');
  recursiveRemoval($form, 'square_thumbnail');

}

function recursiveRemoval(&$array, $val) {

  if (is_array($array)) {

    foreach($array as $key => &$arrayElement) {

      if(is_array($arrayElement)) {

        recursiveRemoval($arrayElement, $val);

      } else {

        if($arrayElement === $val) {

          unset($array[$key]);

        }

      }
    }
  }

}

N.B.: Use at your own discretion.


create a block and use the below code to get the node body field content.

$node = node_load(YOUR_NODE_ID);
$body_content = $node->body[$node->language][0]['value'];
print $body_content;

If you are using a field other than body field, then you should print_r that $node variable and you will get all content type field relate with particular node.From this array you can get the all values created by content types.


Searching on Taxonomy terms with the Search API module?

On the field index page, at the bottom see Add related fields select the term field you want to search. When you save, this adds a number of items associated with the term fields. Then select Taxonomy >> Name to index as Fulltext. Now it is searchable.


Listing the terms of a Taxonomy Vocabulary in a Tree structure using Views

Taxonomy menu module you are looking for and also you can integrate with views,
See the demo here

  Custom Menu per vocabulary
  Uses the default taxonomy term path or custom paths
  Integrate with Views
  Integrate with Pathauto: use URL/path aliases
  Does not interfere with other menu modules


It depends what kind of content the view is displaying, but in general

Set the view path to be user/%/cj
Add a new argument (or contextual filter D7) > User Uid
This will work for any user id you insert, eg user/1/cj, user/20/cj, etc...

You can also set the filter to filter on user > Current user, but that would make the path user/1/cj ambigious.


Drush crashes Call to undefined function ctype_alnum() in ubuntu

PHPBrew must be disabling ctype by default.

Try explicitly installing the extension with
phpbrew ext install ctype


use taxonomy term for reservations how to prevent overlapping

There are a number of ways to achieve the booking features in Drupal, try comparing here: Comparison of Booking System modules

One way that comes to mind for your specific case is using Flag module because you can set a Flag to be global, once an entity is marked as "occupied" that status is valid across the site. It's well integrated with Views and Rules, so you could probably do a lot there.

Another way might be to use Views Entity reference display for the Field widget when the user is creating a reservation. The Views would make sure to exclude all the terms for the Vocabulary that are already being used, so only "free" terms would show up when creating a new booking.


How to add a view of product fields to a product display so that it changes when add-to-cart form is updated via ajax?

The fields that change on a product display as different variations are selected on the Add to Cart form are updated via a series of Ajax commands returned by the form's refresh handler. It's about as complicated as the Forms API gets, to be honest, but it lets us do things like render the related fields and return them with instructions to the JavaScript client on where to place the HTML snippets to reflect the updates.

Because your View isn't associated with the product in the same way, you really need to trigger a refresh of its contents yourself. I'm not aware of any modules that will do that for you unless you can try / rule out Views Field. That may work with the product refresh system to support replacing the View alongside other fields.

That said, that's kind of overkill and would require a rearchitecture of your product displays. I would just hook into hook_commerce_cart_attributes_refresh_alter() yourself, re-render the View using the product ID stored in $form['product_id']['#value'], and return a command to drop it into place similar to how the other product fields are updated.


Move file uploads in webform into subdirectory using hook_webform_submission_presave

I finally sorted something out. Now in hook_webform_submission_presave the files are moved into subdirectories named by the value of a number form field. The field is mandatory, so I don't need extra validation in my function.

Here is the code I use in a custom module with plenty of comments, mostly for me to remember what I did.

/**
 * Implements hook_webform_submission_presave().
 *
 * @param $node: The Webform node on which this submission was made
 *        $submission: The Webform submission that is about to be saved to the database
 *
 * - Move uploaded files to subdirectory based on order-id
 */
function custom_module_webform_submission_presave($node, &$submission) {

  if ( 15 == $node->nid) {
    // get ordernumber for subdirectory
    $subdir = $submission->data[4][0];
    // get files from submission and move them one by one
    $upload_files = entity_load('file', $ids = $submission->data[5]);
    foreach ($upload_files as $key => $file) {
      $uri_old = $file->uri;
      // find last '/' in URI to get filename
      $uri_break = strrpos($uri_old, '/') + 1;
      // extract filename
      $file_name = substr($uri_old, $uri_break);
      // replace filename in uri with subdirectory to get new directory
      $new_directory = str_replace($file_name, $subdir, $uri_old);
      // if not already exists create subdirectory
      file_prepare_directory($new_directory, FILE_CREATE_DIRECTORY);
      // move file in new directory and show message
      $moved_file = file_move($file, $new_directory, $replace = FILE_EXISTS_RENAME);
      if ($moved_file) {
        drupal_set_message(t('<i>@file</i> uploaded to server.', array('@file' => $file_name)));
      }
    }
  }
}


How do I delete all the user's posts, using drush?

You could run something like this via drush php-script:

<?php
global $user;
$user = user_load(1);
$result = db_query("SELECT nid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE u.name = '%s'", 'alice');
while ($row = db_fetch_object($result)) {
  node_delete($row->nid);
}
?>

There's also http://drupal.org/project/user_delete.


I would take a look at the flag set up in each of your displays, and make sure you are using the same Flag - it's an easy oversight if you have multiple types of Flags and can cause this sort of behaviour.


Why does include() call PublicStream::stream_set_option()?

It happens with PHP 7.4, where one of the backward incompatible changes is the following one.

When using include/require on a stream, streamWrapper::stream_set_option() will be invoked with the STREAM_OPTION_READ_BUFFER option. Custom stream wrapper implementations may need to implement the streamWrapper::stream_set_option() method to avoid a warning (always returning FALSE is a sufficient implementation).

Even with the latest code committed in Drupal 9, LocalStream::stream_set_option() triggers the user error you are seeing.
public function stream_set_option($option, $arg1, $arg2) {
  trigger_error('stream_set_option() not supported for local file based stream wrappers', E_USER_WARNING);
  return FALSE;
}


Doing all of this within templates really shouldn't be the way to go. Write a custom module. And then do the following:

Use hook_menu() to create a page. Page callback would be drupal_get_form. Page argument would be YOURMODULE_form.
Inside YOURMODULE_form() you'll create your form. Check Form API for detailed info.
Finally you have to add a submit function YOURMODULE_form_submit() where you do your processing and use drupal_mail() to build and send your emails.

Maybe look at a little module I once wrote myself that follows a similar approach, form to mail, only it doesn't happen on a page but in a block instead. So that it can be placed on every page you want.


This is a rough sketch based on some other projects I've been involved in but the WP part is a bit uncertain. FWIW here it is:

1) install services, rest server and an auth module (like oauth or api_key) the on drupal and create an endpoint with resources for the user functions you need. Find a great tutorial by here. Essentially you should be able to push a php call with the json to your endpoint (Chrome's postman is a great tool to test this with) and get a 200 response if user was logged in or 401 unauthorized if not.

2) pause WP from processing user tasks on its side

3) export legacy WP users to csv and import users into Drupal using the user import module

4) Now you should be able to set ping your drupal from WP, get a reply back, set a session var if logged in and serve content on WP as if they logged in.

Granted, this is not an ideal setup but hopefully will carry you through the few months until you convert WP to Drupal.


How do I get access to fields of a node that a menu item links to?

You could use the menu_get_object() function or the arg() function. One of these 2 functions should do the trick. If i get you right ...


How to get entityreference_backreference data programmatically

OK this was my ignorance of how to use Entity Metadata Wrappers.
The way to get the value of the field_parent_user_eb field is

$wrapper = entity_metadata_wrapper("user",$some_user);
$value = $wrapper->field_parent_user_eb->value();

$value contains an array of entities which (back) reference the original $some_user.

I should have read https://www.drupal.org/docs/7/api/entity-api/entity-metadata-wrappers before posting.


Migrate API - Multiple multi language images in nodes

In the end, it was easy. Just follow the steps below:

Import files (only files, without alt and title)
Import content. For the field of image must have all the identifiers of the images and the alt and title. It is necessary to use the iterator plugin.

  field_images:
    plugin: iterator
    source: IMAGESVAL
    process:
      target_id:
        plugin: migration
        migration: news_images
        source: fid
      alt: alt
      title: alt


After restoring, incorrect database credentials are used

Some possible solutions / debugging steps:

Check that your local settings.php file is correct by using drush status command.
 Do this when in the same directory as the settings.php file (or with a correctly set up site alias).  You should see information about the database and drupal version.  If you don't then something is wrong with your settings.

Next, Drupal uses the DB to cache things in the DB.  This cached information in an SQL dump can cause a local site to crash.  Some ways to possible ways to correct this are:

On the local site, try using the drush cc (assumed D7 per tag) on the command line.

(OR)

Prior to making the dump from production, clear cache (either via admin screen or drush cc).

(OR)

Remove the contents of any Cache_* table on the local site (keep the tables)

Another possibility is that the password encryption salt string is different between the sites. This is set in the settings.php file and should be the same on both sites.

Finally, you can always reset the local user password via drush.  Two useful drush commands are:

drush uli --name=xxx  (Gets a password reset URL.. may need to put the correct host name)
drush upwd [username] [new-password]


Should I enable a feature I created on the same site?

Sure, you enable it. By that you keep track of changes you make on either development environment.

For example you edit some settings on your local dev site, then the activated feature will recognise the changes. Then you recreate the feature and commit the updated files to your repo. On live then you pull the file changes, which your activated feature there recognises as well.

Now you revert the feature on your live site and by that sync the settings you made on dev to live. All by having the feature activated on all instances you work with.


Creating a userlist in Views (including custom user fields)

Your question makes it sound like you've created a node view, listing content. If you create a view listing users, you should be able to accomplish what you're trying here.


yes - you can always do custom stuff, but miss all the features of the framework.

some pros:

works with javascript disabled (/nojs)
you can use the form-api 1:1 (more or less ..), so forms are reusable
you can use predefined commands (like replace or alert) and create your own
it's all ready for jquery ui
you can write your own and overwrite behaviors (and it's settings) from other modules
you can use drupal translations
with ctools it gets even more powerful, like modals, AJAX Responder etc.
there are a lot of modules you can use (qucktabs, modal forms, masonry .. you name it ..)
you can have all JS libraries managed
for JSON with website content you can use views datasource module

the contra is you need to be willing to learn and adapt :D


you can add extra field to solr.
you need to implement
hook_apachesolr_index_document_build_node(ApacheSolrDocument $document, $node, $env_id)

and there $document->addField('pdf_field_name', 'your_url');

also you need to implement hook_apachesolr_query_prepare(DrupalSolrQueryInterface $query)

and add there $query->addParam('fl', 'pdf_field_name');

then in your search-result.tpl.php
$pdf_field_name should be available (after reindexing)


Retrieve reference to content type in preprocess

try :

$value = $node->get('field_wheel-type')->getValue();


Create a custom block programmatically and specify region and pages on which created block must shown on

You have to create a block config entity to place a block:

use Drupal\block\Entity\Block;

  $placed_block = Block::create([
    'id' => 'block_machine_name',
    'theme' => 'classy',
    'weight' => 0,
    'status' => TRUE,
    'region' => 'footer',
    'plugin' => 'block_content:' . $block->uuid(),
    'settings' => [],
    'visibility' => [
      'request_path' => [
        'id' => 'request_path',
        'negate' => FALSE,
        'pages' => '/path',
      ],
    ],
  ]);
  $placed_block->save();


Using node hooks to set the user will work, but what you are suggesting is really what is normally called "workflow" in content management systems.

There are a few ways to do workflow in Drupal, but the most common for Drupal 7 is probably using the Workbench suite of modules.  In particular, Workbench Moderation would be the most beneficial module for your situation.

You would set up a few different roles (writer, editor, proofreader, etc) for your users.  You would then set up various workflow states (Draft, Pending, and Published are a good start).  Then, you define which roles can push nodes through which states of the workflow.  For example, you may say that only writes can push from Draft to Pending, and proofreaders can only push from Pending to Published.

In the long run, this will give you the most flexibility as your current situation evolves and changes.


How to create the equivalent of a spreadsheet?

The TableField or the Slickgrid modules may help here.


How to add onBlur attribute to ZIP code field in Address Field

In case anyone else has this same problem. I have learned that it's a better practise to only use Javascript with an addEventListener to do this job, due to the scope rules.

This is how I finally did it. Change the code to adapt the formatting to the standard format in your country. This one changes the ZIP code format to five digits with a space inserted between digit 3 and 4.

  if($("#edit-customer-profile-billing-commerce-customer-address-und-0-postal-code").length){
    document.getElementById("edit-customer-profile-billing-commerce-customer-address-und-0-postal-code").addEventListener("blur", function(){
        if(this.value.length>5 && /\s/.test(this.value)){
          this.value = this.value.substr(0,6);
        }   else if(this.value.length>5 && !(/\s/.test(this.value))){
                        this.value = this.value.substr(0,5);
                    }
        if(this.value.length===5 && this.value.substring(3,4) !== " "){
            this.value = this.value.split(/(?=.{2}$)/).join(' ');
        }
    });
}


Cannot add 'Page Title' and 'Main Content' blocks to panel

Answering my own question after I found some more info.

This is indeed a bug, hopefully to be fixed soon: https://www.drupal.org/node/2626090


I think the method below should do the trick. Don't think it is available in the flag_friend module's API.

/**
 * Gets the friend/unfriend link for a given user.
 *
 * Depending on the flagging user's current friend status with the target
 * user, the label of this link will show up as 'Add friend' or 'Remove friend'.
 *
 * @param stdClass $account
 *   Target user object. Defaults to the currenly logged in user.
 *
 * @return mixed
 *   FALSE or
 *   Formatted flag/unflag link otherwise.
 *
 * @see flag_friend_flag_default_flags().
 * @see flag_create_link().
 */
function flag_friend_get_friend_flag_link($account = NULL) {
  if (!isset($account)) {
    global $user;
    $account = $user;
  }
  return flag_create_link('friend', $account->uid);
}

Do note that the flagging user is assumed by default to be the currently logged in user which fits your use-case anyway.

Access check happens implicitly. So, if the current user does not have access to friend/unfriend a given target user, then this method will return FALSE.


How do I style a block title for a single menu in a fusion theme?

you could use

div.sidebar-first-inner h2.title {
   whatever css rules you need
}

which means set the css of an h2 with class title that is within a div with class sidebar-first-inner


You should use #button_type and #attributes onclick  like this.

$form['reset'] = array(
    '#type' => 'button',
    '#button_type' => 'reset',
    '#value' => t('Reset'),
    //'#weight' => 9,
    //'#access' => FALSE,
    //'#disabled' => TRUE,
    '#validate' => array(),
    '#attributes' => array(
          'onclick' => 'this.form.reset(); return false;',
        ),
    '#prefix' => '',
    '#sufix' => '',
);

Another option is to use Ajax like this.In the callback we can reset all form elements to default.I tried using $form_state['rebuild'] in there but it didn't work in my case.

 $form['reset'] = array(
     '#type' => 'button',
     '#value' => t('Reset all'),
     '#ajax' => array(
         'callback' => 'my_ajax_reset_all',
     ),
     //'#limit_validation_errors' => array(''),       // No validation.
);


CKeditor doesn't work in controller response within a default theme

A form usually contains all libraries necessary, but you shouldn't render the form at this point in the controller.

Put it unrendered in the template variable

return [
  '#theme' => 'customize_user_form',
  '#form' => $form,
];

and when you print the form in the template {{ form }} the libraries should be attached automatically to the page.


How to automatically update entity that is created programatically?

Not really. To figure out if an entity exists, you have to check that somehow.

If you're trying to optimize, you could run an entity query instead of loading it completely. But in case you want to update, you need to load the original entity anyway, so just do that.

$entity = SomeEntity::load(['my_id' => 'id123']);
if (!$entity) {
  $entity = SomeEntity::create(['my_id' => 'id123']);
}
$entity->save();


How to remove dropdown items from a form?

If the name of your field is edit-taxonomy-forums-und your code should be:

unset($form['edit-taxonomy-forums-und'][LANGUAGE_NONE]['#options']['4']);

Maybe you don't have the correct name of the field. Go to the Manage fields page of your content type (YOUR_SITE/admin/structure/types/manage/YOUR_CONTENT_TYPE/fields) and check the name of the field.

EDIT:

If you read the comments in the answer you will see that the problem was the change of forum_node_form by forum-node-form.


Check and see if the core module "Number" is enabled. It requires the Field and Field SQL storage modules to be enabled as well.


I ended up using the Bundle Copy module.


Forms don't have nid. Only nodes are having nid (node_id) in drupal. If you are displaying the form on any node page, suppose on http://example.com/node/123. Here 123 would be the node id and you can fetch it in form by

if (arg(0) == 'node' && is_numeric(arg(1))) {
  $nid = arg(1);
}

And if you want this $nid to be passed through different form states, add this as form field

$form['nid'] = array('#type' => 'value', '#value' => $nid);


That's a known issue in some Drupal versions: Drupal will not pick up node--blog.tpl.php from your theme directory unless there is node.tpl.php too. Just place them both in your theme, clear cache, and you should be fine.


How to set a new password using a module?

Okay, I was trying to make it more complicated than it is.

The user_save() function already hashes the password. This works:

// Prepares the user object with new password
$edit = array();
$edit['revision'] = 0;
$edit['pass'] = $password;

// Saves the user object
user_save($account, $edit);

There is no need to include the password.inc and to use user_hash_password().


How to unit test hook_form_alter implementation code in custom module

Don't, that doesn't make sense. Unit tests make sense for APIs and classes, things with clear interfaces and definitions what's the input/output.

A form alter means you're altering more or less internal structures from another module that might change over time. Especially backend forms are explicitly excluded from Drupal Core BC for example, which means that they can be changed over time. You want to do a full browser test to make sure that your logic/changes actually work in the resulting form that is displayed in the browser.

See https://www.drupal.org/docs/8/testing/types-of-tests-in-drupal-8 for documentation of different types of tests in Drupal 8 and when they should be used. There are 4 different types of test classes for a reason.


For my first question:
I'm sending data with this format and it works now

{
  "field_files":[

    {
      "fid": "445"
    },

    {
      "fid":"446"
    }
  ]
}

Where fid is the id of an existing and accessible file.

For my second question, I've written module extending restws classes that user can submit data like the way user submits for services rest api.

Idea behind my module is that user submits data and module checks validation data and if data is valid saves file using drupal file_save_data function.


How to override page.tpl.php with view's template file

First you define a specific display in your template: views-view-field--employee--page--field-first_image.tpl.php.

Then you don't specify a display in your insert tag, making it fallback to default.

To fix your problem you need to either strip the display part of your template name or specify a display in your tag, like [view:employee=page].

I would probably go for the first solution, so your theming targets all possible displays of that view, but how you do it really depends on your implementation.


Theme settings are specific to each theme. Go to /admin/appearance/settings/yourtheme and check for any theme-specific caching options. I can't tell you exactly what the options would be because that depends on your theme.


Multisite Drupal 7 sharing same code base

Having the folders that the message states in your sites/ directory involves two basic steps:

Creating the directories
Making the directories visible to the web server

In a typical Ubuntu installation with Apache as your server the first step is accomplished by executing the mkdir command in your sites directory:

Example

cd /var/www/my_drupal_site/sites
mkdir jobs.abc.com

and for the second step using the chown command.

chown -R www-data:www-data default
chown -R www-data:www-data jobs.abc.com

The chown command changes the ownership of the directory and with the -R flag it does the same thing recursively for every contained subdirectory and file. The www-data is the default user and group that Apache runs as (so if you have an nginx setup, you will probably have to change this).


How to print a date from Date module using user timezone

The problem is the configuration of the date field itself. In its settings (field management->edit), you will find an option "Time zone handling". This option controls the way this field is parsed and its display. I will venture a guess that yours is set to "Site's time zone". This means, that the default timezone will be used to convert this datetime into UTC, and the same will be used to display it. If changed to "User's time zone" option, then user's timezone will be used instead, and the default one will be the fallback if none such is set. The latter is taken into account from the format_date() function, without your having to set the $timezone parameter explicitly.

In your case, since each event has a timezone of its own, I would also consider the second option "Date's time zone". In this case, custom date timezone is not taken into account by format_date(), thus needs to be explicitly set.

Read the complete documentation here


Create a link to the fist item of a specific view block

Since this is a view block, you might be better of directly accessing the view:

$results = views_get_view_result('my_view', 'block1')

Where block1 is the Views display ID. Leave it blank to utilize the default display.

Then

$node = $results[0];
$url = $node->toUrl()->toString();
$link = \Drupal::l('My link', $node->toUrl());


How to safely render node body on a custom variable?

Build a render element processed_text and set the text format from the body field, so that the right text filters are applied before you print the field with {{ body }}:

If you have the node in #test like in your second example:

'#test' => $node

then you can build the render element in twig:

{% set body = {
  '#type':   'processed_text',
  '#text':    test.body.value,
  '#format':  test.body.format,
} %}

{{ body }}

This is the preferred method, see the documentation of check_markup():

  Note: this function should only be used when filtering text for use
  elsewhere  than on a rendered HTML page. If this is part of a HTML
  page, then a  renderable array with a #type 'processed_text' element
  should be used instead  of this, because that will allow cacheability
  metadata to be set and bubbled  up and attachments to be associated
  (assets, placeholders, etc.). In other  words: if you are presenting
  the filtered text in a HTML page, the only way  this will be presented
  correctly, is by using the 'processed_text' element.

https://api.drupal.org/api/drupal/core%21modules%21filter%21filter.module/function/check_markup/8.2.x

Render element in php:

'#test' => [
  '#type' => 'processed_text',
  '#text' => $node->body->value,
  '#format' => $node->body->format,
],

and print in twig:

{{ test }}


Contextual Filters in a 'Tree-style' View

I found a rather clean and intuitive solution, however I am very interested in other, more straightforward answers if they exist.

I created a new Computed Field, called parent_project_computed field which:

calculates the parent-project based on the parent_main_task
field(which is entity reference) if it's a Sub Task content type
calculates(basically just copies) the parent_project field if
it's a Main Task content type

This way both the Main Task and Sub task have a field which stores the nid value of the Parent Project. Then I use a contextual filter based on this new parent_project_computed field and both content types match this filter so they show up in the results just fine.

This is the PHP I wrote within this new computed field:

$entity_field[0]['value'] = null; //initial value null, should get overwritten in IF's below

//if field_parent_project exists just copy it's value
if (array_pop(array_pop(field_get_items($entity_type, $entity, 'field_parent_project')))) {
   $entity_field[0]['value'] = array_pop(array_pop(field_get_items($entity_type, $entity, 'field_parent_project')));
}

// if 'field_main_task' exists get it's value, load the node and get the E-R value within it
if (array_pop(array_pop(field_get_items($entity_type, $entity, 'field_main_task')))) {
    $nid = array_pop(array_pop(field_get_items($entity_type, $entity, 'field_main_task')));
    $node = node_load($nid);
    $info = field_get_items('node', $node, 'field_parent_project');
    $entity_field[0]['value'] =$info[0];//ER fields store data in array, since this is a single value ER field it always sits at position '0'
}

//Note: E-R value means Entity Reference value.

If the PHP code can be made more, err bulletproof, I'd appreciate a comment below.
Thanks.

Update:

On saving each Task you need a post-save custom hook to reload and resave all the Subtasks in order to update their 'Parent Project' computed field which has now changed. We've used this module which provides some nice additional post-save hooks and some more.


File save upload doesn't replace existing file despite FILE_EXISTS_REPLACE

This is drupal's default behaviour and a known issue. It has been addressed a couple of ways.

The Upload File Replace module addresses this issue by swapping the filenames so the new file retains the original name.

The Media Update module allows in situ replacement of media files (part of the Media project).

You could either make use of one of these modules, or use them as a model for your own function.


Allow only certain user type to create account

To disable account creation by anonymous:
At admin/user/settings check "Only site administrators can create new user accounts"

Allow the account-creator role to administer users:
At admin/user/permissions -> user module -> administer users

Use a module such a Protect Critical Users if the account-creator role should not be able to touch the superuser (user1).


How to add 'read more' link in Blog comments

You can override comments template for your blog content type and in the template add the read more link.

In order to override the template simply copy the existing comment.tpl.php to your theme/templates and rename it to comment--node-blog.tpl.php and edit it to add the read more link.

on click of this you will be running jquery codes to toggle the comments below.


How to add data to a message type custom field that's inherited by all message instances?

I didn't actually figure this out. I probably could have by looking at the way commerce orders get attached via entity reference to messages and done that. Instead, I used the commerce order that was attached to the message, which had the commerce store ID, to load the field on the organic group that was referencing the store and then add that field as a token.


How do I remove the itok token from the image URLs?

While it's recommended to keep the itok parameter, it is configurable.

You can suppress it from output using the image.settings config setting suppress_itok_output

  // The token query is added even if the
  // 'image.settings:allow_insecure_derivatives' configuration is TRUE, so
  // that the emitted links remain valid if it is changed back to the default
  // FALSE. However, sites which need to prevent the token query from being
  // emitted at all can additionally set the
  // 'image.settings:suppress_itok_output' configuration to TRUE to achieve
  // that (if both are set, the security token will neither be emitted in the
  // image derivative URL nor checked for in
  // \Drupal\image\ImageStyleInterface::deliver()).

https://api.drupal.org/api/drupal/core!modules!image!src!Entity!ImageStyle.php/function/ImageStyle%3A%3AbuildUrl/8.2.x


Drupal 7 Click tracking / traffic per node

The google_analytics_reports module is a starting point for you to look at. I don't think it will cover all your requirements.


How to get form variables data into twig templates?

Put the custom variable in a key with a '#', so that the formbuilder doesn't try to render this as a form element.

buildForm():

  $form['#myvars']['var1'] = 'xyz';

In twig you can access the variable in element:

form.html.twig:

  {{ element['#myvars'].var1 }}

If you set a template in #theme of the form build

buildForm():

  $form['#theme'] = 'take_mcq_form';

you get a second template inside of form.html.twig, where you can access the variable in form:

take_mcq_form.html.twig:

  {{ form['#myvars'].var1 }}


When I edit a display within a view, it changes other displays too

Never mind! I figured it out... Each display was still overriding the others, but I found where to change that and everything is good!

For anyone else with the same question:
When you click on a filter criteria, you can select options in the drop down at the top of this overlay which specifies whether you would like to apply the changes to all displays or just this page.


Create donation product with Commerce Kickstart

Someone replied on the Commerce Donate issue thread with a solution.

The solution is to manually go to: /admin/commerce/products/add/donation where you can then make your product.


Why are my nodes not showing up in a Panel?

Since the problem of non-displayed Panes can be caused by quite a lot of things, it can also take quite a lot of time to find a solution (2 days in my case). It turned out that I had overwritten panels-pane--node.php.tpl in my custom theme and that I accidently put an if statement around the whole code, which only returned TRUE for one specific node. Woops...

In order to make the searching process a bit easier for future users who have a similar problem, I will sum up some stuff to try underneath.

Maybe it's a theming thing

If you have a custom theme, your first reflex should probably be to take a look at it. (That being said, my reflexes aren't that good apparently.) First, use a tool like Firebug to inspect your Panel and make sure that the Pane isn't printed. Something like a lost visibility: hidden; can easily be solved in your CSS files. If your Pane just isn't there, maybe there is something wrong with one of your templates. Take a look at the templates that start with panels-pane.

Maybe it's a Panels thing

Take a look at the Pane's settings in your Panel. As CodeNext suggested in the comments above, check that the active style is No Style. In other cases, there can be a problem with (the CSS of) that style. Also, make sure that you didn't set a visibility rule that hides the Pane for you.

Maybe it's a clashing modules thing

P Magunia suggested that the jQuery version can affect the proper working of Panels. If you installed jQuery Update, you can temporarily deactivate this module to see whether something changes. In my case, nothing happened. Also, install the latest versions of all modules on your website. Maybe the Panels module clashes with another outdated module or is outdated itself (see  No Sssweat's comment).

Taking Jimmy Ko's remark into consideration, I reinstalled an old backup of my website, where the problem did not arise, and updated all installed modules. Since the problem was still there, I could convince myself that the hidden Pane was not related to any module. Yet another reason for backing up your website's (WAMP) folder and database.

PS: Maybe it's an alien thing

If none of the above hints worked, no error messages are shown, Google lets you down, and you have been clicking and typing around for days, probably some aliens hacked your website and are making fun of you. Beware, they are potentially dangerous. Never lose your temper...


Can't set a default theme in a FunctionalJavascript test with $defaultTheme class property

I wound up installing a barebones install with drush si and exporting certain configuration to an install profile. After adding this to drush si in CI and local, all functional javascript browser tests work without complaints.

I double checked and the parent BrowserTestBase class does have defaultTheme and profile properties, so I don't know why those were not installed.


Different Image on each Mainmenu entry in Drupal 7

You may try this module, which seems to do exactly that.


How to submit a user profile form through ajax?

Below module will help you

Modal forms (with ctools)

  Modal forms make use of the modal feature in the ctools module to open
  some common forms in a modal window.

Log in (modal_forms/nojs/login)
Request new password (modal_forms/nojs/password)
Create new account (modal_forms/nojs/register)
Contact (modal_forms/nojs/contact)
Comment (modal_forms/nojs/comment/reply/%node)
Webform (modal_forms/nojs/webform/%node)

  Function that rewrite normal links to modal forms links (except for
  webforms) can be activated on the modules configuration page


Caching in metatag coused the problem. Disabling the metatags for users solved it.


Can I use a token within a custom token?

You could use something like token_replace() to get the other token value within your own token, but you shouldn't try to alter an already created token, as that will mess up when you really want to use that token.

You need to define you own token, and handle the output of that token. But in doing so, you will most likely find that it will be easier to get the raw values from the PHP values supplied instead of using token_replace() or something similar.

You need to look at hook_token_list() and hook_token_values() to define your custom token.


I don't think there is such a function. However it's not hard to create your own. Here's an example:

function load_files_by_type($type, $id) {
  // Select all used files by type and id.
  $query = db_select('file_usage', 'fu')
    ->fields('fu', array('fid'))
    ->condition('fu.type', $type)
    ->condition('fu.id', $id);

  // Load all file ids in an array.
  $fids = $query->execute()->fetchCol();

  // Return the file objects.
  return file_load_multiple($fids);
}

You can call it like this: load_files_by_type('node', 64);

Of course you can alter the query to your liking, you could even add a module check.


Access denied to all profiles of a certain type

I think I understand what's happening now. During migration, empty profiles were made for users who did not have profiles on the origin site. That is why access is denied: there isn't anything to access. That message really should be "a profile doesn't exist yet," or something like that. I can see the existing profiles without any issue.


Dynamically linking from author name(s) in a View to a nodes by author View

Assuming that authors are the user that created the piece of content and not an entity reference field, and that you're using D7:

Create a clone of the current view that you're using, assuming that you want the author's list of nodes to have the same layout/fields/what have you that the current view you're working with does, and create a new page for it.
For the path of the new view, create a path that includes a wildcard (%) such as /posts-by-author/%
Under Advanced, add a Contextual Filter for Content: Author uid. When you put in a user's UID in the "Preview with contextual filters" box above the preview and hit Update preview, it should show you that user's posts.
Now, back to your original view. Assuming that you're using a display format that requires fields, add the Content: Author uid field to your display and set it to "Exclude from display".
Under "Add" there's a "Rearrange" option when you click the arrow next to the Add option. Rearrange the fields so that the UID field is above the name field. This will allow you to use it in the name field when you create a link.
Under "Rewrite results" select "Output this field as a link" and enter the link path with [uid] replacing the wildcard symbol.

Now, when you click on an author's name, it should take you to a page that displays all the nodes created by that author.


How to use Views PHP to code if a view exists and has content then echo...

You can look at views_get_view_result() and do something like this:

$result=views_get_view_result('teachers');
if (isset($result[0])) {
  // we have results
} else {
  // we don't
}


Problem with displaying field using Views

If this is a Solr/ElasticDB search backend under Search API, you could try this approach.

Create a view mode on the node type (ex. Search Result), then create a template with the html markup when rendered for it. Include all the fields in the display and configure the formatters as you want them.

Next, install Search API View Modes, and configure that view mode to be indexed. It will render that node before indexing it into a new field (search server side). Then, you can create a view display that shows that field, which is just HTML, and bypass some of these issues.

I use this method in every Search API based search I encounter. You're basically storing the rendered HTML on the search server, then printing that as the result.

I can't tell if you are on Drupal 7 or 8. Note that the 8.x branch 'works' but may have some bugs. I have only been able to test simple setups and not use it on production like the 7.x branch.


Redirect to a specific page when user update their profile

You can add a custom submit handler to the user edit form and then do the redirect there:

function mymodule_form_alter(&$form, $form_state, $form_id) {
  if ($form_id === 'user_profile_form') {
    $form['#submit'][] = 'custom_submit_function';
  }
}

function custom_submit_function($form, &$form_state) {
  drupal_goto('node/xxx');
}


How to get read count of blogs in Blog module?

The core Blog module does not track read statistics for content; that's the purview of the Statistics module.

To enable read statistics:

Install the Statistics module.
Follow its configuration link (/admin/config/system/statistics).
Set the Count content views option to enable view counting.


Populate questions and answers (Display two types of content two different ways on one page intermittently)

You also get a "Answers to a Question" view with this module. Change display format to "Fields" and create a block pulling all the fields you need. You might as well find Relevant Answer (extends Answers) helpful found here.

  The module provides two predefined blocks to display questions and their corresponding answers: 'Popular Questions' and 'Recent Questions'.

Edit: Import this view- you should get a "Q & A feed" block which populates questions and its answers, apply a sort criteria to meet your need.

$view = new view();
$view->name = 'q_a_feed';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Q & A Feed';
$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'] = 'Q & A Feed';
$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'] = 'full';
$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: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
/* Field: Content: Answer to the question */
$handler->display->display_options['fields']['field_answer_question']['id'] = 'field_answer_question';
$handler->display->display_options['fields']['field_answer_question']['table'] = 'field_data_field_answer_question';
$handler->display->display_options['fields']['field_answer_question']['field'] = 'field_answer_question';
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'answer' => 'answer',
  'question' => 'question',
);

/* Display: Q & A feed */
$handler = $view->new_display('block', 'Q & A feed', 'block');


How to apply pagination on checkbox options of form elements in Drupal?

Best option you can do it without checkbox in pagination you can enable module like multiselect widget which work like dropdown with checkbox field.


The solution given by DrupalMonster is a straightforward, but barely scalable. I've been through a similar scenario and I eventually gave up on it when it got to real life.

I haven't been at Drupal for some time but I hope my suggestion will get you going.

Make a view that lists the terms. You will want to use contextual filter with node ID to tell Views which node you are viewing, and then test it (using normal environment) to make sure that it retrieves appropriate terms.
Once your view is working well, install Viewfield module. The module will provide a new field "Viewfield". Attach an instance of it to your node content type and configure it to display the View you have tested.
Theme the view using Views' tpl naming convention, accessible from Theme information in the Views editor.

HTH


I lost permission to access admin/content for user 1

Solved: the problem was the module: admin_views I just disabled it and the problem was gone.


You should put a wrapper around the fields of which you want to reload/refresh (basically replace) and in the call back return the either the form values in an array or the wrapper.

This basically means that on the event specified in the callback, eg change the whole wrapper div is swapped out and replaced with a new one built by the php in your form.


Importing nodes with Node export is creating them in "unpublished" status

At admin/config/content/node_export there is Reset values on import > [your node type] > Published checkbox, which is not checked by default. Checking this will reset the published status, which means nodes will be unpublished (that's how I interpret that anyway). So leaving it unchecked will not change the status. There seems to be no way to force nodes to be published.

If needed, on the new site nodes can be mass published at admin/content.


Call another view with a single exposed filter

Wao! A brilliant idea. But where do i add the JavaScript? In the
  themes folder or in the created views?

In template.php located in sites/all/themes/yourtheme

Add the following code at the bottom:

function yourtheme_views_pre_render(&$view) {

   if ($view->name == 'view_name') {
    drupal_add_js(drupal_get_path('theme', 'yourtheme') . '/js/custom.js');
   }
}

replace yourtheme with you actual name of your theme.
replace view_name with your view name.

Also, you'll need to wrap/format your jQuery code like this

/sites/all/themes/yourtheme/js/custom.js

(function($) {

    //your code goes here

})(jQuery);

PS: Don't forget to clear the cache to see the changes.


Why are only a few actions available on my triggers page?

I had the same problem. The solution is to use the RULES module which is the successor of Triggers. If you want to use Triggers anyway (you shouldn't as my impression is it is being phased out and migrated to RULES) you would have to do code modifications (via drupal hooks).

With Rules, you can have all these options about publication of nodes and even more.


Which hook to use when a date is going to be saved into the database

If you are only using nodes then yes, implementing hook_node_update is a good approach. You also will need to implement hook_node_insert if you need to do logic when the nodes are first created.


Are you familiar with Boostrap or Zurb Foundation framework? I suggest you research either of these 2 frameworks and you will find that you can accomplish your goal using either one.

Here is a little background. Basically they are just a javascript file and css file. The javascript file has code for a ton of common/widely used features and built to be mobile responsive.
All you have to do is assign your divs a specific class name and they will get a certain functionality. You can find the class names that you need to use on their documentation page.

In Drupal, you can use the Boostrap theme or Zurb Foundation theme to build on top off. These themes have done some of the work for you. Ex: assign all the buttons the proper button classes using a preprocess function.

Here are specific tutorials regarding your question:

Bootstrap 3 Tutorials - #2 - Responsive Collapsing Navbar

Zurb Foundation | Top-Bar Tutorial


Customizable product bundles, user can add/remove products

My solution goes here based on Drupal Commerce-
Step 1: Create Product Bundles using Commerce Bundle module. (which you already know).
Step 2: Now you have bundles. The next step is your custom functionality to swap at most two products from the bundle.
Add a new step to your checkout process to implement the custom functionality refer Add a new step in Commerce checkout, explore commerce_checkout.api to get the hold on this.
Adding a new step is nothing but adding a new pane (inside a checkout page) in a Drupal Commerce checkout process where you can list the products in the cart and process them using hook_form_alter().
Refer this link for more details hook_form_alter.
You can make use of hooks provided by Drupal Commerce such as commerce_cart.api, commerce_order.api to edit/update the cart.
Step 3: After processing the cart contents you can update the order details/status using commerce_order.api.
You can alter the checkout pane settings from Home » Administration » Store » Configuration » Checkout Settings page.
Note: You must have Drupal 7 module development knowledge to implement the above solution.
I hope this helps! Thank You.


you can use this js code

 $('.page-node-webform #edit-actions #edit-save').click(function() {

                return confirm('Are you sure?');

            });


views filter for current user with a relationship

If I correctly understand the requirement then you are missing the relationship between content type 1 and 2

You need a view of nodes with:

A filter that only shows node of type A.
A relationship from node type A to node type B via your reference field.
A relationship from node type B to its author user.
A filter to restrict the user author (of content b) to the current user.


Why is the CSS for my theme not loading while the JS is?

try wrapping the google fonts entry in quotes like this:

'//fonts.googleapis.com/css?
family=Open+Sans:400,300,600&subset;=latin,cyrillic': { type: external }

Maybe there is a problem with the url using yaml special characters https://stackoverflow.com/questions/19109912/do-i-need-quotes-for-strings-in-yaml#22235064


I would use that contrib module. Beta releases are generally darn tight and seeing that it is beta3 would lend to the idea that it will soon be out of beta. (Of course it may never come out so that doesn't say much.) Also, the maintainer group seems to be high quality which gives me even more confidence.

To answer your other question I do not thing there is anything else you can do besides write something yourself. I was looking around and saw some initial phases of work being done on this but nothing as far along as that project you linked. I imagine this is something they will work on for D8. Your find is surprising. The only other place I might check if I were is IRC just to make sure that there isn't some other optimization technique or module out there that isn't Views specific but that will help. (Probably not, but worth a try.)


My sitemap.xml have a different domain and this is an error

I think you have a setting wrong.

Browse to the XML Sitemap settings page (admin/config/search/xmlsitemap/settings).

Expand the Advanced Settings section.

Check/set the Default Base URL.  Typically, I set this to make sure the default base URL gets used, as rebuilding from drush won't set it properly if you don't $uri set in your site alias.


How to programmatically assign (attach) a file to file field while creating/saving the node?

I had a similar situation. My situation is attach a file to a node in the creation of a different content type node. Done this in hook_node_insert

Initially i uploaded all files into a temp directory in /default/files/.
Then for each node, i created a new file object with my file attributes.
Then moved that particular file into the destination where i want the files to be placed. This results a clean complete file object with fid.
Then simply assign this file object attributes to file field and save the node.

The code used is follows..

$source_node = node_load($nid);
$filename = $bio_file_name; //your specific filename
$dir = 'public://temp-path/'.$filename; //path to specific file with name
$file_size = filesize($dir);

//New file object
$file = new stdClass;
$file->uid = $source_node->uid;
$file->filename = $filename;
$file->uri = $dir;
$file->filemime = file_get_mimetype($dir);
// Make it permanent, otherwise it will get deleted later.
$file->status = FILE_STATUS_PERMANENT;
// Save file object to make it a 'managed file'.
$file_obj = file_move($file, 'public://newpath', FILE_EXISTS_REPLACE);

$source_node->your-file-field-name['und'][0] = array(
 'fid'  => $file_obj->fid,
 'uid'  => $file_obj->uid,
 'filename'  => $file_obj->filename,
 'uri'  => $file_obj->uri,
 'filemime'  => $file_obj->filemime,
 'filesize'  => $file_obj->filesize,
 'status'  => 1,
 'display'  => 1,
 'description'  => '',
 );

 node_save($source_node);

Hope this will help you..


D7 jquery dropdown menu categorized/ordered by content type and taxonomy

I now use custom menu items and the modules 'Taxonomy Menu' together with 'Nice Menu' and some custom jquery javascript.


What are the functions of the callbacks in the commerce payment method info hook?

You can find Contributed Modules API Documentation in http://drupalcontrib.org/ portal.

Please find link to above hook documentation hook_commerce_payment_method_info .

Callbacks Documentation links below...

CALLBACK_commerce_payment_method_settings_form()
CALLBACK_commerce_payment_method_submit_form()
CALLBACK_commerce_payment_method_submit_form_validate()
CALLBACK_commerce_payment_method_submit_form_submit()
CALLBACK_commerce_payment_method_redirect_form()
CALLBACK_commerce_payment_method_redirect_form_validate()
CALLBACK_commerce_payment_method_redirect_form_submit()

Check out commerce_payment_example module to find out how to write a payment method for more information.


Do something after submit the form at hook_form_alter

Sorry about that! My problem is fixed.

the code belowed is the anwser

function mymodule_form_node_form_alter(&$form,&$form_state,$form_id)
{
     if($form['#node']->type=="my_content_type")
     {
          $form['actions']['submit']['#submit'][]='my_callback_function';
     }
}

function my_callback_function($form, &$form_state)
{
     //my code here!!
     //execute after the user submit the node form
     //and then redirect user to another place,after executing the code above

}

[Edit] For me, the callback would not fire unless form_state was declared as &$form_state (pass by reference)


geofield types failed to add with commerce services

The answer is to send computed values via the geofield module api itself by Implementing the hook_request_parsed_alter like:

function my_module_request_parsed_alter(&$data, $controller) {
switch ($controller['callback']) {
case 'commerce_services_product_create':
case 'commerce_services_product_update':

  if (isset($data['field_geoloc'])) {
    $data["field_geoloc"] = geofield_compute_values($data['field_geoloc']['und'][0]['geom']);
  }
}

But I still wonder why not working by default as node create request


user_login_block not displaying status messages

I think you are embedding Login Form directly in .tpl file. Either assign login block to some region or bring it through a variable from hook_preproces_page() function.


Print just field data from a view into a block?

If what you're trying to get is the number of results returned from the view then your best bet might be to call views_get_view_result():

$result = views_get_view_result($name, $display_id);
$num_blogposts = count($result);

However, if that's what you're trying to achieve then it might be better from a performance point of view to bypass views entirely and get the count with an EntityFieldQuery.

-- EDIT --

Option 2:

You could override the various templates that make up the view, removing any unnecessary markup from each.

To do this, Click on "Theme: Information" in the "Advanced" section of the view edit page (bottom right) and you'll see a list of templates used.  Click each one in turn and create a new file in your theme folder and copy in the contents before removing any unnecessary markup.

What you name the file is important, back on the list of templates, note that each one has a large number of filename suggestions, ranging from very generic to very specific.  Choose the name with the the most appropriate degree of specificity and name your file that. note that for example calling your Display Output template file "views-view.tpl.php" will mean that your override will have effect on every single view across your site, so a more specific filename should lock it down to a specific view/display/etc.

Once you've done this, you'll need to flush the theme registry cache before you'll see the change.  The easiest way to do that is by clicking "Rescan template files" at the bottom of the theme information dialogue.

Finally note that these updates won't change what you see in the views preview unless you also make these changes for the admin theme.

note that if you are also rendering the view normally (in addition to the views_embed_view) where you want to see the original markup then you should probably use a new display of the view for this and make sure your template names only target the correct display.


Sounds like you are not using the right version of Drush.  For Drupal 8.0-beta7, you need Drush 7.0.0-alpha9.  For Drupal 8.0-beta6, you need Drush 7.0.0-alpha8.

Drupal 8 APIs are changing rapidly; if you have mixed versions, you can easily encounter spurious problems.  Tracking HEAD of Drupal 8.0.x and Drush master is another viable strategy.


Better Search Api Solr score sorting for strict word match in Drupal

Having just worked with Solr myself (for English) text. You need to assure Solr is Configured to search how you want. Out of the box the Solr configuration provides:

a case insensitive, stemmed search (fuzzy, such as "savage" searches for "savage", "savages", "savaged", etc. and the search ignores punctuation. It also supports short phrase searching such as "find me this text" although Search API in 7.x-1.20 has a bug that removes min_length words from quoted strings:
https://www.drupal.org/node/2832196

This issue is resolved in the current -dev release available on 12/09/2016.

You have 2 options

So, if the default stemmed search works for you as-is OK. If you want exact word searching with no stemming you need to alter the Solr schema to index text content differently than it does out of the box.

For non-stemmed, case sensitive searches change the analysis and query and multi-part logic to not use SnowballPorterStemmer and CaseInsenitive.

This is kinda outlined, but out of date for Solr 5x in this drupal issue.
https://www.drupal.org/node/1319516#comment-5158076
Solr 5x depercated enablePositionIncrements=true so don't do that in the comments, and it will work.
If you like the searching as-is. You can alternatively boost the exact words to score higher than the inexact results. You would do this by:

adding a fake entity property using an alter hook, and copying the text content from your fields into that field.
You would then define a Solr field in the solr schema to use for this drupal entity property field which doesnt use stemming to returned results
include this fake property field in your drupal search api Index.
use an alter hook for the solr query include this field with a boost (&myfield="FOOBAR"^10) in your search query.

Here's how you add a fake entity property to then be boosted:
http://cornel.co/article/add-entity-property-node-which-can-be-used-search-api-index-field

Then it's simply a query alter in your form (here for apachesolr module, but for search API it's the same thing):
https://www.phase2technology.com/blog/techniques-to-improve-your-solr-search-results/

Isn't Solr fun!!! (sigh) it's really cool, but also cumbersome.


Add an Argument to your view with Taxonomy: Term ID (with depth). You may want to use %2 for the title (or %3?). At the bottom of the argument config form you'll see "Set the breadcrumb for the term parents."


When I load an overlay to edit a node, how can I open a specific vertical tab?

I took a look at vertical-tabs.js, and as best I can tell you'll have to add some JS to the page to trigger the click event on the correct link. On line 33, the Drupal.verticalTab object gets instantiated, but not assigned to a namespace where you can get to it later to run its focus() method. (This would be a good thing to fix in D8. Hmm.)

So basically, you need a .js file that does something like

(function ($) {
  Drupal.behaviors.yourModuleName = {
    attach: function (context, settings) {
      $('a:contains("Revision information")').click();
    }
  };
})(jQuery);

where "Revision information" is the actual text of the link that opens your vertical tab.

Note: There is some URL fragment handling in vertical-tabs.js, which I think is supposed to make it so that if you set the URL fragment to the id of a fieldset, that vertical tab will open automatically. It might be worth trying, but I couldn't get it to work even on a non-overlay page.


The return value from file_save_upload() is:

  array Function returns array of files or a single file object if $delta != NULL. Each file object contains the file information if the upload succeeded or FALSE in the event of an error. Function returns NULL if no file was uploaded.

So you can handle it a few different ways.

$picture = reset($pictures);
if ($picture === FALSE) {
  $form_state->setErrorByName('field_name', $this->t('Error!'));
}

or

$picture = reset($pictures);
if (!$picture instanceof \Drupal\file\Entity\File) {
  $form_state->setErrorByName('field_name', $this->t('Error!'));
}

are the first that come to mind.

This code will need to be in a validate method rather than a submit method, so that you're setting errors in the right place. You can leave the ->save() logic in the submit method, safe in the knowledge that the file has been validated and exists before that code is executed.


Autocomplete ahah combo is not working in Drupal 6

you need delete 'event' => 'change' or change event value


What are the performance implications of running a frequent simplenews cron task to send emails?

Once every 30 minutes will most likely not cause any issues. I've never used that module before so I can't saw with 100% certainty. If you where to change the frequency from 30 minutes to 1 minute I might start to worry as that could increase your server load.


Limit the number of nodes created from anonymous users

Drupal 8 invokes a specific hook when an entity is created: hook_entity_create_access(). Apart that, Drupal 8 code has been converted to a more OOP code, and it uses methods where before it used functions.
The following code is the one I would use for Drupal 8.
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Session\AccountInterface;

/**
 * Implements hook_ENTITY_TYPE_create_access().
 */
function mymodule_node_create_access(AccountInterface $account, array $context, $entity_bundle) {
  $flood = \Drupal::flood();
  if ($entity_bundle == 'type_of_interest' && $account->isAnonymous()) {
    if (!$flood->isAllowed('create_node', 2, 43200)) {
      return AccessResult::forbidden('There is a node creation limit of 2 nodes per 12 hours.');
    }
    $flood->register('create_node', 43200);
  }
  return AccessResult::neutral();
}


In exposed form settings enable reset button and give label save it you will get reset button


It sounds like a case for the Webform module.

  Webform is the module for making forms and surveys in Drupal. After a
  submission, users may be sent an e-mail "receipt" as well as sending a
  notification to administrators. Results can be exported into Excel or
  other spreadsheet applications. Webform also provides some basic
  statistical review and has an extensive API for expanding its
  features. Some good examples could be contests, personalized contact
  forms, or petitions.

https://www.drupal.org/project/webform


That extra field is added from the Views module itself, in particular its views_plugin_query_default::add_signature() method, which is described as:

  Add a signature to the query, if such a thing is feasible.
  This signature is something that can be used when perusing query logs to discern where particular queries might be coming from.

If you look at its code, it is setting the view_name field.

function add_signature(&$view) {
  $view->query->add_field(NULL, "'" . $view->name . ':' . $view->current_display . "'", 'view_name');
}


I don't know anything about the Instagram API, but if you want to keep the like counters up to date you will need to make API calls at some point.

If you expect many viewers then as you say, you probably don't want to make that call every time a user goes to the gallery, I would suggest adding another function to cron that iterates through your currently active Instagram content and refreshes the like counter.


How to use Services Basic Authentication?

The module authenticates a web service call against drupal accounts.

Enable the module
Setup a drupal user
Make the web service call with the credentials of the user.

Note that with basic auth, the credential can be intercepted if SSL isn't used.

The module uses the standard PHP authentication headers and submits the standard drupal login form, without checking for any specific roles or permissions. So any drupal user will work.

Make a test web-service call with curl or wget to test it. There are also instructions in how to call with PHP in the call with curl stackoverflow answer.


Partial start date with end date output views

I have resolved this issue using the compact daterange module, and using one of the committed patches.

https://www.drupal.org/project/daterange_compact


Programmatically render an imagefield in Drupal 6 as defined in content-field.tpl.php

Do you have more than one image?

print content_format('field_image', $vars['node']->field_image[0], 'default', $vars['node']);
print content_format('field_image', $vars['node']->field_image[0], 'image_imagelink', $vars['node']);

Try again with [0] instead of [1]. I use those all the time and it works fine like that.


CKEditor doesn't load when using Bootstrap theme

Solved.  The I am using the development version of jQuery_update which provides a fallback version of jQuery to use on administrative pages.  -- https://drupal.org/node/1524944
It determines whether or not to use the admin version based on if the current_path() is found in the return value of path_get_admin_paths().  Unfortunately for me,  node/add is an administrative path. So, jquery_update kicks in and loads jQuery 1.5.2 to be compatible with the administrative task. It seems CKEditor can't operate with 1.5.2. I noted above that CKEditor loaded without issue for a comment field on a node. Since viewing a node isn't an administrative path, the page was allowed to load jQuery 1.10 which works fine with CKEditor.
For now, I added an array of paths to exempt from admin status (node/add, node/add/post, etc) and added that to the evaluation in jQuery_update. Content creation pages now load jQuery 1.10 and CKEditor appears normally.
UPDATE: in place of the array of exempt paths, I have put in place the patch posted by muschpusch at https://drupal.org/node/2141205 . It has solved this issue.


You need to add a relationship to your view on the nid. Once you do that you will have the fields from the parent node available to be added to your view.


Clear data stored with drupal_static() and cache_set()

The Drupal way is to have a $reset parameter to your function.  It would look something like:

function _mymodule_call($reset = FALSE) {
  if ($reset) {
    // do stuff
  }
  // ...
}

node_load() is probably the best example of this.

In your specific case, you can pass the $reset parameter to drupal_static() or explicitly call drupal_static_reset().  For the cache backend, you need to think whether you want to just rework the logic and just do the cache_set() or explicitly call cache_clear_all($cid) (my guess is the former).

And remember, that drupal_static() is only effective when you need the value multiple times during the same request.  This does not persist between page loads (or any other HTTP request that get handled by Drupal).


call from form alter - undefined function error

You have a typo error in your code.

Change

$form['#submit'][] = 'my_search_form_submit_funtion';

To

$form['#submit'][] = 'my_search_form_submit_function';


A field that is not defined as unique key or primary key is allowed to have the same value in different records of that database table. So, if you don't want to have the same value of aid in two different records, you need to define it as unique key, if it is not already the primary key.

Notice that the line defining aid_vid as unique key would allow the following records.

aid  | vid  ! other_field
-------------------------
1      3      10
1      4      22
2      4      14

Only the line defining aid as unique key avoids two records have the same value for the aid field.


Solution for preventing indexing of content types?

Rather than coding a custom solution, I would use a supported module. The answer I believe will help you: Restrict Drupal Search to few content types

So for Drupal 7 you can use Custom Search, Search Config or Search API Exclude if you are using Search API. For Drupal 8 you can use Search Exclude.


Module Uninstall Validators and Lazy Services

It's a property of services classes provided by Symphony's dependency injection framework. Per its docs on lazy services:

In some cases, you may want to inject a service that is a bit heavy to instantiate, but is not always used inside your object. For example, imagine you have a NewsletterManager and you inject a mailer service into it. Only a few methods on your NewsletterManager actually use the mailer, but even when you don’t need it, a mailer service is always instantiated in order to construct your NewsletterManager.

In other words, proxy classes are quick-loading dummy stand-ins until the actual class methods are needed to do the heavy lifting. In this specific case, the Book uninstall validator isn't useful until it's needed during the book module uninstall so there's no need to fully instantiate the validator service.


Setting permissions via drush make; auto-copy settings.php?

make sure you go through all the options available at drush help make . This option should help you :

  --prepare-install   Prepare the built site for installation. Generate a properly permissioned settings.php and files directory.