How do I create a jump link to a paragraph item?

Perhaps Paragraphs Table of Contents module is good enough for what you describe.
From the project page

If you have long pages on your site, then it helps visitors if you can provide in-page navigation, or a table of contents.
If you build your long pages with the Paragraphs module, then you can use Paragraphs Table of Contents to provide the in-page navigation. There is one link in the table of contents (ToC) for each paragraph on the page.


Render parent paragraph depending on dynamic data from child paragraph (e.g. db query)

I don't understand the code and what you are trying to do, so I answer the question in the title and the last part of the question:

  How can i access a child paragraph's render array from the parent? Or
  is there a better approach to achieving a similar result?

Don't use the render array, use the parent paragraph entity to get the child paragraphs and their field values:

use Drupal\Core\Cache\Cache;

/**
 * Implements hook_ENTITY_TYPE_view() for paragraph entities.
 */
function MODULE_paragraph_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
  $bundle = $entity->bundle();
  // check if this is the parent paragraph
  if ($bundle === 'gigs_teaser') {
    foreach ($entity->field_child_paragraphs->referencedEntities() as $paragraph) {
      // get a field value from a child paragraph
      $field_value = $paragraph->field_example->value;
      $build['#cache']['tags'] = Cache::mergeTags($build['#cache']['tags'], $paragraph->getCacheTags());
      ...
    }
  }
}

Node query

I think I understand now the issue more. You ask probably the wrong question, because the "dynamic data from the child paragraph" is in reality not data from this paragraph, but from a node entity query. If you want to access this query data from two places in code, then put the code in a function and store the result in a static variable so that it is not calculated twice.


Checkout these modules:

qTip (Stylish jQuery Tooltips):

  qTips are stylish tooltips that can be configured and styled (more to come in later releases) to fit nearly any website's design. You can look at demo here.

Field Tooltips:

  Field Tooltips provides a user interface for adding tooltips to fields. Field Tooltips includes three important features:

  A simple administration interface for adding tooltips to fields.
  Support for all field types.
  Support for HTML tooltips.

Beauty Tips:

  The Beautytips module provides ballon-help style tooltips for any page element by integrating the BeautyTips jQuery Tooltip plugin by Jeff Robbins with Drupal. It provides an API for adding custom beautytips as well as some built-in features. Admins can enable rollover balloon-help style tooltips for text fields within forms. It also supplies hover tips for Drupal help links and advanced help links.

  Most importantly, it allows developers to add their own custom beautytips popups to their site without having to delve into jQuery.


Start with creating 3 content types like so:

Borrower, with as fields the various attributed you mentioned within Borrower Information.
Asset, with as fields the various attributed you mentioned within Asset Details.
Loan, with as fields the various attributed you mentioned within Loan Information.

Then use the Entity Reference module to add 2 more fields to Loan:

a 1st entity reference field to indicate the Borrower.
a 2nd entity reference field to indicate the Asset.

Then use the Views module to build all sorts of lists. Such as a Loan history, which could simply be a list all nodes of type Loan, in which you'd also want to add a Views "relationship" to Borrower and/or Asset. You could also add some Views filter(s) to further  limit this list to fit your needs, e.g. to list all available (not borrowed) assets (as in your comment to my answer). For this kinds of lists I often use the dataTables module to make the searching even more flexible/dynamic (in the browser). Refer to my answer to "How to display the data of a View in table format?" for (way) more details on that.

You could easily take this a step further by also adding the Rules module to the mix. E.g. to schedule an eMail reminder to the borrower X days before the "to be returned date". However, for this to work (make sense), you'll also want to add an extra field (of type date) to the Loan type to register the actual return date of the Asset (which you should also add IMO even if you don't want this extra Rules feature). Assuming you added such return date field, you'd want to check it's value in such eMail reminder (to avoid sending reminders for Assets that were returned already).


REST Services documentation for end client

There is indeed:

Services Documentation API

  The Services Documentation module generates API documentation for your site’s Services resources. Most of the documentation is generated automatically, using the resource information contained provided by Services. However, this module provides you with the ability to easily extend that documentation.


Commerce Attribute price is not updating in cart

Unfortunately, the https://www.drupal.org/project/commerce_pricing_attributes module and it's brethren (product options and product attributes) are a part of what I like to call the "hunziker approach." This removes the idea of separate SKUs per attribute. Which has the unfortunate effect of giving the masses what they expect and distorting/side-stepping a very deliberate separation of logic in Drupal Commerce. It would be like forcing Views to store taxonomy terms. It might make your task easier, but it is not the right approach.

The "hunziker" approach to Drupal Commerce is not supported nor recommended by the creators of Drupal Commerce. Thus, any problems you might have with the modules is "by design" unfortunately.

If you want attributes to update the pricing correctly, try creating separate product entities with unique and single attributes and attaching them to one single product display node.


Migrate module: how to handle adding Redirects and rolling back?

The redirects associated with the migrated (node) content should be automatically removed during the rollback.


How can I programatically add a shipping method to a store?

With custom module code, you can add a new store like this:
function mymodule_entity_insert(Drupal\Core\Entity\EntityInterface $entity) {

  if ($entity instanceof Drupal\commerce_store\Entity\StoreInterface) {

      $sm_id = 1; // I can see Shipping Method ID is 1 from your table screenshot
      $shipping_method = Drupal\commerce_shipping\Entity\ShippingMethod::load($sm_id);
      $store_ids = $shipping_method->getStoreIds(); // get existing IDs
      $new_store_id = $entity->id(); // get new id
      $store_ids[] = $new_store_id; // add new to existing
      $shipping_method->setStoreIds($store_ids); // set
      $shipping_method->save();

  }

}

In the above code, when a store is created, it automatically adds it to the shipping method.

But if your question is to add already existing stores to the shipping method, then run this code only once:
      $sm_id = 1; // I can see Shipping Method ID is 1 from your table screenshot
      $shipping_method = Drupal\commerce_shipping\Entity\ShippingMethod::load($sm_id);
      $store_ids = [1, 2, 3, 4, 5, 6]; // Array of all the store IDs that belong to this shipping method.
      $shipping_method->setStoreIds($store_ids); // set
      $shipping_method->save();

The better API solution
Thanks to 4k4's answer I was able to commeup with a more efficient solution.
function mymodule_entity_insert(Drupal\Core\Entity\EntityInterface $entity) {

  if ($entity instanceof Drupal\commerce_store\Entity\StoreInterface) {

      $sm_id = 1; // I can see Shipping Method ID is 1 from your table screenshot
      $shipping_method = Drupal\commerce_shipping\Entity\ShippingMethod::load($sm_id);
      $new_store_id = $entity->id(); // get new id
      $shipping_method->{'stores'}[] = $new_store_id; // appends new store to existing list.
      $shipping_method->save();

  }

}

Manual Solution

Quick follow up, do I have to load all the stores at once? When I have
1000+ stores and more, that seems like it will be a little resource
intensive. Is it possible to just add the new store?

At this point, you wouldn't want to use the entity API and do Drupal\commerce_shipping\Entity\ShippingMethod::load as this would contain all the 1000+ store IDs, you will have to manually DB query & insert:
function mymodule_entity_insert(Drupal\Core\Entity\EntityInterface $entity) {

  if ($entity instanceof Drupal\commerce_store\Entity\StoreInterface) {

    $sm_id = 1; // Shipping Method ID
    $connection = \Drupal::database();

    $query = $connection->select('commerce_shipping_method__stores', 'csms');
    $query->range(0, 1)
      ->orderBy('delta', 'DESC')
      ->condition('csms.entity_id', $sm_id)
      ->addField('csms', 'delta');
    $last_delta = $query->execute()->fetchField();
    $new_delta = $last_delta + 1;
    $new_store_id = $entity->id(); // new store ID

    $insert = $connection->insert('commerce_shipping_method__stores')
      ->fields([
        'entity_id' => $sm_id,
        'stores_target_id' => $new_store_id,
        'revision_id' => $sm_id,
        'delta' => $new_delta,
        'bundle' => 'commerce_shipping_method',
        'langcode' => 'en',
      ])
      ->execute();

    $storage = \Drupal::entityTypeManager()
      ->getStorage('commerce_shipping_method');
    $storage->resetCache([$sm_id]); // Flush Cache

  }

}


Don't show user fields on admin/people/create

On each of the field settings for user fields, there is an option "Display on user registration form.". Just uncheck it.


Drupal Commerce Authorize.net gateway and POODLE

The commerce_authnet module is using the PHP curl() functions to communicate with Authorize.net, and it does not explicitly requests the SSLv3 protocol in the curl options (see file commerce_authnet.module, lines 1163 to 1172).

curl will therefore rely on the HTTPS handshake to determine the protocols and ciphers, and since the Authorize.net will not advertise SSLv3, another protocol will be selected during the handshake (most certainly TLS v1.2).

So you have nothing to change, the transition will be handled automatically by the HTTPS handshake. I would only advise you to upgrade your openssl library to the latest version.


Redirect to a specific tab in a page after node submit

Most if not all browsers strip the hash (fragment) and this information is lost so you can't rely on hash being in the URL.
RFC 3986 states:

the fragment identifier is not used in the scheme-specific
processing of a URI; instead, the fragment identifier is separated
from the rest of the URI prior to a dereference, and thus the
identifying information within the fragment itself is dereferenced
solely by the user agent, regardless of the URI scheme. Although
this separate handling is often perceived to be a loss of
information, particularly for accurate redirection of references as
resources move over time, it also serves to prevent information
providers from denying reference authors the right to refer to
information within a resource selectively.

Possible workaround:
Create a hidden input field url_fragment and make sure it passes as a URL parameter (&url_fragment=hashvalue). Have some javascript execute on load of this page and if it finds the url_fragment in the URL make it do a scrollTop and opening of the specific tab.
Here is a question and answer that does the scrollTop if the urlParemeter EXISTS.  You need to modify this script to get the actual value and also click the Tab.


You might want to test the following simple formatter I put together for one of my projects - named mvspan (multivalue span). Soon after I wrote it, the specs of my client changed and I did not need it anymore, therefore it may need some more tests, therefore please accept it in its "as-is" shape.

It works for simple text or integer types, not date or datestamps, unfortunately. Feel free to shape it for your own needs.

It has two modes: displaying first/last values or min/max values. Plus, it allows you to set the delimiter to glue up the values.

mvspan.info:

name = Multi-value Span
description = "Formats multi-value fields to show first/last or min/max value spans."
core = 7.x
files[] = mvspan.module

mvspan.module:

<?php
 /**
 * Implements hook_field_formatter_info().
 */
function mvspan_field_formatter_info() {
  return array(
    // the key must be unique, so it's best to prefix with your module's name.
    'mvspan_formatter' => array(
      'label' => t('Multi-value Span'),
      'field types' => array('text', 'number_integer'),
      'multiple values' => FIELD_BEHAVIOR_DEFAULT,
      'settings' => array(
        'delimiter' => '...',
        'mode' => 'minmax',
      )
    ),
  );
}

/**
 * Implements hook_field_formatter_view().
 */
function mvspan_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();
  $settings = $display['settings'];

  $delimiter = check_plain($settings['delimiter']); // The delimiter string in the settings form

  switch($settings['mode']){
    case 'minmax':
      $minv = NULL;
      $maxv = NULL;

      foreach($items as $delta => $item) {
        if(is_null($minv) || $item['value'] < $minv){
          $minv = $item['value'];
        }
        if(is_null($maxv) || $item['value'] > $maxv){
          $maxv = $item['value'];
        }
      }

      if($minv === $maxv) {
        $element[0]['#markup'] = $minv;
      } else {
        $element[0]['#markup'] = implode($delimiter, array($minv, $maxv));
      }

      break;

    case 'firstlast':
      reset($items);
      $firstv = $items[key($items)]['value'];
      end($items);
      $lastv = $items[key($items)]['value'];

      $element[0]['#markup'] = implode($delimiter, array($firstv, $lastv));
      break;
  }
  return $element;
}

/**
 * Implements hook_field_formatter_settings_form().
 */
function mvspan_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state){
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $element = array();

  // settings
  $element['delimiter'] = array(
    '#type' => 'textfield',
    '#title' => t('Delimiter'),
    '#description' => t('Delimiter string to be inserted between min and max values.'),
    '#default_value' => $settings['delimiter'],
  );
  $element['mode'] = array(
    '#type' => 'select',
    '#title' => t('Value handling'),
    '#description' => t('How multiple values will be managed: min/max or first/last'),
    '#default_value' => $settings['mode'],
    '#options' => array(
      'minmax' => t('Minimum/maximum'),
      'firstlast'  => t('First/last'),
    )
  );
  return $element;
}

/**
 * Implements hook_field_formatter_settings_summary().
 */
function mvspan_field_formatter_settings_summary($field, $instance, $view_mode) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $summary = array();

  switch($settings['mode']){
    case 'minmax':
      $summary[] = t('Min/max values will be displayed');
      break;

    case 'firstlast':
      $summary[] = t('First/last values will be displayed');
      break;
  }
  $summary[] = t('using delimiter: "@delim"', array('@delim' => $settings['delimiter']));
  return implode('
', $summary);
}


Db_Query Fatal error: Unsupported operand types

I'm not sure exactly which one is causing the error but there are a couple of things:

You're trying to loop over a variable called $dbresult which you haven't declared; you probably meant

$dbresult = db_query("SELECT first, last FROM {autoform}");

$results = '';
foreach ($dbresult as $dbrow) {

It looks like you're using Drupal 7, and the call you're making to theme_table contains arguments in the style of the Drupal 6 call. Variables are all named in Drupal 7 so you need to invoke the function like this:

$output = theme('table', array('header' => $header, 'rows' => $data));

theme_table() takes an array of rows, and each of those arrays will have the data for a number of columns, one for each that you've defined in your header. At the moment you're concatenating a single string and creating a single row containing one cell, with that single string in it.

I think something like this is more what you're after:

$rows = array();
foreach ($dbresult as $dbrow) {
  $rows[] = array(
    $dbrow->first,
    $dbrow->last
  );
}

$output = theme('table', array('header' => $header, 'rows' => $rows));

Also if you want a nice little shortcut leveraging some of the db API you could use this reduced code:

$header = array('first' => 'First Name', 'last' => 'Last Name');
$rows = db_query("SELECT first, last FROM {autoform}")->fetchAllAssoc();
$output = theme('table', array('header' => $header, 'rows' => $rows));

That last snippet will become less useful the more you need to customise the individual rows/cells of the table.


hook_views_pre_render() would enable you to filter out results after the query has already been run. Keep in mind that the results that are filtered out are still part of the query, with all the performance ramifications of that. Putting that in a custom module would be how I would do that.

If you don't want a view that's just a filtered version of the IsImportant == TRUE view, you could clone the first view and create a similar one whose only difference is that it returns four more results than the IsImportant == TRUE view. You could then add whatever filtering logic you want, and then limit the display to a certain number of items before rendering.

You may also want to take a look at the Peek Summary module, since it gives some further granularity to number of results returned beyond what Views alone offers.


The RDF UI module only provides the 'RDF Mapping' local task for nodes at the moment (so not Group entities). See the if statement in this snippet from Drupal\rdfui\Plugin\Derivative\RdfUiLocalTask::getDerivativeDefinitions():

foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
  if ($entity_type->get('field_ui_base_route') && $entity_type_id === "node") {

    $this->derivatives["overview_$entity_type_id"] = array(
      'route_name' => "entity.$entity_type_id.field_ui_fields",
      'title' => $this->t('Fields'),
      'parent_id' => "field_ui.fields:overview_$entity_type_id",
    );

    $this->derivatives["rdf_$entity_type_id"] = array(
      'route_name' => "entity.$entity_type_id.rdf_ui_fields",
      'weight' => 2,
      'title' => $this->t('RDF Mappings'),
      'parent_id' => "field_ui.fields:overview_$entity_type_id",
    );

  }
}


How to dislodge drupal from Apache and remove drupal

Yes, deleting the files and dropping the database should be enough.

If you made any changes to Apache (eg. creating a virtual host) and/or the operating system (eg. a line in the /etc/hosts file) you may want to revert that as well.

Don't worry about messing it up the first time, that's actually a great way to learn and get comfortable with any CMS (not just Drupal).


Getting WSOD after attempting to upload an images from desktop

If you are trying to upload some bigger images, it is possible that you are out of memory.

Processing large photos requires lots of power and memory. Set the RAM with php_value memory_limit 128M or 256M if your hosting allows.


I think you need to create your own ajax handler for this. The idea would be to check if an existing modal exists and rather than add a new one, simply run a replace in your existing one. If non exists, you'd need to setup a new modal.

The other approach you can take, is rather than just forcing it to opena new one, send an ajax request to close the existing one and then present the new one.

Either way, I do not believe there is an easy or straight solution for this particular problem.


How to print the search results after form_submit, in a custom search module?

I used an if statement in the form to check if submit is pressed and gave the results in the if block.

function hook_form($form, &$form_state) {
if (!empty($form_state['values']['text'])) {//here i am checking if the text field is empty
    $header=array('one'=>t('one'),'two'=>t('two'));//your header
 $query=db_query();//query
$column_name = $query->execute()->fetchAssoc();//fetchAssoc to get results in an associative array.
//here get the fields from $column name into rows
$row = array(
    array(
    'one'=>$column_name[""],
    'two' => $column_name[""],
    );
//your form elements after submit is pressed.
 $form['table']=array(
 '#theme'=>'table',
 '#header'=>$header,
 '#rows'=>$row,
 );

}
else {
//your original form here.
 $form['text'] = array(
'#type' => 'textfield'
 );
$form['buttons']['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit Button'),

);
  }
 return $form;
}

in you form submit add this

$form_state['rebuild']=true;


The red box you see is a means that the e-mail address you typed in did not match with any e-mail addresses registered on the site, or that the password was not recognised.  You should also be able to see a red message-box   further up on the same page with more information about the problem.  For example:

  Sorry, unrecognized username or password. Have you forgotten your password?

The most likely explanation for this error is that you misremembered the password.  This also explains why it starts working again after you login as admin and reset the password for the non-admin user.

However, I've noticed that you've definitively ruled out this explanation in your question. Fair enough, I just wanted you to make sure this is not what is happening.  I've run dozen of Drupal sites for many years (many of them with the Email registration module enabled) - and I've never seen this happen except when the credentials are mistyped.

If that is not what is happening, I have no good alternative explanation.

To progress with debugging, you may extract the {users}.pass field (hashed) from your database, and see if the hashed value changes between when you're able to log in, to when you're not.  If it is changed, then you have some rogue process (or user) that munges the pass field in your {users} database.  (If it is not changed, then this is very, very mysterious.)


Is possible to choose the file_default_scheme to save avatars?

file_default_scheme() returns a variable using variable_get(), unfortunately it just returns it straight without hooking out to any other modules.

For modules that call user_save() directly I don't see any way around this without patching the user module, there's just no way to intercept it.

For the user profile and registration forms you might be able to override the submit handlers, and call your own version of user_save() which contains logic to choose the right file scheme. I don't have time to test it but it would probably look something like this:

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'user_profile_form') {
    // Remove the standard submit handler
    if(($key = array_search('user_profile_form_submit', $form['#submit'])) !== FALSE) {
      unset($form['#submit'][$key]);
    }
    // And add the custom one
    $form['#submit'][] = 'MYMODULE_user_profile_form_submit';
  }
}

function MYMODULE_user_profile_form_submit($form, &$form_state) {
  // Copy the code from user_profile_submit() and change the user_save()
  // line to MYMODULE_user_save()
}

function MYMODULE_user_save($account, $edit = array(), $category = 'account') {
  // Copy the code from user_save() and change the file scheme as required.
}

There might be some caveats to that I haven't though of but hopefully it'll provide a good place to start.


Apply view contextual filter only if user role is not administrator

Not entirely an answer to the question, more a workaround, but you could do it as follows.

Make sure to create a second page. It has to be identical to the original one (including the path), so you can clone it from the edit view name/description dropdown button. Then make sure to remove the contextual filter from this display only, and limit the access to users with the administrator role. Finally make sure this views page is listed before the other one (reorder displays in the edit view name/description dropdown button).

This works because views attempts to load the path, if there is no access for the first display, views attempts to load the second display.
So all users that have no administrator role will see the second display, while the admins will get the first display without contextual filter.


May be a long shot, but I had luck recently with turning on "Aggregation" for the View, so that similar fields are bundled together, and this solved duplication problems that distinct/the other settings you mentioned have failed to fix:


Assigning new region in a display suite layout does not show contents placed inside newly created region

You've made a footer definition but printing $content_footer. Try printing $footer or changing the name of the region to be consistent with the others (content_). Clear cache to see your changes.


Default statistics module. Count views of only published nodes when administration users see it

The Statistics module doesn't use any hook because generally works when Drupal has not completed its bootstrap phase. (That is if caching pages is enabled.)

What you can do is creating a custom module that runs right after the Statistics module, and execute code similar to the following one.

function mymodule_exit() {
  global $user;

  drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES);
  $is_node = (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == NULL);

  if (variable_get('statistics_count_content_views', 0) && $is_node) {
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    $node = node_load(arg(1));
    if (!$node->status) {
      db_merge('node_counter')
        ->key(array('nid' => $node->nid))
        ->fields(array(
          'daycount' => 1,
          'totalcount' => 1,
          'timestamp' => REQUEST_TIME,
        ))
        ->expression('daycount', 'daycount - 1')
        ->expression('totalcount', 'totalcount - 1')
        ->execute();
    }
  }
  if (variable_get('statistics_enable_access_log', 0) && $is_node) {
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    $node = node_load(arg(1));
    if (!$node->status) {
      db_delete('accesslog')
        ->condition('title' => truncate_utf8(strip_tags(drupal_get_title()), 255))
        ->condition('path' => truncate_utf8($_GET['q'], 255))
        ->condition('url' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')
        ->condition('hostname' => ip_address())
        ->condition('uid' => $user->uid)
        ->condition('sid' => session_id())
        ->condition('timestamp' => REQUEST_TIME)
        ->execute();
    }
  }
}


Create a module that implements hook_watchdog(). You could have your own cache of log entries and send a digest of them once a day, or whatever policy you like.


How do I display the raw value of a CCK field securely?

Yes! Lots of security concerns. You'll want to use check_plain(), check_markup() or one of the other functions to output that securely.

Check out Writing Secure Code for more information.


Not sure how to work with beanstalkd module

I managed to figure it out.

Using hook_cron_queue_info, it is possible to define worker callbacks for queue items.

I then wrote the sftp upload script in the worker callback and then run the runqueue.sh script that comes with the drupal beanstalkd module to listen for ready queue items.


I wrote a patch which will allow users to enter an "Author" name when creating/updating a feature.
When provided, the signature will take the Authors value, if not fallback on standard workflow.

Setting the signature was my goal and I succeeded.  For those interested, here is the patch:

diff --git a/sites/all/modules/contrib/features/features.admin.inc b/sites/all/modules/contrib/features/features.admin.inc
index a4203a0..3c5c913 100644
--- a/sites/all/modules/contrib/features/features.admin.inc
+++ b/sites/all/modules/contrib/features/features.admin.inc
@@ -168,6 +168,15 @@ function features_export_form($form, $form_state, $feature = NULL) {
     '#size' => 30,
     '#element_validate' => array('features_export_form_validate_field'),
   );
+  $form['info']['author'] = array(
+    '#title' => t('Author'),
+    '#description' => t('Examples: Patrick, John'),
+    '#type' => 'textfield',
+    '#required' => FALSE,
+    '#default_value' => !empty($feature->info['author']) ? $feature->info['author'] : '',
+    '#size' => 30,
+    '#element_validate' => array('features_export_form_validate_field'),
+  );
   $form['advanced'] = array(
     '#type' => 'fieldset',
     '#title' => t('Advanced Options'),
@@ -832,7 +841,7 @@ function _features_export_generate($export, $form_state, $feature = NULL) {

   $module_name = $form_state['values']['module_name'];
   // Directly copy the following attributes from form_state
-  $attr = array('name', 'description', 'package', 'project path');
+  $attr = array('name', 'description', 'package', 'project path', 'author');
   foreach ($attr as $key) {
     $export[$key] = isset($form_state['values'][$key]) ? $form_state['values'][$key] : NULL;
   }
@@ -1083,7 +1092,10 @@ function features_admin_form($form, $form_state) {
       '#disabled' => $disabled,
     );

-    if (!empty($module->info['project status url'])) {
+    if (!empty($module->info['author'])) {
+      $uri = check_plain($module->info['author']);
+    }
+    else if (!empty($module->info['project status url'])) {
       $uri = l(truncate_utf8($module->info['project status url'], 35, TRUE, TRUE), $module->info['project status url']);
     }
     else if (isset($module->info['project'], $module->info['version'], $module->info['datestamp'])) {


After installing Drush on Mac it only downloads drupal 6x

Drush 7.x doesn't only download Drupal 7 of course. Drush 5 will download Drupal 7 too. Drush 7 is required for Drupal 8 and needs to be selected when installing with composer global require drush/drush:dev-master. Ps the recommended method is the composer method. This what I use on OS X 10.9.

Find old versions of drush with which drush. Check where they live withls -l [path from which drush]. Rinse and repeat until the only one left is in your home folder inside the hidden composer directory.

Check the version of the installed drush with drush --version

Make sure you don't have a .drushrc somewhere with a default core version specified.


Ajax processed not added on link element

In order to have the AJAX event assigned (and the ajax-processed class added) to a link you need two things:

use-ajax class on the anchor tag
AJAX library loaded

I'm guessing you're missing item #2, and that can be done in a few different ways:

If you're generating a renderable array, use #attached:

$my_data['#attached']['library'] = array(
  array('system', 'drupal.ajax')
);
Or you could run this PHP pretty much anywhere prior to the page being rendered:

drupal_add_library('system', 'drupal.ajax');


Is there a way to add non indexed fields to a search api view?

If you were using Drupal 7 and Apache Solr, you could get something like this with the Apache Solr Display module:

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

The advantage here is that you can store rendered entity or entity json encoded object inside the Solr index, which allows you to access non-indexed fields. Otherwise you would need to load the node to access those fields.

I'm not sure if there is any analogous module for Drupal 8, but a similar approach might work.


drupal_set_title not setting $title variable

By the time you've hit node.tpl.php it's too late to set the title as $head_title has already been set in template_process_html() and the $head_title variable has already been output.

You'll need to use template_preprocess_node() or similar to set your title as desired.


How to hide share content option under profile type?

Presumably this is a field, so under Profile2 you can change 'Manage Display' for all fields - set it hidden


Weird Character output Field Collection data with Views Data Export (CSV)

You have UTF-8 characters in your data. The Â character in your case is a UTF-8 non-breaking space, but it's being rendered with the wrong encoding.

You might be looking at the output in something that can't render UTF-8 correctly (some old, dumb text editor), or if you're using something that does understand UTF-8, perhaps the wrong encoding (i.e. iso-8859-1) was chosen when you opened the csv.


Breadcrumb per content type per role, bootstrap theme

You can create a theme template for each content type, then add the breadcrumb logic in there and output the modified breadcrumb there. Here's a great DO resource for theming and how to use template files. In a nutshell, you can clone your default page.tpl.php and rename it page--patient_sheet.tpl.php and inside this template you can run and output the breadcrumb logic.


Fill Date field in a hook form alter with ajax callback

Here the solution finally:

https://www.drupal.org/node/1984838#comment-11736060

I had to fill both $form and $form_state values...

$form_state['input']['your_field_to_change']['und'][0]['value'] = $new_date;
$form['fyour_field_to_change']['und'][0]['#default_value']['value'] = $new_date;


Filtering exposed filters with views_get_view_result() function

It seems views_get_view_result does not allow setting filters: https://www.drupal.org/node/1428696

Instead of using views_get_view_result, you might try with other functions of the Views API:

$view = views_get_view('course_catalog');
$view->set_exposed_input($my_exposed_input);
$view->init_display();
$view->pre_execute();
$view->execute();
$result = $view->result;

You can check the documentation for the set_exposed_input method, and also this related Drupal Answers question, for alternatives: How to change programmatically exposed filters in views


How do I correctly display OG content using Views?

It could be that you use a relationship in the view that is restricted to only authenticated users.
Or it could be that you have set group content visibility to hidden.

But let's start from the beginning..check if it works with a simple view like this:

Create view of nodes, filter it by node type,
Add relationship: OG membership: OG membership from Node
Add contextual filter: OG membership: Group ID, and use the relationship you just created, and set default value: content ID from URL.

If the problem you describe still appears, you can check if it is a permission issue by selecting "Disable SQL Rewriting" in the views settings. But this will disable views permissions and is not wise apart from testing purposes.


Using views how to display taxonomy term description in D6?

Create a new view of the type 'Term'. (D6: Select Term radio button while adding new view, D7: Choose Taxononomy Terms in 'Show' select box)

Then choose the fields

Taxonomy: Term Term
Taxonomy: Term description

that's it, and you can choose  a suitable Style for the display


I was right in my comment earlier. The issue was compatibility between drush 9 and drupal 7. Once I downgraded to drush 8.1.10 it worked fine. Note there is also an oddity with 1and1 specifically where in SSH they default to php4.4 which is too old! So I also had to set up an alias for php and php-cli to refer to a more modern php. Also I had to ensure drush used it by adding 'export DRUSH_PHP=' followed by the full path and filename for the more recent version of php.

If anyone reading this does not know how to downgrade drush with composer you have to remove and re add it with the following commands:

composer global remove drush/drush

composer global require drush/drush:8.1.10

Replace the 8.1.10 with the version that you want.

Also, anyone new to composer might get fooled as I did by the prompt 'Discard changes? (y/n/v/d/s/?). Yes actually means 'discard and apply changes'! I found details of this in the following post:
https://stackoverflow.com/questions/25828102/composer-discard-changes-what-do-the-y-n-v-d-s-do

I hope this helps anyone else new like me stumbling across this issue!

Once again thanks for the comments - the one question from @Christia about drupal version triggered me to look in the right direction!

Rory


How to make values of fields of newly created node available in Rules

You can use fields of node currently being added in two ways

Check down the PHP code text field you will find text saying

  "The following variables are available and may be used by your PHP
  code:". Inside this you will get some site variables as $site and node variables as $node.

As per requirement you need fields of current added node so $node is the reference for current added node and also contains the fields you need.
Find the screen shot to see how it can be used,as in the example I am using drupal_set_message to show the title of current added node or with first code of line it is simple dpm($node), which will show you complete insight of node once this rule is saved and devel module is installed.

Other way is to use tokens replacement options.

Under replacement patterns you will see "Replacement patterns for saved content". This list provides current node fields as toke replacement.
Check the screen shot.

For example usage,if you want to show node title using tokens in rules simply add this code

`drupal_set_message(token_replace('[node:title]', array('node' => $node)));` in the php code.

here in the following screen-shot is a code comparison for the above two ways, you can use any.I usually prefer using $node.


Change the format of 'Authored on' date in views filter

As @prkos said enable better_exposed_filters and in Exposed form style change it as Better Exposed Filters. Open setting and under Authored On select jQuery UI Datepicker. It will enable to give only date format.

BEF Settings:


(OG) Example function to detect User's roles?

To test whether the currently-logged-in User has a specific Role, you can do this:

global $user;
if (in_array('Executive', $user->roles)) {
  drupal_set_message("I have the 'Executive' role.");
}


Drupal 7's States API: Why won't this code work?

Try 'value' => 'sponsor' instead of 'value', 'sponsor'.


Custom views field handler with relationship support, but without table

Ok, I found one way to do this: Instead of registering just one handler, you register one handler per entity type. To save time, we can reuse the stuff already registered by Entity API, with entity_views_data(). This means, of course, the module needs to add Entity API as a dependency.

/**
 * Implements hook_views_data_alter().
 */
function EXAMPLE_views_data_alter(&$data) {

  foreach (entity_get_info() as $entity_type => $info) {
    if (!isset($data['views_entity_' . $entity_type]['rendered_entity'])) {
      // Only register for those entity types where Entity API already did its job.
      continue;
    }
    $data['views_entity_' . $entity_type]['EXAMPLE'] = array(
      'title' => t('Entity display plugin'),
      'help' => t('The @entity-type of the current relationship rendered using an entity display plugin.', array('@entity-type' => $info['label'])),
      'field' => array(
        'handler' => ExampleViewsFieldHandler::class,
        'type' => $entity_type,
        // The EntityFieldHandlerHelper treats the 'entity object' data
        // selector as special case for loading the base entity.
        // @todo Not sure if we really need this.
        'real field' => 'entity object',
      ),
    );
  }
}

And below is the field handler class, just a bit simplified.

Maybe it does a bit more than we really need here. E.g. we don't really need to create a render array for each row, we could work with html directly. But I think it is a good start.

class ExampleViewsFieldHandler extends \views_handler_field {

  function query() {
    // do nothing -- to override the parent query.
  }

  /**
   * Run before any fields are rendered.
   *
   * This gives the handlers some time to set up before any handler has
   * been rendered.
   *
   * @param object[] $rows
   *   An array of all objects returned from the query.
   */
  function pre_render(&$rows) {
    /**
     * @var string $entityType
     * @var object[] $entities
     */
    list($entityType, $entities) = $this->getResultEntities($rows);
    // Build the entities.
    $builds = $this->buildMultiple($entityType, $entities);
    foreach ($rows as $rowIndex => $row) {
      if (isset($builds[$rowIndex])) {
        /** @noinspection PhpUndefinedFieldInspection */
        $row->example_field_builds[$this->position] = $builds[$rowIndex];
      }
      else {
        /** @noinspection PhpUndefinedFieldInspection */
        unset($row->example_field_builds[$this->position]);
      }
    }
  }

  /**
   * @param object[] $rows
   *
   * @return mixed[]
   *
   * @see EntityFieldHandlerHelper::pre_render()
   */
  protected function getResultEntities(array $rows) {
    $relationship = !empty($this->relationship) ? $this->relationship : NULL;
    $field_alias = isset($this->real_field) ? $this->real_field : NULL;
    // Some views query classes want/allow a third parameter specifying the field name.
    /** @noinspection PhpMethodParametersCountMismatchInspection */
    list($entityType, $entities) = $this->view->query->get_result_entities($rows, $relationship, $field_alias);
    return array($entityType, $entities);
  }

  /**
   * @param object $row
   *
   * @return string
   */
  function render($row) {
    /** @noinspection PhpUndefinedFieldInspection */
    return isset($row->example_field_builds[$this->position])
      ? drupal_render($row->example_field_builds[$this->position])
      : NULL;
  }

  /**
   * @param string $entityType
   * @param object[] $entities
   *
   * @return array[]
   *   A render array for each entity.
   */
  protected function buildMultiple($entityType, array $entities) {
    $builds = array();
    foreach ($entities as $rowIndex => $entity) {
      $builds[$rowIndex] = array(
        '#markup' => entity_label($entityType, $entity),
      );
    }
    return $builds;
  }
}


Is it possible to create a references from text?

It should be simple and straight forward as far as i understand. Below steps should solve the problem. You can solve it using Drupal Core itself and taxonomy module that comes with core.

Create a Content Type called "About Apples".
Add a text area field called "Apple Details".
Create a Vocabulary called "Apple Types"
Add a field called "apple type" , select field type as "term reference" and widget types as "Auto Complete term widget (Tagging)"

That's it ! You just created a content type called About apples which gives you a form to add Apple Details & Auto Complete Category widget which stores new terms to Apple Types vocabulary and shows autocomplete results when user tries to add categories.


I ended up needing to do something like this not too long ago in a custom module. Drupal has a function called drupal_http_request() to hit the external URL. You can execute it inside a hook function if necessary in your module.

$url = 'http://my-url.com';
      $response = drupal_http_request($url);


How to render a views title in .tpl file?

Try following way :

$view = views_get_view('view_name');
$view->set_display('display_id');
print $view->get_title();
print $view->preview('display_id');


Does field_revision_field_xxx table store the same values as field_data_field_xxx does?

Yes, field_revision_[FIELD_NAME] contains the same value as field_data_[FIELD_NAME]. The only difference in both these table is, if you've enabled revision for entity having this field ([FIELD_NAME]), the field_data_[FIELD_NAME] will contain the latest revision value of the field and field_revision_[FIELD_NAME] will contain all revision value.

For example, Suppose I've a content type article with revision enabled, and has a field field_tags. I've then created a content of type article, so now field_data_field_tags and field_revision_field_tags contain data for the content I've just created. After this when ever I'll be updating this content, the field_data_field_tags will hold the latest revision data for field_tags field and field_revision_field_tags will hold all revision data for field_tags field i.e. revision id 1, 2, 3 and so on.


Only show result when the author has a relation with the current user

Found out how it should be done if you can refer to an author.

My setup:

add relation ship Content : Author as "author"
add relation ship User: Group (field_group) - Appears in: user:user. with the relation to "author".
add contextual filter User: Group (field_group) - Appears in: user:user. with at "When the filter value is NOT available" -> "Provide default value" -> "PHP Code" the following code:
global $user;
$data = user_load($user->uid, TRUE);
return $data->field_group['und'][0]['nid'];


Views 3: how to list users related to nodes category and exposed filter by that category

Follow below steps to solve the issue.

Add relationship node author.
In View Fields add field Node Author Name
Add filter Node Category Field that is used to Categorize content.
Expose the above filter
Select Group By Node Author Name in View Style Settings so that you can see DISTINCT users belongs to Node Category

That should work i hope !


Drupal Commerce "let me know when the price goes down"

In product content type add a new radio field "Would you like to receive an email if the product price change?" with options Yes and No.

Install Token module and Rules module

You can write a rule to send an email whenever the product node price field is updated to only users who has selected Yes option. you can do this by adding a standard available condition or you can execute a custom php code and use Token to access the radio button value.


$uri = $var->field_upload[und][0][uri];

For object you need to use the notation '->' for tracing the object and $var is the variable which gave you the array .


You can disable the double click  on submit using the below jQuery code.

$('#formid').submit(function(){
    $(this).children('input[type=submit]').prop('disabled', true);
});

Now you can use the below code to alter submit of webform in your custom module

/**
 * Implementation of hook_form_alter().
 */
function mywebform_extra_form_alter(&$form, &$form_state, $form_id) {
  // Add extra submit for a particular Webform node:
  if ($form_id == 'webform_client_form_44') {

    // Add the submit handler after the existing Webform submit handler,
    // but before the second Webform handler. Pop off the first one and add
    // ours second.
   $form['#submit'][] = 'mywebform_extra_validate_44';
  }
}

/**
 * Submit handler for Webform ID #44.
 */
function mywebform_extra_submit_44(&$form, &$form_state) {
  global $user;

  // Now you can perform here api request and redirect
}

Hope it will help you.


Discount for specific user group in Drupal Commerce

Wait, wait, wait. That video tutorial referenced in the currently accepted answer is very outdated and unnecessary. All you need to do is create a new product pricing rule and use the "Multiply the unit price by some amount" line item action. Multiply it by .9 for a 10% discount, .87 for a 13%, and .84 for a 16% discount. Then just select the "Discount" price component (or else use a module to define a new price component type) in the action so it appears as expected in order total price breakdowns.

The only reason abusing the tax system was recommended at the time of that video recording was because you could not specify the price component type in the rules action. That has long since been changed, but alas the video still gets linked to quite a bit.


Alter field collection edit form in hook_menu_alter

Better to use the Field Attach API hooks instead.

e.g:

hook_field_attach_form
hook_field_attach_validate


How can I hide a field with Views if another field has a certain value?

Solution1:
You can add filter in view by selecting and restricting the value of "Foods" field since if foods has the selected option then only it will display the results.

Solution2:
Just add one more field with php custom field(use views customfield module) and exclude display of all other 3 fields. In this php field you can get all the previous field values in $data variable so you can print the result as you wish by validating using php.

Hope this can help you out!


Are there specific cache tags which get reset on user login?

No, there aren't any cache tags invalidated upon login. And even if there were, they wouldn't be tied to your cache. Instead, you should act on hook_user_login(), and expire the cache yourself.

Cache invalidation isn't really something you would piggy back onto something non-relevant. Rather, you set up elements with cache tags/contexts etc, and then if necessary you add your own cache invalidation on relevant events.


How to override node add template for custom content type?

This template will be used when a node edit form specifies 'node_edit_form' as its #theme callback. Otherwise, by default, node add/edit forms will be themed by form.html.twig.

Try this on your theme:

use Drupal\Core\Form\FormStateInterface;

function YOURTHEME_form_node_form_alter(&$form, FormStateInterface $form_state) {
  $form['#theme'] = ['node_edit_form'];
}

After this your theme can read template node-edit-form.html.twig.

https://api.drupal.org/api/drupal/core%21themes%21classy%21templates%21content-edit%21node-edit-form.html.twig/8.2.x


This may happen if you are have applied filters on any date field. I had similar problem, try this, in Views Advanced Settings under OTHER options, select "Query Setting" and check "Distinct" option.


In Drupal 7 you can use Select (or other) module for your requirement

  Select (or other) module : Provides a new Forms API element which is a select/radios/checkboxes element that has an 'other' option. When
  'other' is selected a textfield appears for the user to provide a
  custom value.


Views supports caching the query and the rendering.

If you have page caching enabled then it's obviously much faster and views isn't involved at all.

There is no silver bullet to improve performance, try to install xhprof to find out where your bottlenecks are.

Using a different cache backend like memcached can help a lot, for a start.


Will disabling the Form Builder UI do anything to my webforms?

Form builder is just a user interface. It does nothing to the forms themselves. The display and use of the forms is dependent upon the modules that implement the forms. so, yes, you can disable it with no effect on your existing forms.


How to translate a word in <a title (tpl)?

Try: <?php print t('Menu') ?>

Like so:

<?php print t('Menu') ?>

This will make the string translatable in the admin interface.


How to use the Rules module to implement a custom redirect for an outdated URL?

Why using .htaccess might not be an option

There are situations where setting up a redirect in your .htaccess file may not be an option, such as:

you are not allowed (= do not "have") edit access to your .htaccess file.
your provider does not allow specific directives in .htaccess files (which you'd want to use).
your Drupal site is running on IIS.
you don't have the required knowledge to correctly code the redirect in your .htaccess.
... (what else?).

These are all reasons for using an approach based on the Rules module, as further detailed below.

Use Rules with 'Drupal is initializing'

Using the Rules module to get this to work, you should be able to use the "Drupal is initializing" event. That will ensure that the rule gets triggered BEFORE the actual content is shown.

Use a Regular Expression

The link that you want to "intercept", should be formatted in some type of regular expression, which you then use as your rules "Condition". so that you have a rule that corresponds to "before showing the actual content of something that matches a specific path ...". After you get that part to work, your Rules "action" should specify the actual redirect to be performed.

Remark: in this case you can also use "contains /content?name=" (instead of the regular expression) to get the text match working.

Sample rule

Refer to the "option 1" part of my answer to the question about "How to restrict access to a node via node/12 and allow access via a path like content/sometitle?", which contains this rule in export format:

{ "rules_check_url" : {
    "LABEL" : "Disallow node/* access",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "init" : [] },
    "IF" : [
      { "text_matches" : {
          "text" : [ "site:current-page:url" ],
          "match" : "node\/\\d+$",
          "operation" : "regex"
        }
      }
    ],
    "DO" : [
      { "drupal_message" : {
          "message" : "Sorry, URLs like [site:current-page:url] are not allowed around here ...",
          "type" : "error"
        }
      },
      { "redirect" : { "url" : "no_access" } }
    ]
  }
}

Here are some suggested tunings of the above sample, to make it work for your case also:

machine name and label.
replace the node/* by your path (in the "label", and the regular expression).
replace the path in the action part of the rule by your target path (more details below), and check if you do want some type of error message to be shown (if not remove that part of the action).

Use the value of the [name] variable in the redirect

To make the value of the URL argument available as new variable to Rules, you can use the Rules URL Argument module. Here is a quote about it (from its project page):

  ... provides two rules conditions based on URL arguments:

  check if a URL argument is present.
  compare the value of an URL argument.

  It also provides an action that makes the value of an URL argument available as new variable to Rules.

The newly provided Rules actions and conditions can be found under the "URL Argument" conditions and actions groups in the rule configuration interface.

For an example of how to use it, refer to Comment # 3 in issue # 1686360 which is about "Pass an amount to the url, ie; site/content/node-title?amount=10 or /node-title?=amount:10". Here is the relevant part of it:

  add a "Check if URL argument exist" condition to your rule and set the "ARGUMENT" value to "amount".
  add "Provide URL argument value" action to the rule and set "URL ARGUMENT NAME" value to "amount" and in the "Provided variables" section "ARGUMENT FROM URL - Variable name" to e.g. "amount_from_url".

  You will now be able to use the amount value as a variable "amount-from-url" for other actions in this rule.

PS: If you're not familiar (enough/yet) with Rules, checkout the 32 (!!!) great, and free, video tutorials Learn the Rules framework.


you should pass 'click sortable' => TRUE parameter together with 'handler':

...
  'field' => array(
    'handler' => 'views_handler_my_custom_field',
    'click sortable' => TRUE,
  ),
...

Then you can override click_sort($order) in your views_handler_my_custom_field class, e.g. you can explicitly override the 'orderby' array of query object:

function click_sort($order) {
  ...
  $this->query->orderby[] = array(
    'field' => '...', // here may be a field, or some SQL clause e.g. FIELD(str, str1, ...)
    'direction' => strtoupper($order),
  ...
);

See also click_sort($order) in views_handler_field class.

HTH,
Alexander


Reload a View with AJAX on a click event

I'm afraid you won't do without a bit of coding here. What first comes to mind is a combination of

Form API for the refresh button,
views_embed_view() for retrieving the current version of the view.
AHAH javascript replacement for the view output replacing, and

Modules Views Auto-refresh mentioned by you or Ajax Views Refresh may not do exactly what you're after, but their code could be a source of inspiration when implementing views refreshing.

I also recommend having a look at the code of the Drupal core's Poll module, mainly the functions poll_choice_js (the callback function for the path poll/js) and poll_form ($form['choice_wrapper']['poll_more'])


I just had this problem (well, similar) and I solved it the following way:

/**
 * Implements hook_views_pre_build().
 */
function MY_MODULE_views_pre_build(&$view) {
  // Trigger this only for the needed view
  if ($view->name == 'my_view_name') {
    // Check the exposed input array to see what the user submitted
    $exposed_input_arr = $view->get_exposed_input();
    // Write your exposed array checking logic here ...
    //if (empty($exposed_input_arr['field_sort_by']) || ...) {
      // Remove the sort field from the view
      unset($view->sort['field_sort_by']);
    //}
  }
}


How To Hook To Commerce Add To Cart Button After Add?

You've got a rules event that fires when a product is added to the cart, which is called after the price calculation one, check commerce_cart_product_add function.

It uses rules_invoke_all, which means that you can either run actions on this event or invoke the hook directly, hook_commerce_cart_product_add normally.

// Invoke the product add event with the newly saved or updated line item.
rules_invoke_all('commerce_cart_product_add', $order, $product, $quantity, $line_item);


Why book re-ordering is not being saved?

It's an old bug when you have too many pages, I've been struggling and finally still doing it through MySQL :

it's 'menu_links' table and Weight value in DB , and flush cache well

it's from my old question How to reorder Book module menu through Database?

Hello, who deleted My Answer?! - This IS ANSWER not Bug report, indeed! You can use my answer about MYSQL data tables! Why joke and delete?!


How to create and send via email a PDF file with rules?

You should write a port to Drupal 7. The Views PDF MIMEMail module codebase is pretty lightweight (~300 LOC). Essentially, it's a

.info file declaration
A .module declaring a theme function
Various Rules integration functions (.rules.inc).

You can figure out how to convert the .info & .module by Googling around how to convert a .info to D7 and look up how hook_theme() changed in D7. There's a comprehensive guide on porting D6 modules to D7 if needed.

As for #3, the Rules module has some internal documentation that describes how to integrate Rules in D7. There's likely a few structural changes you'll need to do, but essentially most PHP code should stay the same.


How can I get the number of comments per page?

Those variables are stored per content type, named comment_default_per_page_TYPE. So to get the default comments per page for the article content type you would use:

$default = 50;
$per_page = variable_get('comment_default_per_page_article', $default);


Drupal 7 Calendar - How do you disable the number link to the day page?

That functionality is automatic and means that you have month- and day-type calendar views defined.

If you don't want to use the daily display on your site, just find the calendar view that defines the daily display and disable that display or view.

That'll automatically disable the functionality of displaying a daily calendar on your monthly view.

Here's a step-by-step:
Look in the calendar view's format settings

If the calendar type is 'Day', then that's the one that's automatically being linked to your month's date number, just disable that view or display:

Hope this helps!


In Drupal 8, settings.php contains the following line:

# $settings['maintenance_theme'] = 'bartik';

First, uncomment this setting and change "bartik" to the machine name of your custom theme.

Next, copy the core maintenance template core/modules/system/templates/maintenance-page.html.twig to templates/maintenance-page.html.twig in your custom theme directory.

Lastly, flush the Drupal cache to enable your new maintenance page template. If you need alter the template's variables, you can add the MYTHEME_preprocess_maintenance_page() to your *.theme file.


Enable "Configuration Translation" core module
Go to your view edit and you will see a "Translate view" tab
You'll find your language in the list there. Then click on "Edit"
next to the language
Expand panels and you will find your header text under the "Header"
panel


Change the Drupal Commerce checkout completion page

I used the Rules module to redirect on checkout completion event, and this seems to be working so far.


Determine available Entities entity_metadata_wrapper value() methods

i think the wrapper doesnt provide the type label, at least i havent found it.
One way to find the label :

$info = entity_get_info($fields->type());
echo $info['label'];

To learn more about available fields, try $fields->getPropertyInfo().

The diference of the body field is in the fact it is formatted, so the "first" value() function returns the object which allows you to retreive other metadata about the field. The difference can be spotted in the result of the aforementioned getPropertyInfo. While a "plain text" field is set to a callback function "entity_metadata_field_property_get", which returns the value immiediately, the body will have something like "entity_metadata_field_verbatim_get" which returns the whole array of the field.

according to the docs, you can also use value() on the wrapper itself and that will allow you to see what there is (so print_r($fields->value()); or dpm() the same will help :)


How can I dynamically get the fields on an image media bundle?

You can traverse the field definitions of the media bundle image and look for a field with the type image:

$fields = \Drupal::service('entity_field.manager')->getFieldDefinitions('media', 'image');
foreach ($fields as $key => $field) {
  if ($field->getType() === 'image') {
    // found image field $key
  }
}

To get all media bundles:

$bundles = \Drupal::service('entity_type.bundle.info')->getBundleInfo('media');


I ended up creating a filter class, since I use a subquery I needed to use HAVING rather than BETWEEN.


exculde content type from search result even for admin

You can do what you're attempting if you implement Apache Solr which has all kinds of cool options - but that involves actually setting up Solr on your server which might be overkill if that is all you wish to achieve.


custom user page image field crashes when uploading, removing image

In the menu entry for your custom page, if you have not already done so, you need to add the file path and file to reference the user module files, like so...

$items['my/custom/page'] = array(
    'title' => 'My Title',
    'page callback' => 'my_page_function',
    'access callback' => TRUE,
    'file path' => drupal_get_path('module', 'user'),
    'file' => 'user.pages.inc',
  );

I find it's necessary to include the reference in the function, as you have already done, and also include it in the menu entry.  Don't forget to clear the Drupal cache after updating the menu entry.


How to get views machine name in `block--views-block-html.twig` file?

Views machine name would be: /admin/structure/views/view/frontpage.

You can edit/change the view name on right corner: Edit view name / description.

You can override the template name using below.

[base template name]--[view machine name]--[view display id].html.twig
[base template name]--[view machine name]--[view display type].html.twig

So this would be:

views-view--frontpage--page.html.twig

or:

views-view--frontpage--block.html.twig

There is no theme information is displayed with D8 views as D7 views was having the those information.

Please refer the reference page.


There a few reason this might be happening

1st is your using a bootstrap 3 theme with bootstrap 2 panel layouts.

The 2nd is your not setting panels with the bootstrap grids width.

After you have choosen the bootstrap stack layout.

1.Click on "Save and update"

2.Then click on the little gear you will see a drop down menu

3.then click on option that say's "Change"

4.Then select the bootstrap layout option

5.Then you will be able to select the column width of the layout

6.Then save.

Then do the same for the other right or left column and now your column will be right or left. You can see example how to do this here

If you want to hide some panels from on a mobile or desktop display, then you
need to use bootstrap hide  and show classes which you can find here

1.goto panels gear
2.Select css
3.add the "hidden-lg" class to panels on desktop you want to hide or "hidden-sm hidden-xs" to panels you want to hide on mobile or tablet

I hope that helps


Form API ajax calls reload attached JS using behaviors

Drupal calls every declared behaviors when an AJAX call is performed. This is done to apply the declared behaviors to new loaded content via AJAX.

When a behavior is applied to an element a class is used to mark that element as behavior processed, so next behavior call ignore this element. The recommended way to do this is using the jQuery Once, included in Drupal 7. See the behaviors section of this page.

In your case you should use something like this:

(function($) {

  // Custom functions and variables can go here
  Drupal.behaviors.moduleName = {
    attach:function(context, settings) {
      $('#ngmap', context).once('leaflet', function () {
        map = new L.Map('ngmap', {center: new L.LatLng(37.472, 57.327), zoom: 13});
        googleLayer = new L.Google('HYBRID');
        map.addLayer(googleLayer);
      });
    }
  };
}(jQuery));

Once will add a 'leaflet-processed' class to the #ngmap element, so next time the behavior is called the initialized map is ignored.

Imagine you have several maps in the same page, and imagine you can load more by using AJAX calls. The above code, with some modifications, allows you to initialize every new loaded map after the AJAX call.

So, your fix works but is not the right way to do it (in general inline code is discouraged), I recommend you to use the #attached and Once approach.


I would recommend trying to use  Views Aggregator Plus

See Example here: https://www.drupal.org/node/2361413
It says a similar thing would work(aggregate and group by column).

God Bless.


Views: Multiple AND/OR operators in contextual filters

So I think you should remove your contextual filters and instead add exposed filters. In there you can make your industry filter multi select so the user can pick more than 1. Then you can also choose to make the filters an either AND or OR giving you that flexibility too.

If the exposed filters or the better exposed filters don't look as you wanted you could even hide the views filter form and created your own custom form that replicates it by passing the parameters into the url that views requires

Hope that helps!


How to add Replace (mysql) function in view query condition field

I don't think condition is what you want, rather expression. And then, to use that expression as a condition, you might need to use havingCondition-- but I'm not sure, test it out. Also note that you need % for a wildcard matching in SQL, so you might have to do ->havingCondition('title', '%' . $category . '%', 'LIKE');.

So, your final code might look something like this:

$query = db_select('node', 'n')
  ->addExpression('REPLACE(n.title, \' \', \'\')', 'title')
  ->condition('type', 'article', '=')
  ->havingCondition('title', '%' . $category . '%', 'LIKE');


drupal_get_form() has been replaced by the form builder service, e.g.:

$form = \Drupal::formBuilder()->getForm(\Drupal\user\Form\UserLoginForm::class);

See the Change Record for more details.

Actually, don't - that change record is incorrect. It'll tell you to pass the form ID, when in fact you need to pass the class string.


Imagecache custom action: scale image to width defined by other field

You would need to create a custom module to do this. Something like this... Create two files in a folder, for example, we'll call this User Defined Width.

user_defined_width.info

name = User Defined Width
description = A module that allows a user to define an image width.
core = 7.x

user_defined_width.module

<?php

function user_defined_width_image_effect_info(){
  $effects=array();
  $effects['advance_resize']=array(
    'label'=>t('User Defined Width'),
    'help'=>t('Resize to a size defined by the user.'),
    'effect callback'=>'user_defined_width_effect',
    'dimensions callback' => 'image_resize_dimensions',
    'form callback' => 'image_resize_form',
    'summary theme' => 'image_resize_summary',
  );
  return $effects;
}

function user_defined_width_effect(stdClass $image, $width, $height) {
      // Your logic here.

  $image->resource = YOUR_IMAGE;
  $image->info['width'] = YOUR_WIDTH_FIELD;
  $image->info['height'] = YOUR_HEIGHT_FIELD;
  return TRUE;
}

This should get you started, but the more I think about it, the more I think you are going to run into all sorts of problems with image caching, as image styles are stored in sites/default/files. You will need to override this some how and make sure the file regenerate on every page load. This wont be good for performance, but could probably be achieved with something like Image Style Flush


You should just focus on several main Zen css files:

blocks.css : should add the css of blocks that you create from backend or from your modules.
forms.css: should add the css for forms: for example: login form, register form, contact form (from contact module)
pages.css: should add the css for the pages: static page that you create from Drupal backend or views page..
nodes.css: should add the css for just the common structure of node and specific nodes also
tabs.css: should add for the tab style (You can easy see the tab style at user login page with login/register/forgot password).

For Zen theme. I suggest you should understand SASS structure and change the scss files instead of css files and the name of scss files are the same as the list above (like blocks.scss, pages.scss, nodes.scss, tabs.scss). You should check Getting started with Drupal7, Zen, Sass and Compass for doing your current stylesheet.


This is due to the new core_version_requirement key taking the place of the core key in module.info files. Here's the change record: https://www.drupal.org/node/3070687.

A dirty hack to get around this would be to add the following to path_alias's .info file:

core: 8.x

I would do this only for the purpose of getting your site back in order, and remove the key afterwards. You are likely to run into this error, or similar, for other modules as well. I think that disabling the path_alias module, and any other troublesome modules, prior to upgrade might help.

This change record about path_alias becoming its own core module might be relevant, as well: https://www.drupal.org/node/3092086.

It's also worth mentioning that, if you have drush installed, you can get a one-time login link by running drush uli 1. You'll get a link that looks something like this: http://default/user/reset/1/1584508997/mFfBCIO2zmwKOm3Bh7l5bBwGxwMO6MVqJ6-S-cvZ-pU/login. Take the part of the URL starting with "/user" and append it to your domain name.

Ex: http://my.site.dev/user/reset/1/1584508997/mFfBCIO2zmwKOm3Bh7l5bBwGxwMO6MVqJ6-S-cvZ-pU/login


Output the "Body" field with markup using Views PHP to be used in Views Datasource (JSON)

No need for Views PHP, in the settings for my JSON putout it ticks Plaintext output by default!

UPDATE: this does answer the question but we can no longer render our REACTJS App on the front end because i presume of some kind of encoding issue with some characters inside the Body field?


How to change Option Label with Hook_form_alter

You're just adding to the existing array of options, when actually you want to clear it and just use your option.

Try this...

$form['commerce_payment']['payment_method']['#options'] = array('commerce_payment_commerce_cheque' => t('Send me an Invoice'));


Different style when listing nodes and displaying a single node

Berdir's suggestion (coolest imho):

  you can even provide custom template suggestions based on the view mode. See for example drupal.org/node/223440 and bri-space.com/content/creating-drupal-template-suggestions

Also within node-article.tpl.php you can inspect $view_mode and decide what to do. You could either include the logic of both templates in the one file, or create different templates and include the appropriate one based on the value of $view_mode

You might also find Display suite interesting.


Rankings and Dates in Views (data architecture)

I could propose using Entity Reference or Field Collection for the second item (Rank).

So, Rank should have 2 different fields eg an integer field (Ranking) and a taxonomy term reference (Year).

These modules will allow you for better data manipulation, Views integration, sorting etc.


How To Override Webform's Submission Template in Drupal 8

Create a custom module and in the custom.module file add this code:

/**
 * Implements hook_theme_registry_alter
 */
function custom_theme_registry_alter(&$theme_registry) {
  $theme_registry['webform_submission_html']['path'] = drupal_get_path('module', 'custom') . '/templates';
  $theme_registry['webform_submission_html']['template'] = 'custom-submission-html';
}

You should have in the custom module your template at the location custom/templates/custom-submission-html.html.twig

The contents of that Twig file look like this.

{{ data }}
{{ data.r }}
{{ data.n }}

You can add HTML that suits your specific case.


"Twig_Error_Loader: Template "file.html.twig" is not defined" for new twig template file

Cache is a pretty broad concept, and sometimes mean content caching and sometimes they mean broader things like config settings and the theme registry.  Disabling content caching is still a bit confusing to me so I can't help with that part of the question.

But the theme registry has some pretty simple rules.  If you add new template file (or change it's name or move it to a different folder) or if you add a new theme callback (in hook_theme) or override to a theme callback (hook_preprocess...) then you MUST clear the theme registry before they will be active.  To do that, the simplest method (without additional modules or drush) is to 'Clear all caches' under admin->config->development->performance.

Of note, sometimes the theme registry is referred to as the theme cache.  While I know it's probably possible, I don't think that disabling the theme registry from caching is a standard practice in development.


Add JavaScript 'effects' to be used with AJAX form submissions

It appears you need to install the interface elements library to add custom effects.
As indicated in the forms api.
http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7
ajax['effect']
Description: Specifies the effect used when adding the content from an AJAX request.
Values: String. Possible values: 'none' (default), 'fade', 'slide'. If the interface elements library is installed, any effect with the name effectToggle may also be used.
I hope this helps :)


What's your reason for looking at Ubercart in D7? I would recommend taking a look at Drupal Commerce. It's not the perfect fit for everyone and is very developer orientated at the moment (this will get better eventually). It is where the future for e-commerce is for Drupal so I would defiantly take a look at it.

If DC isn't an option then it's just a matter of looking which modules you require have a stable release and which are close to a stable release.

Another thing to bear in mind when choosing between Drupal 6 and Drupal 7 is that Drupal 6 will have support (e.g. security releases) dropped for it eventually, so going with Drupal 7 may offer more longevity.


Is it possible to update module provided configuration schema in an hook_update_N()?

Well it turns out I spent some time here because I tried to update the schema file, by typing int not integer LOL.
All I needed was integer and clear caches after all :)


horizontal or vertical nested menus: Nice Menus or Superfish

simple vertical nested menus: Menu Block


Use the module "Automatic Nodetitles". This allows you to use tokens on the title field. Once enabled you can set any pattern for the title. Set your pattern on /admin/content/node-type/YOURCONTENTTYPE to "[nid] - [title]" for example. Already existing nodes can be updated automatically.


How to display fetched data in the form of html table?

Try this example to output your data in table format with Pager (ie. table with page. 1,2,3.. )

function custom_table_page_display() {

  $header = array(
    array('data' => t('Name'), 'field' => 'id', 'sort' => 'desc'),
    array('data' => t('Address'), 'colspan' => 3),
  );

  $query = db_select('users', 'u');

  $query->fields('u', array('name','address'));  // select your required fields here

  $table_sort = $query->extend('TableSort') // Add table sort extender.

                      ->orderByHeader($header); // Add order by headers.

  $pager = $table_sort->extend('PagerDefault')

                      ->limit(20);  // here you can limit the number of data per page.

  $result = $pager->execute();

  $rows = array();
  foreach($result as $res) {
    $rows[] = array($res->id,
                    $res-> title,);
  }
  // If rows are not empty theme and display the rows.

  $output = '';

  if (!empty($rows)) {

    $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'sort-table')));

    $output .= theme('pager');

  }

  else {

    $output .= t("No results found.");

  }

  return $output;

}


hook_form_user_register_form_alter() does not customize user registration form

For all Drupal _alter hooks, you need to pass the variables you need to change as references.

In your function, declaration, $form should be &$form. This makes PHP pass a reference of that variable to inside if your function scope, so changes you make to the $form array persist.

So the function declaration should look like this (to alter both variables):
hook_form_user_register_form_alter(&$form, &$form_state)


How do I get the full URL of the current page?

Have you tried using request_uri()?

$_SERVER['HTTP_HOST'] . request_uri();

It should do the trick. I haven't tried it myself, and I may be off a bit, but I suggest you give a try.
From JavaScript, you could use the window.location.href variable.


Entity Reference: User field not displaying unless user is referenced

Does that field display a link to the user profile? I think it does, and your users do not have the 'View user profiles' permission, so they cannot see the link to a page they don't have access to.


Setup for Taxonomy throwing 404 constantly

Unexpected non-reachable pages you know that exist are 99% of the time a problem in the server-config.

mod_rewrite for apache needs to be enabled and you need to make sure AllowOverride All is enabled in your virtual host for your drupaldirectory. more here: http://drupal.org/node/54832

After you have this setup right you can also enable clean-urls and lose the ?q= in your url. Set it up @ admin/config/search/clean-urls.


How to set DataDefinition::create('integer') to allow bigint numbers

I do not believe there is a solution for this.

Typed Data Manager will always add the PrimitiveType validation constraint plugin for any primitive data type (data type implementing PrimitiveInterface). This plugin does not provide any options for the filter_var native PHP function, which is required to set max_range. This option itself must be less than the PHP_INT_MAX constant. Furthermore PHP_INT_MAX is signed and BIGINT is unsigned. 10 digits should be supported by PHP_INT_MAX for even 32-bit systems as long as it is below 2147483647, which is probably the case for your PHP build. You could try using a 64-bit version of PHP.

There are three alternatives given the signed/unsigned caveat above:

Create a Data Type plugin (that does not extend on PrimitiveInterface) to handle bigger integers.
Alter the constraint plugins and replace PrimitiveType with your own constraint plugin that allows for this or does its own logic. Hope that no other module will do this for the same plugin.
File a core issue and patch Drupal core so that Typed Data Manager allows to pass options and PrimitiveType plugin uses those options. This is trickier than it seems because those options would need to be a part of the DataDefinition (in a backwards-compatible API change), and then extracted out as options into the constraint.

My preferred way would be to get rid of PrimitiveType constraint altogether in Drupal 9 and use specific Symfony constraints.


Output referenced entity in correct language

Do not use the raw field value, use the render array of the field instead:

{{ content.field_stories }}

This will automatically use the correct language.

NOT RECOMMENDED:
If you have to go the custom, raw value route you can do something like

{% for story in node.field_stories %}
  {% if story.entity.hasTranslation('iso2_langcode') %}
    {{ story.entity.getTranslation('iso2_langcode').label }}
  {% else %}
    {# fallback default lang #}
    {{ story.entity.label }}
  {% endif %}
{% endfor %}


For Drupal 7 go to admin/config/user-interface/print, and add that page's (page created by view) path to the the list of system (non-content) pages in the Advanced Link Options tab.

This will show the link on that page. For Drupal 6 the path is admin/settings/print.


How do you use BLOCK_VISIBILITY_PHP, in hook_block_info, to hide a block?

I put this in my php code and it works just right:

<?php drupal_set_message("here"); global $user; if ($user->uid == 1) { return 0; } else { return 1; } ?>

The drupal_set_message is called and everything.


I believe that the total comments is the right field.  You'll have to make different views to show all content from today, this week, this month....THEN sort the view by most comments (so that the highest is first), then restrict your view to show 1 item, and VOILA! (should work)


Set role expiry programmatically in uc_roles_expirations table?

Solved Just by Database entry :

$expiredate = date('U', strtotime($expiry));
    db_insert('uc_roles_expirations')
    ->fields(array(
      'uid' => $uid,
      'rid' => 6,
      'expiration' => $expiredate,
    ))
    ->execute();


Identical permission set for panels and panelizer with different results

It appears that this is a documented bug in panelizer where a role having "Administer Organic groups permissions" can see all options for panelizer even when those panelizer permissions are not set for that role.


URL encoding in admin overlays - breaks overlay

Apparently this error is not related to URL encoding, but the lack of overlay module support when mod_rewrite is not properly configured in the Apache web server.

See http://drupal.org/node/1337420#comment-5238454.


Update commerce cart block when product added through ajax

You need to extend your custom ajax call (or how is your setup ?) with an update cart ajax command, there's a module for it named: commerce_ajax_cart

If you want it all out of the box, then use the dc_ajax_add_cart module.


Overriding the search block module output to add a custom wrapper

Put search-block-form.tpl.php into your theme directory, and modify it as you wish.

Another way is using hook_form_FORM_ID_alter().

/**
 * Implements hook_form_FORM_ID_alter().
 */
function HOOK_form_search_block_form_alter(&$form, &$form_state) {
  $form['#prefix'] = '
';
  $form['#suffix'] = '
';
}


How to investigate (and get control over) the execution order of 3 Rules working on the same action?

It's based on the weight. Edit the  Rule settings and you'll find a drop down to set the weight. I believe those with a lighter weight, e.g. -1, are  executed before those with heavier weight, e.g. 5.


Yes, you should get the four-way cursor and be able to drag stuff around. My own experience has been that DW for D7 is quite buggy. We use a particular commit in NodeStream's makefile, you could try to work from that one, as we do our best to keep well working versions in that make file.
I don't think you can use a View mode, but must use fields. I could be wrong though.


Group items in Views by value in Field Collection

Very nice question!
I give you every detail step by step, including the structure of content types.
First install Field Collection Views module. This will add a default View in Views menu. Its name is field_collection_view. Clone this view (recommended) or edit the existing one.
 Content Type X
This is the Manage Fields of this content type

It contains a Title and a Field Collection field that I called xxx. This is the xxx

It only contains an Entity reference to y, I called it field_reference_xxx (you can also include other fields, for our purpose it is unnecessary).
Content Type y
It only has Title field and nothing else.
I inserted the exact content you included in the question.
Node1 (x) to abd and bca
Node2 (x) to bca and cde
field_collection_view View
This is the main work to do. The default View of field collection is in /admin/structure/views/view/field_collection_view path. Open it.
First you need to add two Relationships :

Entity Reference: Referenced Entity
A bridge to the Content entity that is referenced via field_reference_xxx

Make sure to select referenced  not referencing
and the second one:

Field collection item: Entity with the xxx (field_field_collection)
Relate each Content using xxx.

I supposed the Contextual Filter for selecting is Title of content type y, right? so let's do it. add Title as contextual filter and make it to use (Content entity referenced from field_reference_xxx) Content: Title relationships.
So far so good. Now go to Fields section. select Title as a field and make it to use (field_field_collection) relationships. I mean this

AND NOW OUR WORK IS DONE!
In the aggregate This should be your configuration

For testing I give you the following screenshots to make sure it works
Without any value

With bca

With abc

and cde

Good Luck!


Thanks to berramou!

I ended up using this in my theme:

/**
 * Implements hook_preprocess_HOOK().
 */
function MYTHEME_preprocess_node(array &$variables) {
  if ($variables['view_mode'] == 'search_result') {
    $variables['#cache']['max-age'] = 0;
  }
}


How do I disable update checks for locked projects?

drush cron will trigger the default update manager search, whereas locked project are only locked during drush pm-updatestatus. If you want to prevent Update Manager from checking for particular modules, you'll need a custom module that implements hook_update_projects_alter. All you have to do then is unset($projects['context_mobile_detect']);.

E.g.

/**
 * Implements hook_update_projects_alter().
 */
function MYMODULE_update_projects_alter(&$projects) {
  unset($projects['context_mobile_detect']);
}

I do this quite a lot for Features modules, or custom code.


Access $display_submitted in page template

While normally done in node.tpl.php, if the page is a node view page, the $node variable is also available in page.tpl.php

You can then use something like:

if (isset($node)) {
  // Check if display submitted variable is set for this node type
  if (variable_get('node_submitted_'. $node->type, 0)) {
    // Do stuff
  }
}

An alternative approach would be adding the required logic instead to an implementation of

hook_preprocess_page

Bonus update: You can see the $node variable added to page.tpl.php in core template_preprocess_page

if ($node = menu_get_object()) {
  $variables['node'] = $node;
}


It could be done with Rules:

  The Rules module allows site administrators to define conditionally
  executed actions based on occurring events (known as reactive or ECA
  rules). It's a replacement with more features for the trigger module
  in core and the successor of the Drupal 5 workflow-ng module.

set up a field for the user, boolean and use Field Permissions to hide it from users:

  The Field Permissions module allows site administrators to set
  field-level permissions to edit, view and create fields on any entity.

Rules, Event - Drupal is Initialising
Condition - Data field is empty, user field previously set up
Action - redirect to form

Then you can set up an override for the form submit to set the user data field (or use Rules to do it), so that the condition is no longer met.


The solution is described in:

https://ohthehugemanatee.org/blog/2017/06/07/stop-waiting-for-feeds-module-how-to-import-remote-feeds-in-drupal-8/

1) Download and enable migrate_plus and migrate_tools modules. You should be doing this with composer, but I won’t judge. Just get them into your codebase and enable them. Migrate Plus provides plugins for core Migrate, so you can parse remote XML, JSON, CSV, or even arbitrary spreadsheet data. Migrate Tools gives us drush commands for running migrations.

2) Write your Migration configuration in text, and paste it into the configuration import admin page (admin/config/development/configuration/single/import), or import it another way. I’ve included a starter YAML just below, you should be able to copypasta, change a few values, and be done in time for tea.

3) Add a line to your system cron to run drush migrate -y my_rss_importer at whatever interval you like.

Below is a YAML file which you should adjust:

id: my_rss_importer
label: 'Import my RSS feed'
status: true

source:
  plugin: url
  data_fetcher_plugin: http
  urls: 'https://example.com/feed.rss'
  data_parser_plugin: simple_xml

  item_selector: /rss/channel/item
  fields:
    -
      name: guid
      label: GUID
      selector: guid
    -
      name: title
      label: Title
      selector: title
    -
      name: pub_date
      label: 'Publication date'
      selector: pubDate
    -
      name: link
      label: 'Origin link'
      selector: link
    -
      name: summary
      label: Summary
      selector: 'itunes:summary'
    -
      name: image
      label: Image
      selector: 'itunes:image[''href'']'

  ids:
    guid:
      type: string

destination:
  plugin: 'entity:node'

process:
  title: title
  field_remote_url: link
  body: summary
  created:
    plugin: format_date
    from_format: 'D, d M Y H:i:s O'
    to_format: 'U'
    source: pub_date
  status:
    plugin: default_value
    default_value: 1
  type:
    plugin: default_value
    default_value: podcast_episode


Do I need to manually destroy the EntityFieldQuery object?

You shouldn't really have to care about this much. Because PHP will clean up all this stuff at the end of the page's request lifetime. If you really want to cleanup this lingering instance of anything you just unset() it as-needed.

Something is fishy with your code as your EFQ is in a loop, but it's not being used in the loop for anything what-so-ever.


Tag every value of a single multi-value field

you could create a form with multiple file upload fields, and on submit have it create three nodes, adding the file information to a file field in the new node

Form API

you could take a look at Multi Node Add Module:

  This module provides a new interface for creating nodes where the
  users are able to select the fields what they want to use for creating
  the nodes. It is designed to create multiple nodes in one round, it's
  possible to add more node input rows on-the-fly.

I have never used it, but it appears to do the first suggestion automatically for you. Even if it wasn't perfect, you could modify it into a custom module using it as a framework to build upon

using a temp content type that is only used as a form (for simplicity), or creating a custom form via code or module, you could create a Rule acting upon submit to create three of the actual image nodes, using the field values from the temp content type. If Multi Node Add doesn't work, this has an advantage of the easiest (though probably least performance) way of accomplishing it of these options

  The Rules module allows site administrators to define conditionally
  executed actions based on occurring events (known as reactive or ECA
  rules). It's a replacement with more features for the trigger module
  in core and the successor of the Drupal 5 workflow-ng module.


Your variables will not show up in the variables table; variables are loaded from the database first and are then overwritten by settings.php. You might need to add a global $conf to access the variables in your settings.php.


Rules: Display Message every first login per day; reset day 12:00am

There's a few things to mention here.

Using the [account:last-login] token won't work here; Drupal's login process updates the user account login timestamp before User logs in event.
Using the [account:last-access] token will work however because the User logs in event triggers before Drupal updates the access timestamp.
PHP's strtotime() has a special keyword for the significant time you're looking for; strtotime('midnight') produces the timestamp of when the current day started.

Putting that together, you can create your own custom rules condition via hook_rules_condition_info() and using it compare against the [account:last-access] token in the User logs in event to produce the effect you're looking for:

/**
 * implementation of hook_rules_condition_info()
 */
function MYMODULE_rules_condition_info() {
  return array(
    'MYMODULE_condition_before_midnight' => array(
      'label' => t('Before Midnight'),
      'arguments' => array(
        'last_login' => array('type' => 'date', 'label' => t('The date to compare.')),
      ),
      'module' => 'MYMODULE',
      'group' => t('MYMODULE'),
    ),
  );
}

/**
 * Condition MYMODULE_condition_before_midnight
 */
function MYMODULE_condition_before_midnight($last_login) {
  return ($last_login < strtotime('midnight'));
}


I had a similar problem:
I had to check for certain conditions before adding an item to the cart (not after adding). And if the condition is not met the item should not be added.

The only way i could resolve this is by adding a "Execute custom PHP code" action with the code:

drupal_goto('any_path');

This doesn't look very correct but its the only thing that worked for me.


How to convert date/time from timezone to another timezone in migration process

Timezone conversion is not yet supported - the issue where it's being developed is https://www.drupal.org/node/2883892.


Is there any case where a module needs to implement a class using ServiceProviderInterface?

In short, nope. The Twig service registration is written by Fabien Potencier himself and I doubt anyone will have anything as complex as Twig to necessitate this level of complexity in registration. The module handler is just fanciness, we could've written an override for the module handler during install time. Unless you are writing an install profile which uses a service, you won't face this problem.


How to set up custom Entity Storage per bundle?

I'd strongly recommend against doing that. That's what separate entity types are for, bundles are just variations with different settings/configurable fields.

The assumption in many places is that all entities of a type a stored in the same places, for loading, querying and so on.

You could probably make it work by replacing the storage and have every relevant method (save, delete, load, query, ...) branch of into two different methods. Very likely more work and more complicated than just doing this for a separate entity type. and some things are impossible to get right (e.g. doing queries against a field shared by multiple bundles. core expects that to work).


For the ajax callback  and hook_form_alter() to function you should clear the caches from the performance link.
Also you should change the following

return $form['choice_wrapper']['poll_more'];