If you just want the path to the original file you can use file_create_url() like this:

if ($node = menu_get_object()) {
  if ($items = field_get_items('node', $node, 'field_image')) {
    $variables['field_image_path'] = file_create_url($items[0]['uri']);
  }
}

Note that I've done away with some redundant if statements, the extra node_load (the get object call already loads the node) and the building of the node content.

If you want to use an image style insead of the original image you can use image_style_url() like this:

if ($node = menu_get_object()) {
  if ($items = field_get_items('node', $node, 'field_image')) {
    $variables['field_image_path'] = image_style_url('style_name', $items[0]['uri']);
  }
}

If you wanted to get the image style from the content type display settings you can do this using field_info_instance() like this (this example assumes a content type called "article" and a display mode of "default"):

if ($node = menu_get_object()) {
  if ($items = field_get_items('node', $node, 'field_image')) {
    // Set a default style name as fallback.
    $image_field_style = 'original';
    // Use the image style from the field settings if we have it.
    if ($image_field_instance = field_info_instance('node', 'field_image', 'article')) {
      if (isset($image_field_instance['display']['default']['settings']['image_style'])) {
        $image_field_style = $image_field_instance['display']['default']['settings']['image_style'];
      }
    }

    $variables['field_image_path'] = image_style_url($image_field_style, $items[0]['uri']);
  }
}


Fetch third Level Depth Data from taxonomy with performance

You can fetch all child at any level by using this code :

function taxonomy_get_children_all($tid, $vid = 0, $key = 'tid'){
  $c = taxonomy_get_children($tid, $vid, $key);
  $result = array();
  foreach ($c as $t => $d){
    $result[$t] = $d;
    $below = taxonomy_get_children_all($t, $vid, $key);
    if (!empty($below)) {
      $result[$t]->children = array();
      foreach ($below as $nt => $nd){
        $result[$t]->children[$nt] = $nd;
      }
    }
  }
  return $result;
}

OR

You can do it by adding custom database query using function function taxonomy_get_children


How to create a rule to send email to users of a role that belongs to a country?

You need to use the action "fetch entity by property" and then use the country field and supply the country.

That will create a list to loop through so you can send mails.


The Drupal 7 database API piggy-backs straight onto PDO. It doesn't define its own exceptions, or messages; it actually doesn't even attempt to handle any exceptions, it leaves them for the caller to handle directly.

The most descriptive error message you can get is in the exception object.

catch (\PDOException $e) {
  $error = $e->getMessage();


showing taxonomy (tags) in alphabetical order on nodes

The first thing that comes to mind, you can try to reorder taxonomy tags in vocabulary in alphabetical order.
Perhaps there is a better solution...


In your theme's template.php file use drupal_add_js() to the page preprocess method (or an equivalent preprocess).

function hook_preprocess_page(&$vars) {
  drupal_add_js('http://cdn.jquerytools.org/1.2.6/jquery.tools.min.js', 'external');
}


Extra text field for Status order in Commerce

Consider using the Conditional Fields module. Excerpt from its project page:

Conditional Fields allows you to manage sets of dependencies between fields. When a field is “dependent”, it will only be available for editing and displayed if the state of the “dependee” field matches the right condition.
When editing a node (or any other entity type that supports fields, like users and categories), the dependent fields are dynamically modified with the States API.
You can, for example, define a custom “Article teaser" field that is shown only if a "Has teaser" checkbox is checked.


Changing the label of Change Password Form

You have to create a new module and use hook_element_info_alter
to alter title input like this:

function my_module_element_info_alter(array &$types) {
  if (isset($types['password_confirm'])) {
    $types['password_confirm']['#process'][] = '_mymodule_change_title';
  }
}

and process function

function _mymodule_change_title(&$element) {
  $element['pass1']['#title'] = t('New title 1');
  $element['pass2']['#title'] = t('New title 2');
  return $element;
}

and as a result


How do I pass parameters as JSON format to the HTTP client request?

You can add it to the request like so:

use Drupal\Component\Serialization\Json;
...
$response = $client->get($url, [
    'headers' => ['Accept' => 'text/plain'],
    'json' => Json::decode($params),
]);


Getting a taxonomy-term-name as plain-text in computed field

calling field_get_items() on a term reference field returns an array like this

Array(
  0 => Array(
    'tid' => 10,
  ),
)

to get the term name from the term id (tid) you should load the taxonomy term:

$field_myterms = field_get_items($entity_type, $entity, 'field_myterms');
if (!empty($field_myterms)) {
  $term = taxonomy_term_load($field_myterms[0]['tid']);
}

$term is an stdClass object:

stdClass Object
(
    [tid] => 1
    [vid] => 1
    [name] => test
    [description] =>
    [format] => filtered_html
    [weight] => 0
    [vocabulary_machine_name] => tags
    [rdf_mapping] => Array
        (
            [rdftype] => Array
                (
                    [0] => skos:Concept
                )

            [name] => Array
                (
                    [predicates] => Array
                        (
                            [0] => rdfs:label
                            [1] => skos:prefLabel
                        )

                )

            [description] => Array
                (
                    [predicates] => Array
                        (
                            [0] => skos:definition
                        )

                )

            [vid] => Array
                (
                    [predicates] => Array
                        (
                            [0] => skos:inScheme
                        )

                    [type] => rel
                )

            [parent] => Array
                (
                    [predicates] => Array
                        (
                            [0] => skos:broader
                        )

                    [type] => rel
                )

        )

)

to set the computed field value:

$entity_field[0]['value'] = drupal_clean_css_identifier($term->name);


Not sure if this is a typo just in the question... but you have your hooks defined as hook_blocks_* with an extra s at the end of the word block which shouldn't be there.


There is a setting how many items to display in Display Suite. The setting is demoed in this screencast: http://youtu.be/fa56OZcJq-4?t=1m20s


Commerce framework: How on earth do I offer recurring license subscriptions?

Commerce License is in alpha.  That means it is not generally ready for production use.
Further, Commerce Recurring is in beta, but the module page itself notes, as of January 2021:

This module is not production ready! Expect pain.

Using these modules now will require writing custom code and debugging; there is no out-of-the-box easy solution at this time.
However, I needed a license solution today, so I decided to implement one in Commerce without using these modules.  Here's a rough sketch of how I did it.  Note that I am renewing the subscriptions manually, which is prone to human error; the following flow only provides a UI for users to purchase and configure the period of their subscriptions.
However, this example will hopefully give you an idea of the large amount of work involved in getting subscriptions set up.  It's not easy; if you want something simpler but still not easy, and in which the subscriptions actually recur properly, you could look at Recurly or other SaaS.

Add a role, Premium user.  Give this role the additional permissions that users will purchase.
Add a datetime field to the user account, Subscription expire date.  Add another list text field to the user account, Subscription type.
Add custom code to restrict permission for the Subscription expire date field to admins only.
Configure your store + checkout flow in Commerce.
Create a product type "My license."  Add product variations "One year autorenew," "One month," etc.
Add an EventSubscriber to Commerce to automatically set the user account field Subscription expire date when the purchase is complete.  Also, add a redirect to skip the cart because for individual users, having a cart makes no sense for licenses + I don't want users to purchase multiple subscriptions.

Skipping carts requires this patch in composer.json:
    "drupal/commerce": {
        "allow order types to have no carts": "https://www.drupal.org/files/issues/2020-10-05/2810723-130.patch"
    },

Even with all this effort, you will still have to renew the subscriptions manually.  I did this by adding a view for the admin of "expiring subscriptions" and then using the token stored in the user account by Commerce Stripe to make the recurring payment.
Custom EventSubscriber
Notes about this code: It includes an additional field, a list text field on the user account to let the users change between different subscription types.  This allows members to change from a monthly to an annual subscription, or vice versa.
It also assumes that "monthly" subscriptions are always 30 days.
First, services.yml:
services:
  mymodule_subscriber:
    class: Drupal\MYMODULE\EventSubscriber\MyModuleEventSubscriber
    arguments: ['@request_stack', '@logger.factory', '@datetime.time']
    tags:
      - { name: 'event_subscriber' }

And here's the Event Subscriber from mymodule/src/EventSubscriber/MyModuleEventSubscriber.php:
<?php

namespace Drupal\MYMODULE\EventSubscriber;

use Drupal\Component\Datetime\TimeInterface;
use Drupal\Core\Logger\LoggerChannelFactory;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
use Drupal\state_machine\Event\WorkflowTransitionEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Drupal\commerce_cart\Event\CartEntityAddEvent;
use Drupal\commerce_cart\Event\CartEvents;
use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;

/*
 * Event Subscriber MyModuleEventSubscriber.
 */
class MyModuleEventSubscriber implements EventSubscriberInterface {

  /**
   * The request stack.
   *
   * @var \Symfony\Component\HttpFoundation\RequestStack
   */
  protected $requestStack;

  /**
   * Logger factory.
   *
   * @var \Drupal\Core\Logger\LoggerChannelFactory
   */
  protected $loggerFactory;

  /**
   * The time service.
   *
   * @var \Drupal\Component\Datetime\TimeInterface
   */
  protected $time;

  /**
   * MyModuleEventSubscriber constructor.
   *
   * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
   *   The request stack.
   * @param \Drupal\Core\Logger\LoggerChannelFactory $logger_factory
   *   The logger factory.
   * @param \Drupal\Component\Datetime\TimeInterface $time
   *   The time service.
   */
  public function __construct(RequestStack $request_stack, LoggerChannelFactory $logger_factory, TimeInterface $time) {
    $this->requestStack = $request_stack;
    // Specify that logs should be for this module.
    $this->loggerFactory = $logger_factory->get('mymodule');
    $this->time = $time;
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events = [
      'commerce_order.place.post_transition' => 'postPlaceTransition',
      'mymodule_order.fulfill.post_transition' => 'onFulfillTransition',
      CartEvents::CART_ENTITY_ADD => 'tryJumpToCheckout',
      KernelEvents::RESPONSE => ['checkRedirectIssued', -10],
    ];
    return $events;
  }

  /**
   * Set fields and roles for user accounts that purchase subscriptions.
   */
  public function postPlaceTransition(WorkflowTransitionEvent $event) {
    $order = $event->getEntity();

    $order_type = $order->bundle();

    if ($order_type === 'MYORDERTYPE') {
      $price_monthly = 500;
      $price_annual = 5000;
      $subscription_monthly = 'monthly';
      $subscription_annual = 'annual';
      $customer = $order->getCustomer();

      $total_price_array = $order->get('total_price')->getValue();
      $total_price = intval(round($total_price_array[0]['number']));
      $drupal_now_timestamp = $this->time->getCurrentTime();
      $days_in_month = 30;
      $seconds_in_month = 60 * 60 * 24 * $days_in_month;
      $seconds_in_year = 60 * 60 * 24 * 365;
      $subscription_end_timestamp = '';
      // If the user has already purchased, extend the subscription.
      if ($customer->hasRole('subscriber')) {
        $current_subscription_datetime = $customer->get('field_datetime_sub_end')->value;
        $current_subscription_datetime_object = \DateTime::createFromFormat(DateTimeItemInterface::DATETIME_STORAGE_FORMAT, $current_subscription_datetime);
        $current_subscription_timestamp = $current_subscription_datetime_object->getTimestamp();
        if ($total_price === $price_monthly) {
          $subscription_end_timestamp = $current_subscription_timestamp + $seconds_in_month;
          $customer->set('field_list_text_sub_period', $subscription_monthly);
        }
        elseif ($total_price === $price_annual) {
          $subscription_end_timestamp = $current_subscription_timestamp + $seconds_in_year;
          $customer->set('field_list_text_sub_period', $subscription_annual);
        }
        else {
          $this->loggerFactory->error('Total price was outside the assigned range for subscription. (has subscriber role)');
        }
      }
      // Set the date for a new subscription.
      else {
        // The user is henceforth a subscriber.
        $customer->addRole('subscriber');

        if ($total_price === $price_monthly) {
          $subscription_end_timestamp = $drupal_now_timestamp + $seconds_in_month;
          $customer->set('field_list_text_sub_period', $subscription_monthly);
        }
        elseif ($total_price === $price_annual) {
          $subscription_end_timestamp = $drupal_now_timestamp + $seconds_in_year;
          $customer->set('field_list_text_sub_period', $subscription_annual);
        }
        else {
          $this->loggerFactory->notice('Total price was outside the assigned range for subscription. (no subscriber role)');
        }
      }
      $subscription_end_date_object = new \DateTime();
      $subscription_end_date_object->setTimezone(timezone_open('UTC'));
      $subscription_end_date_object->setTimestamp("$subscription_end_timestamp");
      $subscription_end_date_value = $subscription_end_date_object->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT);
      $customer->set('field_datetime_sub_end', $subscription_end_date_value);

      $customer->save();
    }
  }

  /**
   * Tries to jump to checkout, skipping cart after adding certain items.
   *
   * @param \Drupal\commerce_cart\Event\CartEntityAddEvent $event
   *   The add to cart event.
   */
  public function tryJumpToCheckout(CartEntityAddEvent $event) {
    // $purchased_entity = $event->getEntity();
    // if ($purchased_entity->bundle() === 'training_event') {
    $checkout_url = Url::fromRoute('commerce_checkout.form', [
      'commerce_order' => $event->getCart()->id(),
    ])->toString();
    $this->requestStack->getCurrentRequest()->attributes->set('mymodule_jump_to_checkout_url', $checkout_url);
    // Clear status message "Product added to your cart".
    // @todo fix deprecated code.
    // drupal_get_messages('status');.
  }

  /**
   * Checks if a redirect url has been set.
   *
   * Redirects to the provided url if there is one.
   *
   * @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event
   *   The response event.
   */
  public function checkRedirectIssued(FilterResponseEvent $event) {
    $request = $event->getRequest();
    $redirect_url = $request->attributes->get('mymodule_jump_to_checkout_url');
    if (isset($redirect_url)) {
      $event->setResponse(new RedirectResponse($redirect_url));
    }
  }

}


How to alter existing page of a node that is Organic Group and add Two links above

Create a Custom DrupalGap Block
Place it above the title block within the region configuration of the settings.js file
Use a List Widget and some CSS to render your buttons above the title


Give a role permission to add and edit their terms in a taxonomy

If drupal doesn't provide any "edit own terms" permission, then better do it programatically if you wish.

While accessing term page, load/check for the owner of term and allow them to access edit page.


Specify the view mode when the node is displayed on modal window (ajax)

The way you are doing it will always show the full view mode, as you are linking to the canonical entity page - which is the page to see the full view mode. If you want to show a different view mode, then I would suggest creating a custom route (or path if you're using D7), and in the callback, generate the output programmatically with the view mode you want. I'd probably use the following for the path:

node/[NID]/teaser

And in there I would output the teaser view mode.


how to add exposed drop-down filter with options in a view of custom table

You can use hook_form_alter() for this.
simply change the field type to select and add your options.
here is my working code
// implements hook_form_alter
function project_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id === 'views_exposed_form') {
    $view = $form_state['view'];
    // add your view name in 'view_name'.
    if ($view->name === 'view_name') {
      // Checking status field is exists or not.
      if (isset($form['status'])) {
        $form['status']['#type'] = 'select';
        $form['status']['#empty_value'] = '';
        $form['status']['#empty_option'] = 'All';
        $form['status']['#options'] = array('0' => 'No', '1' => 'Yes');
        $form['status']['#size'] = 1;
        $form['status']['#attributes'] = array('id' => 'status-list');
      }
    }
  }
}

hope this will work :).


I guess I figured out the problem.

This Issue was in the 'Coupon module settings'.

Solution:
1. Go to: admin/store/settings/coupon
2. Enable 'Allow multiple coupons to apply to a single order.' check-box.
3. Save.

This solved my problem.

Thanks,
Anand


As suggested by Clive, there is a Static field which provides a static text that can be configured on a per instance basis via Field API.

Just enable the module and use Field UI to add and configure the field.

There is also another module, called: Pseudo field which allows you to render an extra field as a real field (with field label).


How to display the output of my module without clearing cache and refresh page?

there's this method here :

drupal_page_is_cacheable

actually i never used it, but cacheexclude module does,
maybe you have to hook_init too and check for your path there !


How do i override a View attachment glossary fields link or url

So i dont have a definitive yes or no, but if i was to wager a bet i would say... No. There is no way of overriding the glossary mode's url link and make it link to content on the current page. I saw someone else ask this question better than I did back in 2012 and no one answered him, which pushed me to do this in the old way, by building a custom html table and doing the leg work there. So the answer is no need to, just do it in the .tpl.php file.


Authenticating users and uploading content with Services module

http://drupal.org/node/736522 should help you.


How to programmally add nodes with next nid?

Try this way:

  $node = new stdClass();
  $node->title = $new_array['titre_csv'];
  $node->type = "livre";
  node_object_prepare($node); // Sets some defaults. Invokes hook_prepare() and hook_node_prepare().
  $node->language = LANGUAGE_NONE; // Or 'fr' in your case
  $node->uid = $user->uid;
  $node->status = 1; //(1 or 0): published or not
  $node->promote = 0; //(1 or 0): promoted to front page
  $node->comment = 1; // 0 = comments disabled, 1 = read only, 2 = read/write
  $node = node_submit($node); // Prepare node for saving
  node_save($node);
  //save the other table

If you want to save it in your custom table you can do a db_insert or EntityFieldQuery.
In that case $node->nid value will be taken after you do the node_save (so do it after you save it with node_save).
You could also use a hook_schema for your table.


Show table header in views (Bootstrap table)

You can check if your label of the row is enabled or checkbox is checked which shows Show Label. Go to fields in view, and click on any field, you can see that option.


which page/code renders admin/config in drupal 7

The page that normally come up when the path is admin/config is inserted into the site by the core system module's implementation of hook_menu().

The callback function that actually produces the page is system_admin_config_page().

However, unless you (or somebody else) has hacked core (and we don't that, right?) these functions are not the cause of the problem.

Here's a link to the SOP for debugging Blank pages or "white screen of death" (WSOD).


The literal strings that are passed to t() are not directly translated from the function; the function just searches the provided string in the databases used from the Locale module ("locales_source" and "locales_target"; see locale()). Before searching in that databases, t() checks the Drupal variable locale_custom_strings_<lang_code>, where <lang_code> is the language code for the language to which the strings are translated.

In the first case, the strings are imported from the translation files. In the second case, the Drupal variable can be set in the settings.php file.

As you want to have the translation for strings used by a custom module, the first method (creating a .po file, and then importing it) is probably too laborious, especially because it's a custom module for which localize.drupal.org cannot provide the translation files (the ones with extension .po). The only alternative is to use code similar to the following one in the settings.php file:

$conf['locale_custom_strings_es'][''] = array(
  'forum'      => 'foro',
  '@count min' => '@count minudos',
);

The strings I used are just an example (I hope I translated the strings in Spanish correctly
); the strings I used already have their translation in Spanish as part of the core translation.


Best and simple way is to assigning Roles.

Users, roles and permissions


How do you change the location of `form_set_error` output?

Extending the (correct) answer from Clive, I worked through the IFE code. I didn't really need an entire module dedicated to this, so I adopted a few snippets here and there to get the result I needed. I've marked his answer as correct because it is ultimately the right answer.

The code is below, all credit goes to Clive and the IFE team - I just wanted to present the simplified version for anyone looking for a similar answer.

// Standard gear - do some custom validation and set the errors
// as you go..
//
// Once all the validation has been done, call MODULE_errors_reset
// which will return an array of all errors against their ID.
// Expose this array however you like to your template, or loop
// over your form adding a #suffix to each element with an error
//
function MODULE_form_name_validate($form, &$form_state) {
    drupal_set_message("validating...");

    form_set_error("description", "There is an error here!!!!");
    form_set_error("tags", "Yep, and here too!!!");

    $reset_errors = MODULE_errors_reset( $form );

    drupal_set_message( "<pre>" . print_r( $reset_errors, true ) . "</pre>" );
}

// This part is adopted from IFE. It's changed in two ways, it returns
// an array (which also merges with its recursive self).
// And it also skips all the 'display' stuff present in the original
// Essentially it extracts out the error messages from the session and unsets
// them. I am assuming that Drupal 7 marks the success of a validation based not
// whether the SESSION variable contains anything, the SESSION seems to be only
// for the message at the top of the screen.
//
function MODULE_errors_reset( $element ) {
    if( ! isset( $_SESSION[ 'messages' ] ) ) {
        return;
    }

    $reset_errors = array();

    // Recurse through all children.
    foreach( element_children( $element ) as $key ) {
        if( isset( $element[ $key ] ) && $element[ $key ] ) {
            $reset_errors += MODULE_errors_reset( $element[ $key ] );
        }
    }

    // Check for errors and settings
    $errors = form_get_errors();
    $element_id = implode( '][', $element[ '#parents' ] );

    if ( !empty( $errors[ $element_id ] )) {
        $error_message = $errors[ $element_id ];

        // Get error id
        $error_id = array_search( $error_message, $_SESSION[ 'messages' ][ 'error' ] );

        if( $error_id !== FALSE ) {
            unset( $_SESSION[ 'messages' ][ 'error' ][ $error_id ] );
            $_SESSION[ 'messages' ][ 'error' ] = array_values( $_SESSION[ 'messages' ][ 'error' ]  );

            if( count( $_SESSION[ 'messages' ][ 'error' ] ) <= 0 ) {
                unset( $_SESSION[ 'messages' ][ 'error' ] );
            }

            $reset_errors[ $element[ '#id' ] ] = $error_message;
        }
    }

    return $reset_errors;
}

// If there are no form errors, we still hit here, even after the 'reset', this is
// a good thing.
function MODULE_form_name_submit( $form, &$form_submit ) {
    drupal_set_message("submited!");
}


If you are using taxonomy terms for your catalog you could try using taxonomy term permissions https://drupal.org/project/term_permissions. If you are using a view for each catalog you can just restrict access to each view as you like.


Commerce- Show the attribute label instead of product title?

Here's how this was accomplished in a custom module. This will use the taxonomy terms vs the product titles.

function custom_form_views_form_commerce_cart_form_default_alter(&$form, &$form_state) {

$vocabulary = taxonomy_vocabulary_machine_name_load('product_type');
  $terms = taxonomy_get_tree($vocabulary->vid);
  $terms_name = array();
  foreach ($terms as $term) {
    $terms_name[$term->tid] = $term->name;
  }

foreach ($form['edit_attributes'] as $key => $line_item) {
    if (isset($line_item['product_id']['#options']) && $line_item['product_id']['#options']) {
      $options = array_keys($line_item['product_id']['#options']);
      $products = commerce_product_load_multiple($options);
      foreach ($line_item['product_id']['#options'] as $id => $name) {
        $form['edit_attributes'][$key]['product_id']['#options'][$id] =
          $terms_name[$products[$id]->field_product_type['und'][0]['tid']];
      }
      $form['edit_attributes'][$key]['product_id']['#title'] = 'Format';
    }
  }
}

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

if (strpos($form_id, 'commerce_cart_add_to_cart_form') === 0) {
    $vocabulary = taxonomy_vocabulary_machine_name_load('product_type');
    $terms = taxonomy_get_tree($vocabulary->vid);
    $terms_name = array();
    foreach ($terms as $term) {
      $terms_name[$term->tid] = $term->name;
    }

if (isset($form['product_id']['#options'])) {
  $options = array_keys($form['product_id']['#options']);
  $products = commerce_product_load_multiple($options);
  foreach ($options as $key) {
    $form['product_id']['#options'][$key] = $terms_name[$products[$key]->field_product_type['und'][0]['tid']];
  }
  $form['product_id']['#title'] = 'Format'; // added by Lynn. Works on product page, but no in cart
}

}
}


How to make a new field type visible to the Rules module?

Just add the property_type key to the array you already have, like so:

'property_type' => 'text',

With that added line, the Entity API knows how to handle that field.

For a more complex field, such as fields with more than one database column, it is not enough to simply declare the property type. You need to specify further callbacks that may alter the generated property info. To do so, you need to use the key property_callbacks to add a custom callback function that will provide the extra metadata required. For example:

'property_type' => 'field_example_rgb',
'property_callbacks' => array('field_example_rgb_property_info_callback'),

Source:
Describe field properties to make custom fields work with Entity Metadata Wrappers, which includes some more info about this topic also.


I suppose the existing answer is fine if every customer gets a unique version of the product to purchase. However, it should be obvious that if more than one person uses this it would fail.

You should instead look at what we recommend in this video tutorial:

http://www.drupalcommerce.org/videos/tutorials/donations-custom-line-item-types

The main idea is that you can enrich the line item with custom pricing information and then use the product sell price calculation system to swap in the appropriate custom price.


Display paragraphs items in comma-seperated series

append ', ' or ', and ' or whatever as appropriate

You can use CSS to accomplish this
HTML

    Editor:&nbsp;

            Person 1

            Person 2

            Person 3

            Person 4

      Author:&nbsp;

                  Person 4

    Translator:&nbsp;

            Person 5

            Person 6

CSS
.paragraphs-items { /* start each field on a new line*/
    clear: left;
}

.paragraphs-items div { /* eliminate the blocky results of div hell (eliminate some extra spacing in the process)*/
    float: left;
}

.paragraphs-items .entity-paragraphs-item .content:after { /* default to putting commas after every value … */
    content: ", ";
}

.paragraphs-items .entity-paragraphs-item:last-child .content:after { /* … except the last one */
    content: "";
}

.paragraphs-items .entity-paragraphs-item:nth-last-child(2) .content:after { /* The last two items in the series should be separated by a ", and " … */
    content: ", and ";
}

.paragraphs-items .entity-paragraphs-item:nth-last-child(2):nth-child(2) .content:after { /* … unless there are only two items, in which case it should be " and " */
    content: " and ";
}

EXAMPLE DEMO
Note in content: ", " since it won't pick up the empty space (by pressing the space bar) I used the ALT+0160 trick to make the empty space.


Drupal8 Oaut2 add a grant type “password” to client

To add Oauth 2 authentification
Install the module using Composer: composer config repositories.drupal composer https://packages.drupal.org/8 && composer require drupal/simple_oauth:^2. You can use any other installation method, as long as you install the OAuth2 Server composer package.
Generate a pair of keys to encrypt the tokens. And store them outside of your document root for security reasons.
openssl genrsa -out private.key 2048
openssl rsa -in private.key -pubout > public.key

Save the path to your keys in: /admin/config/people/simple_oauth.
Go to REST UI and enable the oauth2 authentication in your resource.
Create a Client Application by going to: /admin/config/services/consumer/add.
Create a token with your credentials by making a POST request to /oauth/token. See the documentation about what fields your request should contain
(Not shown) Permissions are set to only allow to view nodes via REST with the authenticated user.
Request a node via REST without authentication and watch it fail.
Request a node via REST with the header Authorization: Bearer {YOUR_TOKEN} and watch it succeed.
From this

NOTE: I user drupal/simple_oauth version 2.x because i got an exception n version 3.x


What are the list of Drupal 7 image cropping modules out there?

You can use the Image Javascript Crop Module.

  This module makes an Imagecache 2 (D6) or Styles (D7) 'javascript crop' toolbox action available for use with several modules.


Apache solr search words, but the search pages yield no results

The issue was that I had added the line as suggested here:
http://www.druplitec.de/partial-substring-search-using-solr-server-and-searchapi-module

I took out the line and now it works.  I guess I have to find another way to get "fuzzy search" for the solr server to work...

I had added the line to the wrong place.  I re-read through the apache solr docs and found the correct places for it to go.


Leaving first-level tab selected when clicking on a subtab

I came back to study this problem further. If I am not mistaken, the active trail is not set from the local task to its parent menu link, even if the first local task is correctly set to the corresponding menu voice. I looked at a few modules and custom solution, and in the end I simply changed a bit my URLs and installed the module menu_trail_by_path, and I got the desired behaviour.


Is it possible to change the Taxonomy Parent Term's select list to be a Hierarchical select list?

Chosen's autocomplete is just a bonus. You can have your normal hierarchy using chosen and it is much more accessible than other options you have. I would at least give it a go.
Now considering SHS and CSHS.. they are quite similar and I would not recommend using them side by side.
The main reason for that is that they tackle the same issue with a different approach and -best case scenario- one's functionallity would overwrite the other's.
Now as far as I know they do indeed have compatibility issues as stated in CSHS's module page (at the time this was posted)

It is possible to use the CSHS widget as an exposed filter for taxonomy term reference fields. Please note that this feature might break if SHS module is enabled on your site.

While I think I find CSHS's approach more usable, I would stick with SHS and chosen in your case since you mentioned that your vocabularies are large and CSHS, being client side and all, is more susceptible to performance issues, since it

[...], but in contrast to those modules the whole taxonomy tree is already present at page-load and the whole processing is done "client-side".

Now, to give the devil it's due, both  modules have performance issues with very large trees and it is only natural and understandable, but SHS seems like a more stable choice.
Lastly, to achieve what you described, I would prefer a more "Drupal 8" way and would create a new Field Formatter plugin for the entity reference field you are using and attach this to the form in the form display tab of you entity.
To summarize, I  would but not use SHS in conjunction with CSHS, and although you have to try it our yourself, the combination of SHS and Chosen seems to me like the obvious choise for your case. Try overriding the entity reference field's field formatter to add
the taxonomy parent name to your options if you prefer a more custom approach.


Create a view to show users who flagged other users

Well it was quite easy actually. I just added a field in User:Name and added the relationship as Flag User as the required relationship


Features_extra: after enabling fe_block, no Machine Name field appears on block edit form

The fe_block module only allows exporting blocks represented in the boxes table — those created via the admin/build/block/add user interface.

Exportable blocks will have block as the second-to-last component of the admin URL:

Blocks created using, say, Views, or a module's hook_block() implementation, however, are not exportable using fe_block — it doesn't make sense to export blocks such as those, since Views provides its own export mechanism, and other module-owned blocks are already in code to begin with.


Restrict language based content editing for nodes and blocks

For your solution you can implement hook_node_access, as you see this function takes 3 arguments $node which is the content the user wants to make an operation on it, there you can check content's language, $op is the operation which user wants to make on the content which in your case you can check if it is edition, and finally $account takes the information about the user so you can decide if user is allowed to do the operation or not.

One big consideration is that this hook is not fired for the super user (user with uid = 1) as he bypasses almost all permissions, so in this case you can use hook_init and make a redirect based on node arguments.


Slideshow for the homepage. Views Slideshow or another Module?

IMHO, adding a module for this is overkill. I prefer to create a view, add the jQuery Cycle plugin to my theme and apply the plugin to the view using just a few lines of javascript.


Enable View Library tab for Media module

The image you've attached from the drupal.org media module page appears to be an outdated screenshot of the module. I believe you can use the "Library" tab. The "View Library" tab shouldn't be there in the latest version of the module.

There is more information on the tab title changes in this issue: https://www.drupal.org/node/1886994


Is it safe to send the unencoded JSON output?

There is no need to encode or escape anything yourself. json_encode() will take care of properly escaping any special purpose characters.


How to make a clone of a website without contents

I guess what your looking for is the features module http://drupal.org/project/features. When creating clones of websites, obviously all the code/themes/modules is easy to copy but the only way to get all your node types, fields, views etc... is in the database.

Features exports all this information as a module as you can just copy this to a new site along with all your other modules, enable it, and voila all your views content types etc..
In the features you can list modules as dependencies so when enabling your feature all the contrib/core modules you need are enabled aswell (they will ofcourse need to exist on your new area).

It intergrates fully with most the big contrib modules and from what I understand is exactly what your after. It can be daunting at first but dont worry its really very easy to use. The following video is for drupal 6 but the features interface is identical (as far as I remember) http://mustardseedmedia.com/podcast/episode43

There are other more complex ways to do what your after aswell using drush and creating build scripts, you can ever combine drush, build scripts and features. However I believe just normal features will do you fine.


Filter between first and last day of the current month in any year

Long story short: Use Views Partial Date. The image below demos some of its features (click the image if you don't see the animation).

Why it can't be done with Views

Views by itself can only handle Unix timestamps. Even when a relative date is used, Views' date filter uses strotime() internally to convert the relative date to a timestamp before adding the filter condition to the query.

Why it can't be done with Date Views

Date Views is a complex beast that provides a multitude of features surrounding date calculations, including support for multiple DB backends.
Theoretically Date Views could implement incomplete dates, but since it also supports relative dates and various input widgets (like Date Popup), the additional validation and logic would be extremely hard to maintain.

What we can do about it

At this point we've established that either an additional module or custom code of some form is required.
With that in mind I created Views Partial Date and will be expanding this answer in the following days to describe the approach I took.


A simple way is calling drupal_form_submit  in your custom module

function mymodule_form_final_submit($form, &$form_state) {

  drupal_form_submit('submission_node_form', $form_state);

}


How to change front page template based on url alias?

In Drupal 7, template suggestions are added/modified in the preprocess function, in this case HOOK_preprocess_page().

Add this to the template.php file in your theme root directory; you may need to create this file.

The problem is that the page--node--id suggestion is weaker than page--front and does not get used. We need to move the page--node--id suggestion to the end of the theme_hook_suggestions array, so it overrides page--front.

Add this snippet. I have added comments to explain what each line of code does. Replace ThemeName with your theme name.

/**
 * Override or insert variables into the page template.
 */
function ThemeName_preprocess_page(&$variables) {

  // Check if this is the front page and a node is the front page.
  if ($variables['is_front'] == TRUE && isset($variables['node'])) {

    // Foreach over the theme_hook_suggestions array.
    foreach ($variables['theme_hook_suggestions'] as $key => $value) {

      // Does the suggestion match the current node?
      if ($value == 'page__node__' . $variables['node']->nid) {

        // Match, unset the template suggestion.
        unset($variables['theme_hook_suggestions'][$key]);

        // Push the template suggestion onto the end of the array, this will give
        // it precedence over page--front.
        $variables['theme_hook_suggestions'][] = 'page__node__' . $variables['node']->nid;
      }
    }
  }
}

I think this is the easiest/quickest way to move an array item to the end, where it will override page--front.


Adding a background image for Omega subtheme

You shouldn't need to do any of the preprocess stuff.  We recently had some problems getting things to apply via the global.css file - but we figured them out.

Here is the trick of it.  Even though you apply X in the global.css file, if Y is applied in one of the stock css files, and you don't turn off Y (via css in your global.css) - and Y in some way impacts X - X won't be active.

I recommend either Firefox and Firebug - or Chrome and "right click -> inspect" - and really scrutinize the DOM.

Also - regarding your image file - you might try specifying a full path.  We have had issues with relative paths.

I hope this helps.


Ok, thanks to the hint from @Hudri, here's what I did.

In mycustomtheme.theme:

function MYCUSTOMTHEME_preprocess_block(&$vars) {
  if ($vars['configuration']['id'] === 'MYMODULE_site_branding_nolinks_block') {
    $site_config = \Drupal::config('system.site');
    $vars['site_slogan'] = $site_config->get('slogan');
    $vars['site_name'] = $site_config->get('name');
    $node = \Drupal::routeMatch()->getParameter('node');
    if ($node instanceof \Drupal\node\NodeInterface) {
      $type = $node->getType();
      // For landing pages, set the site slogan to the value of the slogan field.
      if ($type === 'landingpage') {
        $node = \Drupal::entityTypeManager()->getStorage('node')->load($node->id());
        $slogan_field = $node->get('field_slogan')->getValue();
        $slogan_field = $slogan_field[0]['value'];
        $vars['site_slogan'] = $slogan_field;
      }
    }
  }
}

But, we're not done yet, because the block (provided by my custom module) is cached the same for every page; it needs to be cached per URL, since it might be different for each landing page.

To fix that, in mymodule/src/Plugins/Blocks/myBlock.php, add this code:

  // Caching must be added here:
  // https://drupal.stackexchange.com/questions/223376/what-is-the-correct-way-to-set-cache-contexts-on-custom-blocks
  public function getCacheContexts() {
    return Cache::mergeContexts(parent::getCacheContexts(), ['url.path', 'url.query_args']);
  }


Problems getting Carousel jQuery plugin working

I don't see that you have add html elements with bootstrap attributes like data-target and data-slide-to.
When I inspect your page and replace this:

&nbsp;

&nbsp;

&nbsp;

with this: (example from plugin site)

<li data-target="#my<ahref="http://www.jqueryscript.net/tags.php?/Carousel/">Carousel" data-slide-to="0" class="active">

I get dots that actually work.


Cannot install Drupal 8 on Windows 8 XAMPP PHP 5.6

You have comments disabled in your opcache configuration. Add the following line

opcache.save_comments=1 in php.ini or if opcache has its own config file

Please consult this for more details.


How to hide flag link if current user and author are same?

If it is a flag on nodes, you just need to set "Users may only flag content of others" in the Flag access by content authorship paragraph of the FLAG ACCESS options.


There's also a Lightbox2 Drupal Module that integrates with various other modules. And you don't need to update your Drupal's jQuery.

Here's the documentation since I don't really know how you're intending to use Lightbox2 on your website.


How do I use a preprocess function to add custom classes to a view fields?

As mentioned in the comment you can add classes to fields through the interface, and you can use field tokens as CSS classes.

Add field-value-based CSS class to a field

Position the field with the value you want to use as the CSS class (the value-class field) above the field where you want the class to appear (the styled field).
Set the value-class field to Exclude from display if you don't want it to appear there.

If you need it visible in some other place then add that same field again where you need it, while keeping the first one for the token (because you can only use tokens of fields preceding in the Fields list).
Edit the field where you want to apply the CSS class (the styled field) >

Uncollapse Style settings >
Customize field and label wrapper HTML (or Customize field HTML if you don't need the wrapper) >
Create a CSS class and
enter the first part of your class (myclass)

(class names can't start with numbers and some special characters so it's good to control at least the first character to make it independent of the other field's value to prevent trouble down the line).

Uncollapse Rewrite results (don't enable it, you just need to temporarily reveal and uncollapse to copy the token),

uncollapse Replacement patterns,
copy the value-class field token and
paste it in the above CSS class field

(you end up with something like myclass-[field_name_a]).

Save the View and check your HTML output (in any theme), you will see a class based on your value-class field on the field where you added the class, something like class="views-field views-field-name-b myclass-namebvalue".


Select data from database when submitting a form

You have missed fields() & fetch type -- fetchAll().

Below is the working example. You can find more details here (db_select API)

$query = db_select('node', 'n')->extend('PagerDefault');
$query->fields('n'); // This is like select *. You can retrieve specific fields too.
$query->condition('type', 'article');
$result = $query->execute()->fetchAll(); // you can fetch by object, array, etc...
print_r($result);


Where to collect business logic for Entity models?

You can use the Entity API which allows to specify the class in hook_entity_info(). Then entity_load() will use that class (assuming that you're using/extending from EntityAPIController, not the core one) then it will return instances of the defined class and not dumb stdClass objects. Then you can define your own methods there.

See http://www.trellon.com/content/blog/creating-own-entities-entity-api for an example.

This feature will be in Drupal 8 (already is and core is currently being ported to it).


Drupal Commerce cart page to enter items

Check out the module Commerce Add to Cart Extras. This got me started. Also, the module Views Field View I used to show the quantity that was ordered last time.


How can I avoid that users vote for their own posts?

The rate module allows you to do this in its settings. You have to create a widget for this : admin/structure/rate (just add a new one and then you'll see the option).
You will be asked to choose the content type and the position of the widget in the page that you need to define to see the vote system. I didn't try nor with views integration, neither with Drupal 6.


Is there a module to translate blocks and pages with language modules?

Block languages submodule of i18n
Submodule i18n_block, included in the i18n module, could be what you're looking for ... or at least address part of your question.
Some more details about it:

This module provides support for multilingual blocks.
You can set up a language for a block or define it as translatable:

Blocks with a language will be displayed only in pages with that language.
Translatable blocks can be translated using the localization interface.

Bean module
Consider looking at the BEAN module also. It offers all sorts of enhancements as compared to the (old fashioned) blocks. And possibly you may want to combine it with modules such as Entity Translation to achieve your goal.
The video tutorial Drupal Bean module tutorial - using Bean Admin UI provides a great introduction to really understand the power of the BEAN module, and the kind of things you can do with it (by only using site building techniques, no custom coding involved). It also shows how the Bean module transforms Drupal blocks into fieldable entities.
Managing translations
To actually "manage translations", there are a few typical modules like these (quotes from their project pages, with some bold markup added here):

Translation Management Tool (RC-version for D7).

... provides a tool set for translating content from different sources. The translation can be done by people or translation services of all kinds. It builds on and uses existing language tools and data structures in Drupal and can be used in automated workflow scenarios.
This module does not make i18n or any other language module for Drupal obsolete. It does only facilitate the translation process.

This module seems already well ported to Drupal 8 also, so much that it is already recommended as a successor of the Translation Overview module (which is about translations of  nodes), which also refers to the Translation Table module (which is about translations of taxonomy terms and menu items).

Translation Management  (No version for D7, only for D6).

... provides complete workflow management for multilingual Drupal sites.
Content managers can manage all translations from one central page. The module shows which contents need translation and notifies translators about what they need to do.
... The module introduces a new Translator role. This role allows translating between specific language pairs. Translators have individual job queues, showing documents that were sent to them for translation.
... Translators can translate everything without having to learn Drupal administration. Node contents, menus, taxonomy, CCK, blocks and strings are all translated from the same interface.

Note: even though there is no D7 version (yet), there are quite a few D7 related issues (and there is a GIT branch for D7 also). And there is the Drupal-Translation.com website with tons of interesting documentation.
Interface translations
The translation of the interface is about the translation of various text strings used throughout the site, like labels used on buttons such as submit, or on tabs such as view or edit. They are the same on all sites (no matter what actual content is contained in a site).
To manage these kinds of translations, there is the Localization update module.
More translation modules
Translations in Drupal is fun, here are a few more to finish:

Language Icons.
Variable.
Title.
Entity.


Add new tags to Chosen Widget or Display All on Autocomplete Deluxe

For Autocomplete Deluxe, there looks like there's a bug in the code.

Update line 287 of the js file autocomplete_deluxe.js to include a question mark, as shown in the third last line of this block of code:

Drupal.autocomplete_deluxe.SingleWidget.prototype.setup = function() {
  var jqObject = this.jqObject;
  var parent = jqObject.parent();

  parent.mousedown(function() {
    if (parent.hasClass('autocomplete-deluxe-single-open')) {
      jqObject.autocomplete('close');
    } else {
      jqObject.autocomplete('search','?');
    }
  });
};

Also update the maximum results shown in line 30 of the module by changing to $limit = 0 (the default of 10 overrides whatever you have set for the field):

function autocomplete_deluxe_taxonomy_callback($field_name, $tags_typed = '', $limit = 0) {


How can I make a view block of related products?

This patch solved this issue, https://www.drupal.org/project/commerce/issues/3015347#comment-13310494


How do I delete all entities of a bundle?

There are some examples of removing nodes of a certain content type. In that case node is the entity type and article could be bundle (content type). This is no different. paragraph is the entity and [paragraph type] is the bundle.

For instance this post: https://stackoverflow.com/questions/34593060/drupal-8-delete-all-nodes-of-the-same-type

There are a few alternatives listed, but I suppose this should work:

$paragraphs = \Drupal::entityTypeManager()
    ->getStorage('paragraph')
    ->loadByProperties(array('type' => 'your_paragraph_type')); // System name

foreach ($paragraphs as $paragraph) {
    $paragraph->delete();
}


Feeds importer. Only imports a certain amount then stops

you can check your php config php_memory_limit must be at least 128M and max_execution_time 120

also check the error logs go to admin/reports/dblog and check for the errors logged by the server, maybe you can find the problem there

Also make sure you are getting all the errors so you can make a better debug in your issue

Change settings in your site

You can show all errors by adding a few lines to your local testing site's settings.php:

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
//Note:  Do not include the opening and closing PHP tags when you copy this code

In addition, navigate to Administration→ Configuration→ Development → logging and errors and select "All messages". (This sets $conf['error_level'] = 2; .)


Your question is about relationships between the different entities or content types like users, bands, shows and so on. You build this relationships with reference fields.

For the dashboard you don't need necessarily views.

When you use a reference field to another entity you can configure in the display mode to render the referenced entities. Then you can configure the display mode of the referenced entity, which can contain itself other reference fields which you then configure in the same way and so on.

So you can build and theme the complete dashboard without views by only showing the parent entity.

Though at some point you probably need views, as view block in a header, footer or sidebar or from the start as view page, if you need more options for filtering. The entities displayed in these views can contain again rendered reference fields. This is how you combine these tools to build the layout you want.


Load fields from a node which reference an entity

You can use entity_metadata_wrapper() to easily get referenced entities, their field and much more.

$node_wrapper = entity_metadata_wrapper('node', $entity);

foreach ($node_wrapper->field_products as $product_wrapper) {
  // You can print or do whatever you like with the value of the fields
  // of the referenced entity like below:
  print $product_wrapper->field_flow_rate->value();
}


How to code custom entity to access more than one database table?

Entity API itself can only interact with one base table for joining to fields, querying with EntityFieldQuery, loading/saving revisions, etc, but you can use more than one table for storage if you implement your own storage controller which you can specify in your hook_entity_info().

You'll want to subclass DrupalDefaultEntityController and override the load() method and buildQuery() method if you want some EntityFieldQUery support.

If you are using Entity API module, you'll want to extend EntityAPIController and override the save(), load(), and delete() methods for full CRUD support.


How to validate and submit a form using AJAX?

I know this is question has been lying around for a couple of years by now, but I don't feel any of the other answers really get the point of Drupal 7 ajax form submission, so I'll try to explain it.
Since your form should work as well without the ajax as per good practice, your ajax submit handler should do nothing but return the form. Everything else should be in your validation and submit functions.
function ex_form($form, $form_state) {
  $form['name'] = array(
    '#type' => 'textfield',
     '#title' => t('Name'),
     '#default_value' => '',
     '#maxlength' => '128',
     '#required' => TRUE,
  );

  $form['submit'] = array(
   '#type' => 'submit',
   '#value' => 'Submit',
   '#ajax' => array(
     'callback' => 'ex_form_ajax_handler',
     'effect' => 'fade',
   ),
  );
}

function ex_form_submit(&$form, &$form_state) {
  // Submit logic - runs when validation is ok
  // You can alter the form here to be just a markup field if you want.
}

function ex_form_validate(&$form, &$form_state) {
  // Validation logic - invalidate using form_set_error() or form_error()
}

function ex_form_ajax_handler(&$form, &$form_state) {
  return $form;
}


Have a look at your "content post date", it seems to be excluded (click at it, uncheck the option "exclude from display") therefore no field is displayed hence the error.


You could extend the default form by using a Route subscriber.
To do so, create a file named RouteSubscriber.php whithin your module in a src/Routing folder.

the file should look like this:

<?php
namespace Drupal\YOUR_MODULE\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

/**
 * Listens to the dynamic route events.
 */
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    if ($route = $collection->get('system.site_information_settings'))
      $route->setDefault('_form', 'Drupal\YOUR_MODULE\Form\ExtendedSiteInformationForm');
  }

}

You should then create a ExtendedSiteInformationForm.php file within your module src/Form folder like that:

<?php

namespace Drupal\YOUR_MODULE\Form;

use Drupal\Core\Form\FormStateInterface;
use Drupal\system\Form\SiteInformationForm;

class ExtendedSiteInformationForm extends SiteInformationForm {

   /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
   $form=  parent::buildForm($form, $form_state);
   //update your $form...
   return $form;
}
}

This way you won't need your routing.yml file anymore.


Webform: POST data and send user to external URL

That post is accurate. You just need to set the #action of the form to be the URL you want to be POSTed to:

$form['#action'] = 'https://some.other.site.com/destination';


New user email notification not being sent

Install and use the SMTP module: https://drupal.org/project/smtp - Period. Nothing comes close to using SMTP and you'll avoid current and future headaches. Details are below. Good luck!

Why sending via the server is bad:

The post recommended by Anil Sagar is good. However, based on my expertise with web hosts, especially DreamHost, you want to avoid at all costs sending emails from your server.

By default, Drupal sends email via the server it's residing on. That server might not have email configured. That server might have email configured now, not properly configured in the future. That server might get spam listed in the future. In summary, a lot of things might happen that leave you without email sending capabilities, and most probably you will not be notified of the issue.

Also, you're lucky that your email is "not working" as, in most cases, some emails via the server will be sent, others will not, which is even worse as you'll not even know you have a problem to fix.

Why sending via SMTP rocks:

When you send via SMTP, you're relying on an external dedicated mail server. Choose a solid mail server provider (Gmail, Yahoo, Zoho, etc) and you'll be on the safe side. They handle maintenance and everything for you and all you have to worry about is the first step which is setting up and installing the SMTP module.

Note about SMTP sending limits:

If you're sending a large number of emails, most good email providers will have a daily limit that you'll reach and they'll stop sending your emails. This is a way for them to fight spam. For Gmail, I think the daily limit is 250 emails, which is plenty for most needs. If you have larger volumes, you might want to buy a paid SMTP account with a large limit or consider something like: http://www.mandrill.com/ - You can send up to 12,000 per month for free. They also have a Drupal integration module: https://drupal.org/project/mandrill

And if you're sending a large number of emails via your own server, you're ending up on a spam list from day one and your emails will soon not even reach junk mail.


How can I update the length of a base field definition in an update hook?

I was having the exact same issue, trying to update the "max_length" of the name field of a custom entity.
I did a hook_update like that :

function mymodule_update_8005() {
  $entity_definition_update_manager = \Drupal::service('entity.definition_update_manager');
  $field_definition = $entity_definition_update_manager->getFieldStorageDefinition('name', 'myentityid');
  $field_definition->setSetting('max_length', 255);
  $entity_definition_update_manager->updateFieldStorageDefinition($field_definition);
}

But then, even if the fieldDefinition had correctly changed, I was still having the old length limitation.

Finally, what I had forgotten to do was changing this max_length in my entity definition itself, here :

public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
  $fields['name'] = BaseFieldDefinition::create('string')
  ->setLabel(t('Title'))
  ->setSettings(array(
    'max_length' => 255,
    'text_processing' => 0,
  ));
  ...

After that, it worked as desired.


Help with SQL-query finding and updating uid's from non-existing users in comment table

I think this should do it. Make sure you take a backup before running this:

UPDATE {comments} SET uid = 0
WHERE uid > 0
AND cid IN
(
  SELECT cid FROM {comments} AS comment
  LEFT JOIN {users} AS user
  ON user.uid = comment.uid
  WHERE user.uid IS NULL
)


Copy the file:

rate-template-thumbs-up-down.tpl.php

that you find in the module rate/templates/thums-up-down to your theme's template folder.

Then change these two lines that print out the percentage:

<?php print $results['up_percent'] . '%'; ?>

...

<?php print $results['down_percent'] . '%'; ?>

to this:

<?php print $results['up']; ?>

...

<?php print $results['down']; ?>


You can get at that with the commerce functions hook_commerce_checkout_page_info() and hook_commerce_checkout_pane_info(); with more documentation on that here: http://www.drupalcommerce.org/developer-guide/core-architecture/info-hooks/checkout-info-hooks#checkout-pane.

It's a little complicated because the panes, pages, and forms are hard-coded into DC's checkout logic. There are a couple of modules that let you override and specify your own pages or other cart functions https://drupal.org/project/dc_co_pages, and https://drupal.org/project/commerce_cart_view_override

You'll probably need to do any serious changing by coding your own module calling the commerce functions/pages you need for your use case.


Custom install profile calls another install profile

The way install profiles work on Drupal 6, I don't think this will be possible. The modules that are installed are based of the dependency list in the .info file, and since you can't depend on an install profile you can't create that full attachment.

You could come far, by doing includes and callling the fuctions that would otherwise be called by Drupal though, but you would probably have to maintain your own .info file.


Problem updating node module from drupal 6 to drupal 7

The problem seems to be with the Locale module. I would suggest disabling the Locale module in D6, running the D7 update.php, then enabling Locale and running update.php again.


Use Path Auto and Token Module to achieve it. It also supports multilingual functionality!!

  The Pathauto module automatically generates URL/path aliases for
  various kinds of content (nodes, taxonomy terms, users) without
  requiring the user to manually specify the path alias. This allows you
  to have URL aliases like /category/my-node-title instead of /node/123.

Go to admin/config/search/path/patterns path :


Rules: save a node but not "fire" a rule that create a loop

Edit: I misread the question but this might be beneficial anyway. Not sure if you're using saving or updating and what you mean by arguments.

You need a Boolean field in your content type that you set to true in the actions of your rule. Then add a condition that if the Boolean is true, the rule doesn't fire repeatably.

You could also skip the extra field and add a condition that one of the fields you set is empty.

If you can't access the fields, you need to add an "entity has field" condition.


You could add the domain to the template names in a theme name suggestion hook for each template, but if you want to have a complete set of twig templates for each domain it might be easier to create separate themes and switch them. In custom code with a theme negotiator or with this module Domain Theme Switch.


How can I catch an EntityStorageException exception?

Thanks to Hudri, the answer to this problem was to add a backslash before SoapFault in the catch because my try/catch code is made within a local namespace and the Soap call is made in the global namespace. So my code should have been catch (\SoapFault $ex). All working now - thanks.


The photo field is an image field? The value() function returns an array which is actual file data linked to the image. To render (or to create a renderable build), you can for example use theme_image function, which prints out an <img> tag.

$node = node_load(43);
$node_wrapper = entity_metadata_wrapper('node', $node, array(
    'langcode' => $GLOBALS['language'],
    'bundle' => 'subject'
));

$field_value = $node_wrapper->field_teaser_image->value();
$build = array(
    '#theme' => 'image',
    '#path' => $field_value['uri'],
    '#alt' => $field_value['alt'],
    '#title' => $field_value['title'],
    '#width' => $field_value['width'],
    '#height' => $field_value['height'],
);

print drupal_render($build);


You want to have a read only access for your users, correct?
It's not so difficult to implement in Amazon S3.

First of all, you need to set up an IAM user and apply read only permissions for it. AWS provides pre-defined policy template. More information here:
http://docs.aws.amazon.com/IAM/

Once you created a user, you can connect to your storage using tools such as CloudBerry Explorer. When you client authanticats using key pairs assigned to the read only user you created, they will be able only to download files.
You can download CloudBerry Explroer here:
http://www.cloudberrylab.com/free-amazon-s3-explorer-cloudfront-IAM.aspx

Regards,
Vlad,
CloudBerry Lab


Solution: we can use insert_view module to add view in CCK field.


How to add a simple online payment transaction?

I agree that Commerce Kickstart is too advanced for what you need. You'd end up spending a lot of time configuring "off" a lot of stuff just to give your users a simple checkout.

I've setup several simple custom payment solutions for Drupal sites using Webform and Stripe.com.

Here's an example of a Stripe/Webform component: https://drupal.org/sandbox/jlyon/1472346

Basically you'd build out the component that captures their CC info and submits it to Stripe via javascript, then run the charge on the server side using the token that Stripe gives you. This gets you out of the bulk of PCI compliance (you just need to have SSL enabled and ensure that you don't let any CC info be sent to your server). Since Webform is easy to use and you can add whatever form elements you'd like, you can quickly capture the right customer info and set the "product" or dollar amount in a dropdown field, then run the charge in a _validate() function.

Not quite plug and play but also not a lot of development time to get a solid working solution.

Edit: You mentioned PayPal – you could provide that as an alternate purchase opition and use a simple paypal button to send them on their merry way; also https://drupal.org/project/webform_paypal

Edit 2: After thinking about Ryan's comment a bit, I would suggest you first grab Commerce module and tinker with it for a while. You may find that it gets you what you need. I have really enjoyed implementing some custom, lean payment systems using Stripe where a traditional "checkout" workflow wasn't appropriate, but there's no need to reinvent the wheel if it fits.


Importing Custom (Trumba ) RSS Feeds into Node

Consider using the Feeds XPath Parser. Here is a quote from its project page:

  Feeds XPath Parser is a Feeds plugin for parsing XML and HTML documents. It enables site builders to leverage the power of Feeds to easily import data from complex, external data sources. Each element you wish to extract is setup using configurable mapping queries, saving time for developers who would otherwise have to code complex, specific-use modules. It also enables end-users to build web scrapers and other useful tools within Drupal.


How to customize the node info being shared on Facebook and other sites?

I would use the Meta Tags module. It makes the Facebook Open Graph information easy to update and configurable per node, if necessary.


Prevent redirection after comment submission

Use FormStateInterface::disableRedirect(), e.g.

$form_state->disableRedirect();

Make sure you run that code in a submit handler for the form, not in the form alter hook.


The following works perfectly for me in devel/php

global $databases;

dpm($databases);

It should return the full array of database information:


You're telling the form to submit via POST, and then once it's done submitting, to redirect to the webform. I think what you intended to do was to make the form submit its data straight to the webform, which you could do with the #action key in the $form array. See http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/6#action

However, this isn't really a very robust approach. A better approach would be to put together your own webform, and then put that webform into a block. If you need to do any custom processing on the webform, the webform module has its own API and hooks that you can use.


Trying to find variable names from $user array

The best way to do this is use the devel module.

Once enabled you can use the dpm($variable) function to have it printed out on the screen.

Another (more complex to set up) solution would be to use xdebug and a debugger.


Hooking into the user login block to modify prefill default text in username and password

To target a specific form you can use hook_form_FORM_ID_alter(), e.g.:

function MYMODULE_form_user_login_block_alter(&$form, &$form_state, $form_id) {
  $form['foo']['#default_value'] = 'bar';
}

If you'd rather do it all in one alter hook though, use the provided $form_id parameter instead of $form['#id']...it's guaranteed to be the right one.

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'user_login_block') {
    $form['foo']['#default_value'] = 'bar';
  }
}

As a side note, it's probably not working at the moment because you're negating the condition:

if ($form['#id'] !== 'user-login-block') {

should be

if ($form['#id'] === 'user-login-block') {


Don't render html.tpl.php for a specific path

You could do something like this:

/**
 * Implements hook_menu
 */
function MY_MODULE_menu(){
  $items = array();
  $items['clean/view'] = array(
    'page callback'    => 'MY_MODULE_clean_view',
    'page arguments'   => array(2, 3),
    'access arguments' => array('access content'),
    'type'             => MENU_CALLBACK,
  );
  return $items;
}

/**
 * Menu callback for clean/view
 * Output view without wrapper page markup
 */
function MY_MODULE_clean_view($name, $display = 'default'){
  // Note views_embed_view performs views access check
  print views_embed_view($name, $display);
  drupal_exit();
}

You can then use the dynamic path /clean/view/view_name/display_id to render the View without the wrapper markup.


D7 Node Field: Create OG Member Checklist in Node Edit Form

Use hook_form_alter to do a entity field query or SQL query to get a list of UIDs that belong to 1 group ... OG may have a function to retrieve that list I dunno.

Once you have a list of UIDs use Devel and dpm($form); the form object and you can simply unset() the #options values for UIDs that dont belong in the OG group. Here's a similar thing I did for limiting to a taxonomy term_reference field to a given level of a nested taxonomy.

If you're paranoid you can also append your own validator function to the form_submit function and cross check that valid UIDs (members in the OG group) are being saved .... but I dont usually bother to do that for intranet sites (I have "trusted" users / staff members ... not joe blow public).

Sample code doing basically the same thing for a taxonomy term reference field.

/**
 * Implements hook_form_alter().
 */
function eap_student_videos_form_alter(&$form, &$form_state, $form_id) {
    switch ($form_id) {
      // Field specific overrides.
      case 'eap_studentvideos_node_form':
          $form['field_eap_video_country']['#after_build'][] = 'eap_country_term_limit_to_countries';
          break;
    }
}

function _eap_region_tids() {
  return array(24,35,48,8,4);
}

function eap_country_term_limit_to_countries(&$element) {
    $options = $element[LANGUAGE_NONE]['#options'];
    $result = db_query('
        SELECT tth.tid, ttd.name AS term_name
        FROM taxonomy_term_hierarchy tth
        LEFT JOIN taxonomy_term_data ttd ON tth.tid = ttd.tid
        WHERE tth.parent IN  (:tids)
        ORDER BY 2 ASC
    ', array(':tids' => _eap_region_tids()));
    $country_tids = $result->fetchAllAssoc('tid');
    $country_tid_array = array_combine(array_keys($country_tids), array_keys($country_tids));
    $new_options = array_intersect_key($options, $country_tid_array);
    array_walk($new_options, function(&$value, &$key) { $value = str_replace('-','',$value); });
    // array_merge() destroys the array keys.
    $new_options = array('_none' => '- Select a value -') + $new_options;
    $element[LANGUAGE_NONE]['#options'] = $new_options;
    return $element;
}


How do I show the result on same page after submitting the form?

Request a rebuild in submitForm() and then display the result in buildForm():

public function buildForm(array $form, FormStateInterface $form_state) {

  // build form

  if ($form_state->isRebuilding()) {

    // display result

  }
}

public function submitForm(array &$form, FormStateInterface $form_state) {

  $form_state->setRebuild();

}


While you could utilize hooks like hook_form_FORM_ID_alter setting custom #validate & #submit functions or hook_webform_submission_insert, I've had better success using the Payment module and writing a custom Payment Method class.


Programmatically do something when a node is updated

Hooks are still implemented as global, procedural functions; you need to declare them in the .module file just like Drupal 7, not in a controller class:

function MYMODULE_entity_update(Drupal\Core\Entity\EntityInterface $entity) {
  // ...
}

The system will move to OO in Drupal 9.

It's also worth noting that hook_ENTITY_TYPE_update() also exists, so you can still use hook_node_update():

function MYMODULE_node_update(Drupal\node\NodeInterface $node) {
  // ...
}


You can use the String Overrides module.  More options are described in the handbook page Change default strings (text).


If you want to change what is shown on the site front page you can do that under Configure > System > Site information.
Enter node/[number] into the Default front page field (replace the [number] with the node ID of the content you want to appear on the front page).

If you want to change Content Views to show only a particular node add the Filter Content: Nid with the Operator set to Is equal to and enter your node ID number in the Value field.
This will show only the one node information on that Views.


How to set value for multivalue field in drupal 8 programmatically

I would rewrite your code like this.
N.B.: This an edited version of the original answer, following some helpful points coming from the comments.

$poll = Poll::load($pollid);

$poll->question->setValue(['value' => 'test']);

$target_ids = array(13,14,15);
foreach($target_ids as $target_id){
  $poll->choice->appendItem($target_id);
}
$poll->save();

Hope this does it!


Is there a module similar to the Tiered Taxonomy Block module for Drupal 7?

Not sure if there is a better solution but this can now be done in a round about way with views.

Create a term view.
Add a required relationship to its parent term.
add a required relationship to node.
add term title for both term and parent term relationship and term count.

You'll have to display the hierarchy at the theme level unless you want to use group headers.


A little calendar icon to show when something was posted?

It's a simple theme modification, probably also easily done via .css. There is not need for a module for this.

Simply edit your themes node.tpl.php page in your theme directory/templates/

Find:

 <?php print $submitted; ?>

Wrap a simple tag round it like so:

      <?php print $submitted; ?>

Write your css:

.date_submitted {
  background: url("../img/icons/calendar_view_month.png") no-repeat scroll left top transparent;
}

You have to save the calendar image or create your own ->

You also probably need to do some simple formatting in the css like padding-left (to push the text to the right to stop it overlaying the image) etc ...

If you don't know what I am on about, read up about css3 and drupal themeing and learn some basics.


If you simply want to place a menu in side bar use Menu Block Module.When  user clicks on a menu item, it will load the page linked to that menu item.

But If you want to provide filter criteria in side bar, like if user clicks on "Koryo", It will filter the results and display results of "Koryo" only, than you should consider Facet API.


Can't seem to get my plugin class include to load?

Looks like my class definition should not have had a capital "C" in "Class". Quite frustrating since I'm using drupalcs which complains about the lower case "class".


Why are all of the non-value columns indexed, but the value column isn't?

I'm not an expert in this but I think it's probably due to the fact MySQL enforces a maximum key length for indexes. For InnoDB this is 3500 bytes (further limited to 3072 bytes by MySQL itself), and for MYISAM it's 1000 bytes.

Whether or not the value columns are indexed is actually done on a per field-type basis. For example, the long text field type (for fields like the node body) has no index on the fieldname_value column, but it does have an index on the fieldname_format column.

The fieldname_format column is a varchar limited to 255 characters, and so would not produce an index key that is too long. Conversely the fieldname_value column is a longtext type, which has the potential to create a key that would be too long. (You can specify a prefix length to get around this but I don't think Drupal supports it).

As another example, if you then look at a table for an image (or file) field type you'll notice there is an index on the fieldname_fid column. Because this field is an integer type it naturally lends itself to be indexed, without having to worry about the maximum index key length.

I think it basically comes down to the type of data the field is storing. entity_type/bundle/etc. are all integer columns and so can be easily indexed by whatever storage engine you're using, while text types (or varchar types with a large enough length) will create an index key that's too large for the storage engine to handle.

Hope that helps a bit


My page showing up with a title, but with the content div empty, but only for users

It really sounds like a permissions problem. Do you (or did you) have field permissions installed?

If you do you will have to set field level permissions (which are separate) from node permissions. If you have field permissions viewing/editing a node does not mean a user can view/edit specific fields, you will have to specify these permissions in addition to the overall node permissions.


Check to see if the ID has changed. If the content containing #facets is getting ajaxed in then the ID may have changed

Or you could try:

jQuery('body').on('click', '#facets a', function () {
        alert('enter');
    });


Allot space to individual registered user

A disc quota is one thing but also checking user-content in the db could be tricky :-). Never done something like this but here's what I would try:

use file_save_upload() to validate the upload. Part of the validation should be
the use of file_validate_size() and
file_space_used() to check the used space.

But as I said that checks only stuff inside the files table. No other content (text inside fields, cached content, thumbnails...) will be handled.


How to show thumbnail for image when edit the node Drupal 8

I resolved that issue.

Me steps:

go to image style and create new image style (/admin/config/media/image-styles).
go to View modes (/admin/structure/display-modes/view)
find Media section and create new view mode for media (/admin/structure/display-modes/view/add/media)
go to Media bundles (/admin/structure/media).
edit Image and go to Manage display (/admin/structure/media/manage/image/display)
click edit to your view

Now we can configure Paragraph content type or Content type


how to have a different page from the front page?

When placing the block, you can set the block visibility conditions.

To get a block to show up only on the home page, you would set <front> and Show for the listed pages under the pages visibility section.


Is there a way to filter blocks by vocabulary instead of NID or CT?

Have a look at my answer to "How to make "Page specific visibility settings" for blocks more flexible?". It explains how the Rules block visibility module can be used to answer that question.

Your question here seems to be a variation of it. You could use a similar approach, so that in the end you'd only have to write a Rules Component related to your criteria here, ie to intercept your condition about "if at least one term of a given vocabulary is in the node" (in which case the Rules block visibility module should take care of "showing the block in whatever region". Done!

Note: for this to work, do not have to enable the PHP Filter module (always a good thing if you can  avoid that).


Using Highlight Module with Default Search Module

I think, looking at the examples, that something like this expression should work if you have clean URLs turned on and searches have URLs like http://example.com/search/node/keywords.

\/search\/node\/([^?#]+)

But I have never used this module and it looks a bit ropey. You can test your own regular expressions at https://regex101.com/ (use JavaScript mode). Contrary to the examples you should not need to include the domain of your site in the search patterns.


The unfortunate answser is that Pathauto does its deed after File Field Paths. A custom solution will be needed.


How to show a message “field is required” from webform validation?

Webform Validation module can be used to add validation in field of webform.


Declaration of DrushInputAdapter::hasParameterOption($values) must be compatible with Symfony

Updating to Drush 9, as suggested in the comment by user3346970, is certainly one solution to this problem. If you wish to stick with Drush 8, upgrade to version 8.1.15 or later. The problem you report above was fixed somewhere around version 8.1.12.

I'm not certain about the exact versions of Drupal Console to use with each version of Drupal, but I believe that you will probably also discover that updating to the latest version should resolve things as well. The error you are seeing indicates you are crossing Symfony version 2 (e.g. in an old version of Drush or Drupal Console) with Symfony version 3 (e.g. in Drupal 8.4.0 and later).


Can't submit data when rendering a webform programmatically

@see How to embed a Webform?

I recommend using something like...

return [
  '#theme' => mycontroller_page',
  '#content' => [
    'title' => t('I am a page from your controller'),
    'form' => [
      '#type' => 'webform',
      '#webform' => 'my_webform_id',
    ],
  ],
];


how many content type fields can I have on a drupal site?

In Views, take a look at the SQL that it is generating in the preview of the view.  If you see tons and tons of JOINs, one for each field, that is most probably the cause of the slowdown.  What Drupal does is create a table for each field that is shared between content types and that means Views has to join everything back together again based upon the nid.  So, if this is happening, you might be able to improve performance by having each of these fields unique to an individual content type.  In that case, just as long as they are single value fields, they will just be another column in the database table defining the content type and can be grabbed all at once.


"View any coupon of any type " permission for anonymous reduces the Score in acquia

The Acquia Insight tool (I am assuming you are referring to that score) is a tool that helps you find potential problems in your website and configuration. It is an automated tool that performs simple checks. It is a guide and a tool. Not exact science. (It could throw a false positive.)

However in my installation of Commerce Coupon 7.x-2.0-rc2, there is also the permission to Redeem any coupon (and the per type Redeem <type> coupons permission). And that works for anonymous user as well. Perhaps you should try that instead?


Array of items as contextual filter in Views

All you need to check "Allow multiple values" true by click on More toggle part of contextual filters field works well.

example.com/some-path/user3,user2,user12


What changed in the way to implement a block?

Using the "Powered by Drupal" block as an example:

Drupal 7

modules/system/system.module

/**
 * Implements hook_block_info().
 */
function system_block_info() {
  $blocks['powered-by'] = array(
    'info' => t('Powered by Drupal'),
    'weight' => '10',
    'cache' => DRUPAL_NO_CACHE,
  );
  return $blocks;
}

/**
 * Implements hook_block_view().
 */
function system_block_view($delta = '') {
  $block = array();
  switch ($delta) {
    case 'powered-by':
      $block['subject'] = NULL;
      $block['content'] = theme('system_powered_by');
      return $block;
  }
}

Drupal 8

core/modules/system/src/Plugin/Block/SystemPoweredByBlock.php

<?php

/**
 * @file
 * Contains \Drupal\system\Plugin\Block\SystemPoweredByBlock.
 */

namespace Drupal\system\Plugin\Block;

use Drupal\block\BlockBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;

/**
 * Provides a 'Powered by Drupal' block.
 *
 * @Plugin(
 *   id = "system_powered_by_block",
 *   admin_label = @Translation("Powered by Drupal"),
 *   module = "system"
 * )
 */
class SystemPoweredByBlock extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function build() {
    return array(
      '#children' => theme('system_powered_by'),
    );
  }
}

The hook_block_info() is replaced by an annotation, containing all of the necessary metadata within the @Plugin portion of the docblock. hook_block_view() is replaced by the BlockPluginInterface::build() method.

The directory structure is the key here. All blocks must be placed into a specific directory within their module folder (src/Plugin/Block).


function MODULENAME_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'search_block_form') {
    $form['help_link'] = array(
      '#markup' => 'help_tips',
    );
  }
}

That should do the work, but I am not sure if the id 'search_block_form' the right one is.
If you don't have any custom module, just place this code into your current template's template.php, replace MODULENAME with templatename, save and clear cache.


Check admin_theme module. This will allow you to set custom pages in admin theme.


Unable to upload file from $_FILES array in drupal7

The problem is not with your Public file system path but with your Temporary directory; normally it is /tmp if you're in a Mac or Linux server.

You can check that the Temporary Directory is well configured, maybe it is pointing to a non-existing path.

To check the configuration in Drupal 7 you must go to Configuration > Media > File system.


Views: how can I cleanly add a row of arbitrary text within a collection of fields?

In Fields, select Global from the Group Dropdown and then you can select Custom Text and set it up pretty much anyway you'd like; at least in Drupal 6 and Views 3 anyway.


You can do that by using uuid_features the dev version (dev+36)
 and you may need Panelizer (dev) there are some patches there that will solve problems for you.

Also you can try deploy module, though I didn't use it, but it looks like it will become a more promising solution.


Here is a solution using custom coding.

Store all hash codes that are the access code to the DB (I think you do this already), a word of caution do not do md5(node id) or sha1(node id) as anyone will be able to figure it out.
Enable anonymous users to edit the content type they are submitting where the code is needed to edit the node. I know what this mean, keep reading.
Create a custom module where you are going to use the NODE API to intercept the node edit step.

If Drupal 6:  http://api.drupal.org/api/drupal/developer%21hooks%21core.php/function/hook_nodeapi/6

function YOUR-MODULE-NAME_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {
    case 'prepare':

    // Add PHP Code here to validate the hash code
    // You can use an if/else condition to print an access denied message
    // if the code is not valid or expired

    break;
  }
}

If Drupal 7: http://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_prepare/7

function YOUR-MODULE-NAME_node_prepare($node) {
    // Add PHP Code here to validate the hash code
    // You can use an if/else condition to print an access denied message
    // if the code is not valid or expired
}

And that is all.


twig problem, how to override base templates?

You can't. Create your own page.html.twig instead and use {% embed '@my_subtheme/navbar/... %} in there.

Use the machine name == directory of your subtheme for @my_subtheme. Only lowercase, digits and underlines are allowed for machine names. The Twig file must be placed below the templates subdir, but do not include templates/ in the embed string


How reliable is hook_post_action module?

The module register a shutdown function in hook_entiyt_delete(), hook_entity_insert(), and hook_entity_update().

/**
 * @param $entity
 * @param $type
 */
function hook_post_action_entity_insert($entity, $type) {
  drupal_register_shutdown_function('_hook_post_action_post_save', $entity, $type, 'insert');
}

As such, the hooks invoked from that shutdown function are always invoked, except in the case the shutdown function is not called, which as the documentation for register_shutdown() says, it can happen if the process is killed with a SIGTERM or SIGKILL signal. Since PHP doesn't have a function to removed a shutdown function, I would say the module is reliable.

As side note, hook_node_postsave() and hook_entity_postsave() are always invoked, whenever the entity is created, updated, or deleted.

/**
 * @param $entity
 * @param $type
 * @param $op
 */
function _hook_post_action_post_save($entity, $type, $op) {
  $entity_is_saved = FALSE;
  $new_entity = NULL;

  if ($op == 'insert' || $op == 'update') {
    $entity_is_saved = TRUE;
  }
  if ($op == 'delete') {
    list($id) = entity_extract_ids($type, $entity);
    $new_entity = entity_load($type, array($id));
    if (!$new_entity) {
      $entity_is_saved = TRUE;
    }
  }
  if ($entity_is_saved) {
    module_invoke_all('entity_post' . $op, $entity, $type);
    module_invoke_all('entity_postsave', $entity, $type, $op);

    if ($type == 'node') {
      module_invoke_all('node_post' . $op, $entity);
      module_invoke_all('node_postsave', $entity, $op);
    }
  }
}


How to add custom stylesheet to print pdf output?

One of the benefits mentioned on the PDF using mPDF project page is "Add custom Style Sheet to PDF". Here are some more quotes about this module (from the module's project page):

  ... used for Conversion of HTML pages to PDF documents using mPDF PHP Library. It allows you to generate a pdf document of any node.

  Features

  PDF creation (www.example.com/node/nid/pdf) where nid is the node id of content to render.
  PDF generation API is provided, the content developers can use this API to generate a PDF document.
  By creating your own CSS file and/or the node.tpl.php template files, it is possible to change the look of the output page to suit your taste.

  Benefits

  Document Properties
  PDF Page settings
  Watermark Image/Text
  HTML Header & Footer
  Password Protected PDF
  Add custom Style Sheet to PDF
  Enable/disable PDF generation for each Content type
  Display/ hide any fields of Content type for PDF


If two modules are altering the same menu item / form / page etc, last one will "win".

If you need some control over this, and are expecting collisions, you need to implement hook_module_implements_alter:

  This hook is invoked during module_implements(). A module may implement this hook in order to reorder the implementing modules, which are otherwise ordered by the module's system weight.

Do your best to have your hook fire last, and if menu item you are altering does not look like the one you are expecting (it was altered already), write a warning message to watchdog.


Render View with title in twig template?

You should develop a custom twig extension for that.
I developed a simple module twig_views for that purpose check it out.

Example of use:

 {{ render_view('view_machine_name', 'display_name') }}

if you use 8.2.6 drupal version, and twig_xdebug Module
you may have some error like:

  The website encountered an unexpected error. Please try again later.
  Symfony\Component\DependencyInjection\Exception\LogicException: Service 'twig_xdebug' for consumer 'twig' does not implement Twig_ExtensionInterface.

Those steps in this comment will solve your problem.


How do I set up user's "Favorite Tags" and "Ignored Tags" tag subscriptions?

I would recommend using the Flag module to allow your users to pick "favorite tags".  It is still in beta for D7 however.

Also, in the future you could look at the Flag Terms module to allow your users to flag taxonomy terms.  That module is still in dev.

You can use Views to create lists of "favorite tags", etc.


Check the actions of the Rules module:

http://cgit.drupalcode.org/rules/tree/src/Plugin/RulesAction?h=8.x-3.x

These are the actions provided out of the box by Rules.

Each action class has a @RulesAction annotation. Wire that up and you should see your Rules action appear. Think of the annotation here very similar to what you would have in hook_rules_action_info().

The only exception is instead of defining it in the .module file, it will live in mymodule/src/Rules/Plugin/RulesAction/NameOfYourAction.php.

Here is an example of what it might look like:

namespace Drupal\mymodule\Plugin\RulesAction;

use Drupal\user\UserInterface;
use Drupal\rules\Core\RulesActionBase;

/**
 * Provides a 'custom action' action.
 *
 * @RulesAction(
 *   id = "mymodule_custom_action",
 *   label = @Translation("Custom Action"),
 *   category = @Translation("Custom"),
 *   context = {
 *     "user" = @ContextDefinition("entity:user",
 *       label = @Translation("User"),
 *       description = @Translation("Specifies the user we are taking action on.")
 *     ),
 *   }
 * )
 *
 */
class NameOfYourAction extends RulesActionBase {

  /**
   * Flag that indicates if the entity should be auto-saved later.
   *
   * @var bool
   */
  protected $saveLater = FALSE;

  /**
   * Does something to the user entity.
   *
   * @param \Drupal\user\UserInterface $account
   *   The user to take action on.
   */
  protected function doExecute(UserInterface $account) {
    // execution code
    // you may want to set $this->saveLater based on your use case
  }

  /**
   * {@inheritdoc}
   */
  public function autoSaveContext() {
    if ($this->saveLater) {
      return ['user'];
    }
    return [];
  }

}

Please note that at the time of this writing, Rules is in alpha release state. It may change with subsequent releases.


In a Twig template, you can use the format_date() filter. For example, in the node template, the following code could be used to show (using a custom format) when a node has been created. (The following code is a simplified version of the code used from the Unami theme used with the Unami Demo installation profile, in node.html.twig.)
{% set created_date = node.getCreatedTime|format_date('custom', 'l, d F, Y', null, 'ur') %}

{% if display_submitted %}

      {% trans %}by {{ author_name }} {{ created_date }}{% endtrans %}

{% endif %}

I would rather avoid passing a language code to format_date() to let the filter use the language set for the page. Setting the language code would make the template file always use that, even if the page is using a different language code.
{% set created_date = node.getCreatedTime|format_date('custom', 'l, d F, Y') %}

{% if display_submitted %}

      {% trans %}by {{ author_name }} {{ created_date }}{% endtrans %}

{% endif %}

Note that when the custom format is using M for the month, the month name could be not correctly translated. See Date formats with abbreviated month name (M) are not translated using context for more details.


How to force a running migration to stop

Did you try migrate-reset-status, and possibly with --force:
https://www.drupal.org/node/1561820

Otherwise I typically restart PHP manually once (restart your webserver) and then use Drush to rollback all the migrations to try again fresh.

EDIT

I rarely use the UI as everything is usable and scriptable via drush when using Migrate. And trying to use a webserver to check the status of long-running tasks can be error-prone.