You can't know if the person is behind its pc, reading the website but you can know the last access of the user (last time he done an http request to the site I suppose, load a page, submit a comment, etc, but I'm not totally sure about that). You need to look the property "access" of the UserSession.

For example, for the current user, the code is:

$session_current_user = \Drupal::currentUser()->getAccount();
$last_access = $session_current_user->getLastAccessedTime();

The property is a timestamp. You need convert if you want display it on you're site. So, you can now calculate when you considere your user Absent and determine after how many time you considere your user Offline. You can do all these calculation in your template.php file and used your results in your twig file.


Remove comma from unlimited items body in content type

for anyone else using the progressive theme:
template.php, line 458:
from
  $output .= drupal_render($variables['items'][$i]) . (($i == count($variables['items']) - 1) ? '' : ', ');

to
  $output .= drupal_render($variables['items'][$i]) . (($i == count($variables['items']) - 1) ? '' : '');


How can I hide the user profile from users?

You can do this with hook_menu_alter changing the access callback and access arguments for the relevant user menu items.

e.g

/**
 * Implements hook_menu_alter
 */
function MYMODULE_menu_alter(&$items){
  // Change user view and edit callbacks to be "administer users" access only.
  $items['user/%user/view']['access callback'] = 'user_access';
  $items['user/%user/view']['access arguments'] = array('administer users');
  $items['user/%user_uid_optional']['access callback'] = 'user_access';
  $items['user/%user_uid_optional']['access arguments'] = array('administer users');
  $items['user/%user_category/edit']['access callback'] = 'user_access';
  $items['user/%user_category/edit']['access arguments'] = array('administer users');
}

Clear menu cache to apply.


Is it possible to have i18n without l10n?

You can switch to the preferred interface language in your user profile.


How to redirect users after password reset from first time user

It's actually pretty easy, the user module adds user_pass_reset to the form_state all you need to do is check for that value:

function MyModule_form_user_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if ($form_state->get('user_pass_reset')) {
    $form['actions']['submit']['#submit'][] = '_MyModule_user_profile_submit';
  }
}


how to extend ctools functions in my own js file?

JavaScript doesn't allow extending a function with another one. If you want to extend modalContentClose() you just redefine it in your JavaScript file that is included after the JavaScript used by ctools.module.

modalContentClose = function() {
  // Add your own code.
  close();
  return false;
};

Your version of modalContentClose() cannot refer the previous modalContentClose(), if you don't save it in a new variable, as with the following code.

originalContentClose = modalContentClose;

modalContentClose = function() {
  // Add your own code.
  originalContentClose();
};


Can node_url be accessed in page.tpl.php?

You could use the drupal_get_path_alias() function along with the node's nid to get the URL alias of the node without having to load the object:

$url = drupal_get_path_alias("node/$node->nid");

If you want the fully loaded node object though use node_load():

$node = node_load($node->nid);

Memory fails me as to whether node_url is added to the node object in a hook_node_load() implementation or as part of a theme preprocess so I'm not 100% sure it's implicitly available after you call node_load()...if it's not just use the first example which will work.

UPDATE

On inspecting the node module the node_url member comes from template_preprocess_node so while node_load() will give you the fully loaded node, I don't think it's going to be useful in this case.

In fact looking at node.tpl.php and template_preprocess_node, node_url isn't added to the node object at any point so you wouldn't normally access it with $node->node_url but instead $node_url. That variable is available by default in node.tpl.php but not page.tpl.php so you'll have to get it another way (i.e. first example above).


rewriting results in view: trim from the back

Yes. You will have to use something like

$newstring = substr($dynamicstring, -6);

in the php code for the field.


how to ignore the validation of hidden form fields in the user registration form?

You need to use #ajax attribute on your specific field to alter the form ( to remove #required for your hidden element ). It lets Drupal re-build the form before submission and core validation. You will need to implement hook_form_alter and an ajax callback function.

Here is a workaround.

function yourmodule_form_alter(&$form, &$form_state, $form_id) {
    if($form_id == 'user_register_form'){

        $form['toggle_me'] = array(
            '#type' => 'checkbox',
            '#title' => t('Tick this box to type'),
            '#ajax' => array(
              // #ajax has two required keys: callback and wrapper.
              // 'callback' is a function that will be called when this element changes.
              'callback' => 'ajax_form_alter',
              // 'wrapper' is the HTML id of the page element that will be replaced.
              'wrapper' => 'replace_field_div',
              // Don't show any throbber...
              'progress' => array('type' => 'none'),
             ),
        );

        # This field will be shown or hidden when "toggle_me" is checked or unchecked
        $form['dependency'] = array(
          '#type'       => 'hidden', # initially hidden
          '#title'      => 'Dependency',
          '#required'   => TRUE,
          '#prefix'     => '
',
          '#suffix'     => '
',
        );
        // An AJAX request calls the form builder function for every change.
        // We can change how we build the form based on $form_state.
        if(isset($form_state['values']['toggle_me']) && $form_state['values']['toggle_me'] == 1){
            # when "toggle_me" is checked, show this field and set required.
            $form['dependency']['#type'] = 'textfield';
            $form['dependency']['#required'] = TRUE;
        }else{
            # when "toggle_me" is unchecked, hide this field and remove required.
            $form['dependency']['#type'] = 'hidden';
            $form['dependency']['#required'] = FALSE;
        }
    }
}
/**
 * Callback for toggle_me
 *
 * On an ajax submit, the form builder function is called again, then the $form
 * and $form_state are passed to this callback function so it can select which
 * portion of the form to send on to the client.
 *
 * @return renderable array (the textfield element)
 */
function ajax_form_alter($form, $form_state){
    return $form['dependency'];
}

The example shows only two new elements ( toggle_me and dependency ) which are added to user registration form using hook_form_alter. When "toggle_me" is checked, show "dependency" and set required. When "toggle_me" is unchecked, hide "dependency" and remove required.
If you don't know about ajax form alter, download examples module and check ajax example.


How to change boostrap seach button class from btn-default to btn-primary?

Copy /sites/all/themes/bootstrap/theme/bootstrap/bootstrap-search-form-wrapper.func.php

to

/sites/all/themes/my-bootstrap-subtheme/templates

and edit that file at line 14:

 $output .= '<button type="submit" class="btn btn-default">';

to:

 $output .= '<button type="submit" class="btn btn-primary">';

This might be helpful:
https://drupal.org/node/225125


Making sort links on views better exposed filters toggle

Right now, BEF doesn't have a lot of extra classes or IDs that would facilitate this. You could post a feature request in the BEF issue queue requesting the necessary additional markup that would make this fairly simple using jQuery.

At a minimum, you'd need some sort of "active" designation so you knew which link reflected the current sort options.  Currently the active sort option is displayed as plain text (rather than a link) but there's an issue requesting the active sort be displayed as a link.

However, I should point out that I'll be out of town most of Aug and wont' be on the issue queue much... (I'm the BEF maintainer).

I'm always open to bounties!  :)


jQuery ui buttonset is not a function in Drupal 7

You're probably just missing the UI button library (libraries are added when they're needed rather than every js file being included for every page).

To fix, add this in your page callback:

drupal_add_library('system', 'ui.button');

To ensure your JS code is invoked after AJAX calls, you just need to wrap it in a Drupal behaviour:

(function($) {
  Drupal.behaviors.myModule = {
    attach: function(context, settings) {
      $('.form-item-service-amount', context).once('mymodule').buttonset();
    }
  };
})(jQuery);

There's no need to use ready() in this context, Drupal will fire attachBehaviors() on document load, and when ajax calls occur, and your module's attach function will be called each time.

once() just makes sure the buttonset is only applied to an individual element once only, to avoid reattaching behaviours to elements that have already had it.


How to correctly sort on accented letters when using the Lexicon module?

If you want to find out whether or not the patch is applied correctly, open up lexicon.admin.inc and look for this code

if ($form_state['values']['lexicon_clear_filter_cache_on_submit'] == 1) {
 _lexicon_clear_filter_cache(NULL, TRUE);
function lexicon_alphabet_form($form, &$form_state) {
 '#type' => 'textarea',
 '#title' => t('Enter all the digits of your alphabet, in the correct order.'),
 '#default_value' => implode(' ', variable_get('lexicon_digits', range('0', '9'))),
 '#description' => t("Separate the digits by a blank. If you don't want terms to start with digits, leave this blank."),
);

If the patch has been applied successfully it will look like this

function lexicon_alphabet_form($form, &$form_state) {
  '#type' => 'textarea',
  '#title' => t('Enter all the digits of your alphabet, in the correct order.'),
  '#default_value' => implode(' ', variable_get('lexicon_digits', range('0', '9'))),
  '#description' => t('Separate the digits by a blank. If you don\'t want terms to start with digits, leave this blank.'),
  '#rows' => 1,
 );

$form['transliteration'] = array(
  '#type' => 'textarea',
  '#title' => t('Enter transliteration rules used for indexing terms.'),
  '#default_value' => _lexicon_transliteration_ruleset_encode(variable_get('lexicon_transliteration', array())),
  '#description' => t('Use the syntax "é:e,è:e,ê:e,...". Transliteration rules are only applied internaly for indexing. Terms are displayed unchanged.'),
  '#rows' => 1,
);

Notice inside the function lexicon_alphabet_form, in the '#description' attribute don't changed to don\'t and also the $form['transliteration'] was added in the patch. If you don't see these changes inside lexicon.admin.inc then the patch was not applied correctly. If you do, then the patch did not fix your problem. Hopefully this will help you narrow down where the problem is.

EDIT:

If the patch has been applied successfully,  go into the lexicon administration page and set the transliteration rules. Looking at the patch, it looks like it added a textfield for defining the rules you want to use in the following syntax é:e,è:e,ê:e,...


Identify form control id in Drupal 7 Forms API

You can add id to your form like this,

$form['#attributes'] = array('id' => 'myid');

Also if you want to add class,

$form['#attributes']['class'][] = 'myclass';


How to create flagged nodes views that show up to colorbox using custom link

Check the "Enable Colorbox load" option in Colorbox settings.
Create a page view that lists the flagged content with path of /flagged/%
Add Contextual filter of Flags: User UID

Now in your table view:
Add User ID field, and checkmark hide from display.
Add Custom text field to view
Click here to show.


Is there a good reason to prefer one method of installing over another?

First of all, you are describing methods to download drupal, not install. If you use drush dl or drupal site:new my_site_name, this is the same as downloading the tar ball and extracting it. If you want to install drupal, you use drush si or drupal site:install, where you can provide the details for installation like database connection on the command line instead in the standard web installer.

To describe the different download methods, as mentioned drush dl and console site:new are only a shortcut for downloading the tar ball. On the other hand, if you use composer, you don't load the tar ball, but use composer to load each of the components, that are in drupal. If you plan to use only the drupal releases and want to follow the normal upgrade path, you don't need to do this. If you want to use dev versions and want to update without the need to download the whole project, use composer. Probably in combination with git for a complete dev workflow.


Tokens are just a representation of some other data structure that exists.

You can not convert an arbitrary value into a token. What you need to do is store the value and then define a token for that stored value using hook_token_info()/hook_tokens().

I understand it's a per-user value, so the simplest option seems to define a field on the user entity, I don't quite understand why you don't just show that in the profile. Then you can easily access it as a token when using the token module.


How to link a title from one view to a page of another view

You are correct.  You can use contextual filters to achieve this.  There are two parts to the solution.

The first is the views page, which you labeled xxx.com/mypage.  You will need to add a contextual filter using Content:NID.  You would then change your views page's path to uft/%.  Then, for instance, navigating to xxx.com/uft/2 in your browser would result in accessing your views page with only the information for node 2 shown.

The other half of the solution is in the block.  You will first need to add one more field to your block's fields, NID. Make sure to check the 'Exclude from display' checkbox while adding it. Once you've added NID, you'll need to rearrange the fields so NID is above title. Now you are ready to change what the Titles in your block link to.  When you click Content:Title under the Fields section you will first want to uncheck 'Link this field to the original piece of content'. Next, you should see a collapsed fieldset titled 'Rewrite Results'.  Click that to expand it. In the text box, entering uft/[nid] should complete the process.

At this point, your views block should be generating xxx.com/uft/target_nid as the link targets for the titles in the block and when you click them you should arrive at your views page with the selected nid passed as a contextual filter argument.


Composer require drupal/ packages doesn't work

Sounds like Composer doesn't know about Drupal's packages, which suggests you're missing a reference to the repository in composer.json.

Add this and you should be good to go:

"repositories": [
  {
    "type": "composer",
    "url": "https://packages.drupal.org/8"
  }
]


How do I display the submitted data in the same page?

You can use $form_state['rebuild'];

If $form_state['rebuild'] = TRUE; has been set then a new copy of the form is immediately built and sent to the browser. Instead of a redirect to new page.

Example:

function example_form_submit($form, &$form_state)
{
  // we return the submitted value to the form
  // by storing it in $form_state['storage'] and rebuilding
  $form_state['storage']['some_value'] = $form_state['values']['some_value'];
  $form_state['rebuild'] = TRUE;
}

You can refer https://www.drupal.org/node/2171993

Another way store the "$form_state['values']" in session.

Take @clive answer How to display an HTML table after the form submission on the same page as the form? as reference.


Make label translatable in Global: Custom Text field

Use hook_views_pre_view and set your global header programmatically.
E.g.

$view->set_item_option($view->current_display, 'header', 'area_text_custom', 'content', $header);


Drupal 7 main-menu - change item text if user logged in

change the sign in link to /user/login.   It will now vanish when the user logs in.   As for replacing it you would need to write some custom code


How to programmatically disallow some users to comment on some nodes?

I would hook_form_alter the comment form, and use your logic to set #access on the form.  You may need to explicitly call menu_get_item to get your node to use in the logic.

You could also use a template_preprocess_node that would perform your logic, and hide or show the comment form in the node's render array based on your logic (this assumes it is in that render array, which I am not 100% positive about).


How can I make my entity controller class fetch the fields that have been programmatically attached?

Fields are attached to instances of entities; that is the reason why field_attach_load() requires an entity ID.
Suppose you want to attach a field to a node; without knowing which node is, how do you know what value to use for the field?

DrupalEntityControllerInterface, the interface that all the entity controllers implement, doesn't define the DrupalEntityControllerInterface::create() method, but it defines the DrupalEntityControllerInterface::load() method, that is implemented by DrupalDefaultEntityController in DrupalDefaultEntityController::load(), which in turn calls DrupalDefaultEntityController::attachLoad(). The documentation for this method contains the following paragraph:

  Attaches data to entities upon loading. This will attach fields, if the entity is fieldable. It calls hook_entity_load() for modules which need to add data to all entities. It also calls hook_TYPE_load() on the loaded entities. For example hook_node_load() or hook_user_load(). If your hook_TYPE_load() expects special parameters apart from the queried entities, you can set $this->hookLoadArguments prior to calling the method. See NodeController::attachLoad() for an example.

If your entity controller extends DrupalDefaultEntityController, then the code for attaching fields to the entity instance is already implemented in that class, and you don't need to write extra code.

For the code to use when saving the entity, you can take node_save() as example. You will notice that the function contains the following code:

// Let modules modify the node before it is saved to the database.
module_invoke_all('node_presave', $node);
module_invoke_all('entity_presave', $node, 'node');

//...

// Call the node specific callback (if any). This can be
// node_invoke($node, 'insert') or
// node_invoke($node, 'update').
node_invoke($node, $op);

// Save fields.
$function = "field_attach_$op";
$function('node', $node);

module_invoke_all('node_' . $op, $node);
module_invoke_all('entity_' . $op, $node, 'node');

The code calls field_attach_insert(), or field_attach_update(); those functions are responsible for saving the fields in the appropriate database tables.

The default implementation of an entity controller doesn't have support for saving an entity; there is a third-party module that implement the support for saving entities: the Entity API module.

  The module provides API functions allowing modules to create, save, delete, view or to determine access for any entity, i.e. entity_create(), entity_save(), entity_delete(), entity_view() and entity_access().
  The entity API introduces a unique place for metadata about entity relationships and entity properties: hook_entity_property_info(). This information about entity properties contains the data type and callbacks for how to get and set the data of a property. Modules may rely on this information in order to support any entity property, e.g. Rules and the Search API build upon that.
  Furthermore the module provides data wrappers that make use of the available information to provide a simple and unified access to entities and their properties. For usage examples have a look at the README or the provided tests.
  Beside that, the module helps you defining a new entity type. For that, it provides an entity controller, which implements full CRUD functionality for your entities. Optionally, entities may be created based on classes derived from the provided Entity class.


What does it mean to "Use rendered output to group rows?"

Say you have a node with a taxonomy term, then a normal list would look like this

Title: A, Term 1
Title: B, Term 2
Title: C, Term 1
Title: D, Term 3
Title: E, Term 2
Title: F, Term 1
Title: G, Term 3

If you group them on the term, you would instead get something like this

Term 1

Title A
Title C
Title F

Term 2

Title B
Title E

Term 3

Title D
Title G

Rendered is not related to raw/safe values. It's just a way of explaining that it's the rendered (displayed) values that are used as grouping field.


Webform : how to count and live display results

I looked through the Drupal document from drupalcontrib.org and i saw that there is webform_get_submission_count function to get a count of the total number of submissions for a node. I think you can use that function instead by create a new one.


Is there a module to show photos on Drupal site that come from Facebook user profile/Facebook page, like Wordpress Fotobook

Kept this open for a while but there has been no answer so I guess not. So, another module for my to do list to write, once I am fluent in writing modules and the Facebook APIs.


When a node has multiple locations (using location cck), is it possible to filter location results in views based on only one field?

Upon further research, I have discovered that no, this is not possible.  It's just not the way location is currently implemented; if a node has multiple location fields, they are all "seen" as a single field.


How to get jquery working on Drupal 7 - for Newbies

A couple of things here:

If you can avoid entering javascript and PHP into the site via the UI it will possibly save you troubles down the line. If you have no alternatives it is ok but here are some reasons why it is not a great idea: https://drupal.stackexchange.com/a/2512/10729 (note that that is aimed at PHP, not js but most of the points still stand for js). The examples module has an example of creating custom blocks.
For attaching js, if you want it on all pages you can add it to your theme's info file. If you only want it in some places though, best to use drupal_add_js() so it is only on pages it needs to be. For attaching js behaviour to forms you can also use #attached attribute on your form items.
If you use $(document).ready(), it will fire your javascript when the page loads, however if the page is updated via ajax then your javascript will not fire again, so new markup won't be affected by whatever your javascript is. To handle these cases you should use drupal behaviors instead of document ready.

For example:

(function ($) {
  Drupal.behaviors.yourBehaviorName = {
    attach: function (context, settings) {
      // Do your thing here.
    }
  };
})(jQuery);

I recommend reading these pages:
Managing JavaScript in Drupal 7
Working with JavaScript and jQuery


node--content-type.tpl.php did not override

If you created your sub theme correctly, the sub theme is located under drupal/sites/all/themes/ and NOT in the drupal/themes folder.

So your tpl.php file needs to be in

  drupal/sites/all/themes/commons_child/templates


Use different comment template for replies-to-top-comment

I manage to solve this problem by exploiting the pid (parent ID) value in the $comment variable. First, I check if the corresponding comment is a top-level comment. It is a top level comment if the pid value is 0. The code inside comment.tpl.php so far is:

if ($comment->pid == 0) {
  // Top level comments code here
} else {
  // Replies to comments code here
}

The code above will split the template programatically already, but it will be better if I worked at two separate files for the two cases. To do this, I used drupal_get_path function to point every case inside comment.tpl.php to their corresponding template.

In my case, I create these two templates inside my theme folder:

/templates/comment/comment-top.tpl.php for the top comment
/templates/comment/comment-reply.tpl.php for the replies

The code inside comment.tpl.php then become:

if ($comment->pid == 0) {
  include drupal_get_path('theme', 'mytheme') .
    '/templates/comment/comment-top.tpl.php';
} else {
  include drupal_get_path('theme', 'mytheme') .
    '/templates/comment/comment-reply.tpl.php';
}

Of course change the mytheme in the code to your theme name.

To finish off, I pasted the template I posted above in the question to the corresponding template. It will render the template properly with all the variables you define inside the preprocesses function working.


Check this answer.

I also faced same kind of issue and I followed the below url  and its worked for me

http://codekarate.com/daily-dose-of-drupal/drupal-7-views-autocomplete-filter


Which hook to use to detect new members added to group?

this works:
function tm_mymodule_group_content_presave(Drupal\group\Entity\GroupContent $entity) {
  $group_content_type = $entity->getGroupContentType();
  if ($group_content_type->get('content_plugin') == 'group_membership') {
    $groupid = $entity->gid->getValue()[0]['target_id'];
    $userid = $entity->entity_id->getValue()[0]['target_id'];
    $group = \Drupal::entityTypeManager()->getStorage('group')->load($groupid);
    $user = \Drupal::entityTypeManager()->getStorage('user')->load($userid);
    $membership = $group->getMember($user);
    $roles = $membership->getRoles();

     // Do something
   }
}


The usual approach is to create a settings form for your module and save the content types on which you want your hook_form_alter to intervene. Then with a simple check you can implement you alterations.
The list of content types existing at a certain point in Drupal is easy to check.

I see no other way of actually placing your alters for specific content types. Even if you create your hook dynamically by using an unorthodox

foreach ($SELECTED_NODETYPES as $NODETYPE) {
  if (!function_exists("my_module_form_$NODETYPE_node_form_alter")) {
    function my_module_form_$NODETYPE_node_form_alter (&$form, &$form_state) {
        //your alterations
    }
  }
}

You will still have to have a list of nodetypes to check from, and on each new nodetype creation you have to be sure you flush the cache so your module will declare the new hooks and Drupal actually will take them into account.


How to add pagination after using hook_views_post_execute() to modify $view->result?

I eventually realized that hook_views_query_alter() was the appropriate hook, but it wasn't working because this view utilizes Search API. Turns out hook_search_api_views_query_alter() is a hook specifically for altering the query when using Search API.

I used this hook to add a condition to the view query before it is executed. This allowed me to turn pagination back on in the admin panel and have it work as anticipated.

function mymodule_search_api_views_query_alter(view &$view, SearchApiViewsQuery &$query) {
  if ($view->name === 'my_view_name') {
    // Do some stuff to get the nids I'd like to allow in my result set.
    $nids = array(1, 2, 3, 4, 5);

    // Add the condition to the existing query.
    $view->query->condition('nid', $nids, 'IN');
  }
}


How to render mini panel in custom template programatically?

Mini Panels are available as blocks. So you'd be rendering it in the same way you render any block programmatically in Drupal 7.

Use

$block = module_invoke('panels_mini', 'block_view', 'machine_name_of_mini_panel');
print $block['content'];


How to show/hide textfield according to the change in drop down using jquery?

I have done something similar using conditional fields module which is an interface for the States API or you can use States API if you are comfortable writing custom code.


How can I avoid the output of my module is cached?

As Eyal mentioned, you can pass the variables from your module to jQuery like this:

mymodule.module

function mymodule_page_attachments(array &$attachments) {
    $attachments['#attached']['library'][] = 'mymodule/auto';
    $attachments['#attached']['drupalSettings']['cool'] = 'hello world';
  }
}

mymodule.libraries.yml

auto:
  version: 1.0
  js:
    js/auto.js: {}
  dependencies:
      - core/jquery

auto.js

(function($, Drupal, drupalSettings) {

    $( document ).ready(function() {
      alert(drupalSettings.cool);
    });

})(jQuery, Drupal, drupalSettings);

This will show a js alert message saying "hello world".


One content type with several fields or several content types?

According to me,

You should only build one content type : "Product". Create the required fields according to your need.
Then, Create taxonomy terms like "Clothing, Electronics, etc." and then use entity_reference module to refer the node(i.e Product in this case).
That's it, Done.
Just create some products and go to taxonomy and add products.
For displaying products on page, You should plan to theme taxonomy pages.


it was the actual features module itself. The latest version removed foreign keys which caused the overridden to be permanent.


Limiting table rows viewed in CCK Table Field

You need to focus on node template.
Override or create a tpl of your content type e.g. node-type.tpl.php
User $node object to access all your cck fields.

Also care about $teaser and $page flags to get the state of your node.

If $teaser is true then render 5 items from $node object. If $page is true then render all your items.


Upgrading drush under Windows using self-update

If you stick to using the Pear installation method for Drush then you can just update all Pear modules (or just Drush) at will. I don't even see the selfupdate command in Drush 6.2, but it just may be hidden now.


Feeds tamper fetch data from external API

If I'm not mistaken {} indicates that it is an object and [] means that the variable is an array, therefor, I would expect $data->elements[0]->name would be the way to get the value in your return statement.

To improve your code, I would advise to use the empty() (or isset()) functions to check whether the elements in $data exists


What does Rules token "node:unchanged" mean?

Terminology

"unchanged refers to the value before something (eg, a field of entity user or node) gets updated (the old value that it used to be).

"changed refers to the value after something (eg, a field of entity user or node) gets updated (the new value that it will become).

Examples

Have a look at my answers to these question for some typical usecases of it:

Monitoring field changes in custom content type
How to implement admin verification for selected user profile fields?
How to include only an updated custom field in an email created using Rules?
How to use Rules to email users when any field(s) is changed in a node (and include the unchanged/changed values for that field)?


drupal_mail() strips all html tags from emails

drupal_mail(), by default sends a mail as plain text.

If you print out the array $message['headers'], you will get something like:

array(
    'MIME-Version' => '1.0',
    'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
    'Content-Transfer-Encoding' => '8Bit',
    'X-Mailer' => 'Drupal',
  );

As you can see, the Content-Type in the mail header is text/plain; charset=UTF-8; format=flowed; delsp=yes. You can try by modifying this header in hook_mail_alter(), you could use one of the modules which allows you to send the mail as HTML, like HTML Mail, or Mime Mail.

Edit:

Following the comments by @Ayesh and @alechko and after looking into the APIs, I found out that the headers are not the only reason for sending the mail as plain text. Because drupal_mail() internally makes a call to drupal_mail_system(), which returns an object that implements the MailSystemInterface interface. The format() method implemented by drupal_mail_system() is responsible for stripping out the HTML from the emails. So, even if the headers of the mail show the formats to be HTML, the mails would be sent as plain text only. So, I guess one could not send an HTML mail using drupal_mail(). You should look for some other alternative (module) mentioned above.


How to Auto Publish nodes based on set interval?

The Rules module is your friend. But if that's too much overhead and you don't need the flexibility, I would suggest coding it on your own.

Also see this question for executing rules on cron.


You need to 'Customize' your submit buttons via the button/link at the bottom of the form builder.


Envoking a web service method with hyperlink

You can implement hook_user_logout():

function MYMODULE_user_logout($account) {
  // Make your web service call here.
}

That hook will be invoked whenever a user logs out, which includes them clicking on any link to user/logout.


There's a module for that: Commerce Registration. You've got a registration field attached to your commerce products and you can work from them to build a solution, for a distribution that uses this for events check out COD, that might fit your needs.


Why is hook_forms form callback not reached?

Instead of:

return $forms[$form_id] = array(
            'callback' => 'driver_route_form',
            'callback arguments' => array($form_id, $args),
        );

You should have:

$forms[$form_id] = array(
            'callback' => 'driver_route_form',
            'callback arguments' => array($form_id, $args),
        );
return $forms;


No.  Your Mac is running a version of the Unix operating system.

Files and directories starting with a dot (.) in Unix are hidden system files/directories and should not be moved or deleted unless you know what you're doing.


You need to click on one of the "Place Block" buttons displayed beside all the region names, a popup with all the unused blocks appears and you select it from the list to add it.


SelectQuery::join() returns the alias created, not the query object, so it can't be chained. This should work

$query = db_select('users','u')
 ->fields('u',array('uid'))
 ->fields('r',array('rid'))
 ->condition('r.rid', '3', '=')
 ->orderBy('login', 'DESC')
 ->range(0,1);

$query->join('users_roles','r','r.uid = u.uid');
$res = $query->execute();


How to disable one sort/direction combination from a combined Better Exposed Filters field?

I can't find a way to do it through Views or Better Exposed Filters settings, but I have found a way through hook_form_alter() in the theme template.php file:

Something like this, specific array keys are based on using the BEF combine option and may vary:

function YOURTHEME_form_alter(&$form, $form_state, $form_id){
  switch ($form_id)
  case 'views_exposed_form':
    if($form['#id'] == 'views-exposed-form-VIEWID-DISPLAYID'){
      if( isset($form['sort_bef_combine']['#options']['field_FIELDNAME ASC']) ){
        $form['sort_bef_combine']['#hidden_options']['field_FIELDNAME ASC'] = $form['sort_bef_combine']['#options']['field_FIELDNAME ASC'];
        unset($form['sort_bef_combine']['#options']['field_FIELDNAME ASC']);
      }
    }
  break;
  }
}


$form['y']['image_div'] = array(
  '#prefix' => '
',
  '#suffix' => '
',
  '#markup' => theme('image', array(
    'path' => 'https://4.bp.blogspot.com/-tGbw82Gz8hA/WPR6WiOGPaI/AAAAAAAAEjk/JDPdpK3p-8wAUe2QTQbtWSdTZR_DBc-QACLcB/s640/Checkout.png',
  )),
);

And in your template file:

print drupal_render($form['y']['image_div']);

Result:


Need to override page/meta title on views page

You can use hook_metatag_metatags_view_alter

/**
 * Implements hook_metatag_metatags_view_alter().
 */
 function mymodule_metatag_metatags_view_alter(&$output, $instance, $options) {
   if (isset($_GET['some_filter']) && $_GET['some_filter'] == 'some value') {
     $output['title']['#attached']['metatag_set_preprocess_variable'][0][2] = t('New meta title');
    $output['description']['#attached']['drupal_add_html_head'][0][0]['#value'] = t('New meta description');
   }
 }


How to check if an item exists in a Queue?

The queue API doesn't have a method for this. It is very limited on purpose, as some queue systems might not be able to provide information like this.

The update module has its own wrapper to do this, by additionally storing all the task names in key value as well. See \Drupal\update\UpdateProcessor::createFetchTask:

public function createFetchTask($project) {
  if (empty($this->fetchTasks)) {
    $this->fetchTasks = $this->fetchTaskStore->getAll();
  }
  if (empty($this->fetchTasks[$project['name']])) {
    $this->fetchQueue->createItem($project);
    $this->fetchTaskStore->set($project['name'], $project);
    $this->fetchTasks[$project['name']] = REQUEST_TIME;
  }
}


Add this to the bottom of your settings.php file:

$conf['admin_menu_cache_client'] = FALSE;


Facebook for drupal throws errors on install.

Have you read the powerful README.txt file inside the module. It says you have to install the facebook-php-sdk. The instructions in the readme are pretty clear. The error is thrown because it can't find the file.


Views exposed filter, filter on multiple fields with dropdown and one textbox

If I understand correctly: you want to expose 3 dropdown filters, but allow only 1 of them for input.

You can hide or show filters by using views dependent filters: https://drupal.org/project/views_dependent_filters, but then you need a filter that sets up 3 values for showing 1 of your 3 independent filters.

But, why don't you use OR instead of AND with those filters? It would give results and you can sort it as you want.


create a new folder in /sites/default/modules
create a custom_blocks.info file inside that folder
add this content in the file:

name = Custom blocks
description = "A short description of your module"
package = My modules
files[] = custom_blocks.module
core = 7.x

create another file: custom_blocks.module (note that you've specified this in the info file)
add this PHP code:

<?php
  function custom_blocks_block_info() {
    $blocks = array();

    $blocks['unique_id_for_your_block'] = array(
      'info' => t('block info'),
      'cache' => DRUPAL_NO_CACHE,
    );

    // You can add more blocks here.

    return $blocks;
  }

  function custom_blocks_block_view($delta = '') {
    $block = array();

    switch ($delta) {
      case 'unique_id_for_your_block':

        // Put your logic here and generate the HTML you want to display in your block.
        $block['subject'] = t('block title');
        $block['content'] = 'Put here the HTML generated above';
        break;

      // Add more case statements here if you defined more than one block.

    }

    return $block;
  }

go to your module page, activate the module, go to the block configuration page and activate your new block
read more here:

Writing a Drupal 7 module
Drupal 7 Block API


The reason for this problem was that the date argument handler was crashing. I had placed the implementations of the date hooks inside mymodule.views.inc, instead of mymodule.module. Duh!


Create node with taxonomy field using services in drupal 7

Here is the Json format to create node having taxonomy filed

{"title":"my act for tax","type":"activity","field_activity_type":{"und":"termname"}}


Show fields on webform based on a value in the session

try somewhere in your webform-form-[NID].tpl.php

hide($form['submitted']['your-field-name']);
if($_SESSION['your_value'] == 'what it should be') {
   show($form['submitted']['your-field-name']);
}


Is there any danger in caching forms, such as node edit, add, etc?

Forms have unique build ids that identify a particular submission. Caching would defeat that and thus defeat Drupal's ability to detect duplicate or invalid form submissions.


The editable fields module (http://drupal.org/project/editablefields) works well with views.  So you could build a view with node title and this pub date field making the pub date editable.


How to allow authenticated user to view others data?

Found it in people/permissions
Checked the authenticated user columns for webform submissions and pages.
Now it works as it needs to.


In a custom module, you should use a custom LanguageNegotiator and assign it to your LanguageManager, using LanguageManager->setNegotiator();

1) First, you must define a CustomLanguageNegotiator, which overwrites initializeType() method. That method should return a Language object, which you can externally define using a custom setLanguageCode() method:

<?php

namespace Drupal\custom_module\Language;

/**
 * Class responsible for performing language negotiation.
 */
class CustomLanguageNegotiator extends \Drupal\language\LanguageNegotiator {

    var $languageCode = NULL;

    /**
     * {@inheritdoc}
     */
    public function initializeType($type) {
        $language = NULL;
        $method_id = static::METHOD_ID;
        $availableLanguages = $this->languageManager->getLanguages();

        if ($this->languageCode && isset($availableLanguages[$this->languageCode])) {
            $language = $availableLanguages[$this->languageCode];
        }
        else {
            // If no other language was found use the default one.
            $language = $this->languageManager->getDefaultLanguage();
        }

        return array($method_id => $language);
    }

    /**
     * @param string $languageCode
     */
    public function setLanguageCode($languageCode)
    {
        $this->languageCode = $languageCode;
    }

}

2) Define your CustomLanguageNegotiator as a service, in your custom module service file, "custom_module.services.yml":

custom_module.language_negotiator:
  class: Drupal\custom_module\Language\CustomLanguageNegotiator
  arguments: ['@language_manager', '@plugin.manager.language_negotiation_method', '@config.factory', '@settings', '@request_stack']
  calls:
    - [initLanguageManager]

3) Rebuild your cache and use your CustomLanguageNegotiator like this:

$languageManager = \Drupal::languageManager();
$customLanguageNegotiator = \Drupal::service('custom.language_negotiator');
$languageManager->setNegotiator($customLanguageNegotiator);

// Set new language by its langcode
$languageManager->reset(); // Needed to re-run language negotiation
$languageManager->getNegotiator()->setLanguageCode('fr'); // 'en', 'es', 'fr', etc

// Run any code, and its output will be displayed in french
// ...

$languageManager->reset();
$languageManager->getNegotiator()->setLanguageCode('en');

// Run any code, and its output will be displayed in english
// ...

// Do not forget to set language to its initial value
$languageManager->reset();
$languageManager->getNegotiator()->setLanguageCode('XX');


Migration is not able to find legacy database tables for some migrations

legacy_database_name.migrate_map_tdmchanneltermparent is a table typically made by the Migrate module to perform a mapping between source DB data and destination DB data. There is typically migrate_map table(s) and for instance migrate_messages table(s).

Be sure to properly Import or Rollback migrations. If you clearing the database by hand and dropping any of these tables, Migrate can get confused. Sometimes I occassionaly MySQL Truncate these tables by hand during my job workflow, but then you need to be careful and understand what migrate is doing -- how it's mapping processed data or registering migrations.

EDIT:

Then as a work around I suggest following the documentation for Map Tables heading section and explicity define the connection you want the mapping table created on. Since you have what looks like a local test migration setup and a Pantheon setup add this ... = new MigrateSQLMap( ... ); in an IF statement to point to the correct Drupal destination connection name.

  When you construct the MigrateSQLMap object, add a fourth argument to
  tell it explicitly the connection on which to create the mapping
  tables.


First of all: DON'T EDIT ANY CORE FILE! EVER!!! Simply create a sub-theme or a very simple module to add your custom stuff.

I doubt a little bit that it really is this exact file that raises that error. But if so (your theme.libraries.yml looks incomplete somehow), please try to follow the docs as close as possible and use Drupal.behaviors to add JS functionality. See JavaScript API overview.

MYMODULE/MYTHEME.libraries.yml

foobar:
  js:
    js/blogger-list.js: {}
  dependencies:
    - core/jquery
    - core/jquery.once

js/blogger-list.js

(function ($, Drupal) {
  Drupal.behaviors.myModuleBehavior = {
    attach: function (context, settings) {
      $('.YOUR-VIEW-ID-OR-WHATEVER', context).once('myCustomBehavior').each(function () {

        $(".views-col a").hover(function () {
          $(this).css('background', 'red');
        });

      });
    }
  };
})(jQuery, Drupal);

And last but not least don't forget to attach your library to a render array or your theme's info file. See Adding stylesheets (CSS) and JavaScript (JS) to a Drupal 8 theme.


How to handle with broken module installation

Before the module installation you export your site configuration with drush cex. You install your module and if it crash you import the saved configuration with drush cim.


View Revision log message with display suite

You can easily do this with help of views module. Check the screen shot

Update
Position the view block to show on node page, where view will pick the node id and show the related revision log message.


there is also a module Better exposed filters. Gives more options for the user. Maybe it is possible to do it with that module


The string "Killed" doesn't exist in the Drupal 6.30 codebase.

You might have a custom/contrib module which is responsible, or perhaps a Drush extension.

If that's the case, to find it:

grep -nr "Killed" /path/to/drupal/root
grep -nr "Killed" /path/to/drush/extension/folder

(The extension path will probably be ~/.drush)


You should consider using File admin module.

  File admin extends the File entity module to add administrative
  options to files, including published, promoted, and sticky status.

If you decide to use the module please also look at the issue queue. Although the module is stable a few extras can be had by applying a few select patches, especially Create tie in for views_bulk_operations as you are using that module.


Nearly :

$config = \Drupal::service('config.factory')->getEditable('system.site');
$config->set('name', "XXXXXXX");
$config->save();

Just have to implement hook_node_update to fit your needs.


You can create a Users view, using a module called Views. It's not exactly "content" (node) but Views can create Page displays which can be placed on the menu.


How does one concatenate fields in title field in Panels (Pages)?

You need to use replacements tokens in your "Content" configuration page, this is how is looks on my local instance:

Good luck!


Ubercart or learn a new ecommerce package?

Disclaimer I help develop commerce (commit patches) from time to time and maintain a few commerce modules, so I might be a bit biased in my opinions

I haven't done ecommerce outside of Drupal, but I have extensive experience with both (Ubercart) Drupal 6 and (Drupal commerce) Drupal 7.

Drupal commerce has a lot of great advanced both for developers and site builders.

Since it has heavy views and rules integration, it makes it very easy to configure the modules to do what you want to do. With Rules you can add a lot of custom logic like discounts. The tax support is also very good already and is very easy to customize for your location.

The only things that's missing with Drupal commerce right now is the host of modules for various stuff compared to ubercart Drupal 6. But this is not as bad as it might sound, and there are a lot of modules being created in the community around commerce.

For developers the experience developing with commerce is the best I've tried for a long time. I started when commerce was still in alpha and have had to deal with API's chaining etc. This has all stabilized now, and the result is very impressive. You can tell that commerce is built from the ground up by people who know how commerce should be made with Drupal. It's very flexible and there's no inconstancy and strange hacks like there is in ubercart. One area in particular where there is a big difference is the price handling system is very cleverly built. Commerce is built to handle multi currency unlike ubercart which I've found to be a major pain.

Conclusoin

All in all I find that commerce is more powerful out of the box using only the UI, and the code you write is in my experience generally more clean and easier to maintain. It doesn't have any legacy code, which is easy to see and it is built to take advantage of all the new Drupal 7 features.


What linux user accounts should be created prior to Drupal 7 install?

With your own user is enough.

If you want know how setup permissions check securing file permissions drupal community doc. It's referenced in this related issue.

In that specific case (setting up permissions for modules folder), it says the following:

  drwxr-x--- 32 greg-user   www-data    4096 2008-01-18 11:48 modules/

Now docs examples are for D8 but it works for D7 too.


Creating a view that shows all events and the users that have signed up for each event

Doing something like this is pushing views to it's limits. You want to pull in a lot of data and group it by the node id. I'm not sure if all this is possible through the views interface, though I believe it will be possible with the engine that's running views.

Instead of trying to achieve this rather complex view, which may become something, that's hard to modify, you could do this quite easily using more and simpler queries. Such a simple solution could look like this:

You could create a simple view, which display all the info except the signups. (Node title etc)
Signup already has a view, which will display the people that signed up for an event. With a little bit of modification, you could make it show the avatar of the users that has signed up for an event. Then you could embed this view in either a preprocess function and/or a template for the view you created in step 1.
You're done.

The ideal thing would be to create all of this in a single view, but sometimes you have to think about what the cost will be compare to the gains. I doubt you will be able measure any performance differences, unless you list hundreds if nodes with signups. But the time you save doing it this way is quite a lot.

This is the same with views itself, it's inefficient, but nothing important (for most sites) and it allows us to save lots of time, not having to code queries, theme functions etc.

Update:

Embedding a view with arguments (like node id) is pretty simple:

$html = views_embed_view($name, $display_id, $arguments)

Or in your case

$html = views_embed_view('signup_user_list', 'default', array('nid' => $nid));


Problem with text format and base64 inline images

I believe I tracked this down. With the filter formatter you mentioned, it calls Xss::filter() on the text.
Xss::filter() looks at the src attribute and will strip any protocol that have not been allowed. It sees anything XYZ: as a protocol, in this case data:.
I added - data to my docroot/sites/default/services.yml filter_protocols value and stopped the data: from being stripped.
I don't know if this opens any other security concerns or not.


Drupal View Show Webforms NOT Submitted By Logged In User

Im not sure about this question: but here you go. Go to View and to ADVANCED>RELATIONSHIP> SElect USer. After that FILTER CRITERIA and add USER as well. NEXT, create roles and work around roles and users.


How do I skip validation for node form element?

I consider that by

  How do I skip validation

you mean "make the fields not compulsory" (UI level)

If that is the case then you can use hook_form_alter and change the
['#required']
setting, for any form element, to
FALSE.

Keep in mind that hook_form_alter is a generic hook invoked by any form in your site (performance issue) alternative you may use hook_form_FORM_ID_alter to "to talk" to a specific form. Hope that helps.

If you want to make the validation on a different level, you have to write your own validation handlers (['#validate']) or override Drupal's, like node_form_validate


If I'm reading the question directly, you've copied button.func.php into your sub-theme, modified the code inside it, and then tried to see if your changes work?

If that's what you did, the problem is that Drupal never sees the code. Fortunately (if that is the problem) the solution is simple: copy the code from that file into your sub-theme's template.php file and make whatever changes are required. Be sure the function is correctly named (i.e. to override theme_button, you'd need themename + button = themename_button()). In your example above, your sub-theme would have to be named 'bootstrap_subtheme_adl_admin' in order for your function to be called even if the code is in the correct file.

Incidentally, the reason the button.func.php file works in the base Bootstrap theme appears to be the theme's registry.inc file.

Basic sub-theme how-to with Bootstrap

Download Bootstrap sub theme into /sites/all/themes; don't bother to enable the theme
Copy bootstrap_subtheme from the /sites/all/themes/bootstrap/bootstrap_subtheme to /sites/all/themes/bootstrap_subtheme
Move /sites/all/themes/bootstrap_subtheme/bootstrap_subtheme.info.starterkit to /sites/all/themes/bootstrap_subtheme/bootstrap_subtheme.info
Enable bootstrap_subtheme

Overriding a theme function implemented by a parent theme

Set up parent and subtheme as described above
Never edit the parent theme in any way
Copy the theme function you want to modify from e.g. /sites/all/themes/bootstrap/theme/system/button.func.php into the file at /sites/all/themes/bootstrap_subtheme/template.php
Change the name of the function in /sites/all/themes/bootstrap_subtheme/template.php from bootstrap_button to bootstrap_subtheme_button


Where do I find extensive taxonomy repositories?

Take a look at Open Calais (http://www.opencalais.com/) They have an extensive tagging system that is free to use. They even have a Drupal module you can use: OpenCalais. Details from its project page:

  The Calais Collection is an integration of the Thomson Reuters' Calais web service into the Drupal platform. The Calais Web Service automatically creates rich semantic metadata for the content you submit – in well under a second. Using natural language processing, machine learning and other methods, Calais analyzes your document and finds the entities within it. But, Calais goes well beyond classic entity identification and returns the facts and events hidden within your text as well. The web service is free for commercial and non-commercial use. It requires registration to obtain an API Key.

You can use such a service to find/suggest tags for your corpus of content.


How to print a taxonomy term's field value alongside a Views grouping header?

Thanks to Mario's helpful hint in the first comment, I was able to do this in the View and not in the twig template:

In the FIELDS section of the View, add "Most Common Name" as a field.
Select "Exclude from display", because I only want it in the title, not the results themselves.
(3. Select "Link to the Taxonomy term", because I want it to be a link.)
Next to "FIELDS", under the "Add" drop-down menu, choose "Rearrange".
Drag "(field_primary_taxon: Taxonomy term) Taxonomy term: Most Common Name" above "Media: Primary Taxon" > Apply
Click "Media: Primary Taxon [hidden]" field
Check "Override the output of this field with custom text"
REWRITE RESULTS > and copy the required tokens from the "REPLACEMENT PATTERNS" list, and paste into the "Text" area. I also inserted brackets outside of those tokens, so my Text area looks like this:

{{ field_primary_taxon }}
(
{{ field_most_common_name }}
)
Apply > Save > Clear all caches if necessary > Refresh the page.
Title now in my example is "Animalia (Animal)". "Animalia" and "Animal" are links to the taxonomy page.


How to programmatically set views format?

From your comments it sounds like you want to change the style_plugin from your theme.  You need to implement hook_views_default_views_alter() in your theme.

Something like this:

function themename_views_default_views_alter(&$views) {
 if (isset($views['commerce_products']) {
  $views['commerce_products']->display['default']->display_options['style_plugin'] = 'table';
 }
}

I'm not too familiar with commerce so you might not want to target the default display if that display is used elsewhere; you might just want to target the 'page' display.


Is it possible to call a custom ajax event after removing a file from a managed_file field?

I tried to do the same in D7 a while ago and I discovered a JS only solution is not possible. You need to add an ajax command to the Drupal callback.
Here's a similar question to yours. This one is about the upload button and you want the remove button.
In D7, the upload and remove button were handled by the same function and when I look at the D8 class of the managed file I also see only one callback: uploadAjaxCallback. So it might be worth checking that out.


Getting "Call to a member function getName() on null" in custom breadcrumb

You can also use hook_system_breadcrumb_alter to achieve this:
Try this:

/**
 * Implements hook_system_breadcrumb_alter().
 */
function MyModule_system_breadcrumb_alter(\Drupal\Core\Breadcrumb\Breadcrumb &$breadcrumb, \Drupal\Core\Routing\RouteMatchInterface $route_match, array $context) {
  $node = \Drupal::request()->attributes->get('node');
  if ($node && $node instanceof Drupal\node\Entity\Node) {
    if ($node->bundle() == 'article') {
      // Add Articles item.
      $breadcrumb->addLink(Link::createFromRoute(t('Articles'), '<none>'));
      // Add category term item to breadcrumb.
      // Change here the field_tags with your taxonomy you want to add to breadcrumb.
      $term_id = $node->field_tags->getValue()[0]['target_id'];
      $term = Term::load($term_id);
      $breadcrumb->addLink(Link::createFromRoute($term->getName(), 'entity.taxonomy_term.canonical', ['taxonomy_term' => $term->id()]));
      // Add title as breadcrumb item.
      $request = \Drupal::request();
      $route_match = \Drupal::routeMatch();
      $page_title = \Drupal::service('title_resolver')
        ->getTitle($request, $route_match->getRouteObject());
      if (!empty($page_title)) {
        $breadcrumb->addLink(Link::createFromRoute($page_title, '<none>'));
      }
    }
  }
}

Update: To fix the error.
Update the applies method to apply your breadcrumb only on articles as it mentioned in @Jdrupal answer:

  public function applies(RouteMatchInterface $route_match) {
    $parameters = $route_match->getParameters()->all();
    if (isset($parameters['node'])) {
      return $parameters['node']->getType() === 'article';
    }
    if (isset($parameters['term'])) {
      return TRUE;
    }
  }

The error comes from the line:

$term = $route_match->getParameter('taxonomy_term');

$term equal NULL its normal, you are in node page so the taxonomy_term param always null, so try to get your term from the node object something like:

 $node = \Drupal::request()->attributes->get('node');
 // Change the field_tags with your filed.
 $term_id = $node->field_tags->getValue()[0]['target_id'];
 $term = Term::load($term_id);


How to add a Related Products View for Commerce Kickstart?

If you want to be able to reference nodes, your view must be taxonomy-based and utilise product categories. The category must be on the display node, not on the product and this is a good starting-point to understanding what's required. To see if this idea is relevant to your use-case, go here: http://www.bookfish.co.za/catalogue/gorongosa-joao-augusto-silva  Bear in mind that I'm not using Commerce Kickstart but various Commerce modules on that site but it should work with CK.

To display my products, I added the following relationships & what I selected there to get it to work I have put in square brackets [ ]:

Content: product [required]
(Products referenced by field_product)Commerce Product: Referencing Content [required]
(Content referencing products from field_product) Content: Taxonomy terms on node [required, select the vocabulary you want, identifier: term]
(term)Taxonomy term: Content using Category [required, identifier: field_category]
(field_category) Content: Category (field_category) [required, relationship: field_category, identifier: term from field_category]
Content: product [required, relationship: field_category, products referenced by field_product]

for contextual filters:

(field_category) Content: Nid [Relationship: field_category,

When the filter value is NOT available:

select "provide default value",

"type": Taxonomy term ID from URL

select  "Load default filter from node page, that's good for related taxonomy blocks" and "Limit terms by vocabulary"

select your relevant category

"Multiple-value handling" select "Filter to items that share all terms" or whatever is relevant to your use case

under "More" select "Exclude"]

Aggregation settings: [Group results together]

Content: Nid [Relationship: do not use a relationship,

When the filter value is NOT available:

select "provide default value",

"type": Content ID from URL

When the filter value IS available or a default is provided:

select "Specify validation criteria"

Validator: "Content"

Content types: select the relevant product display

Filter value format: "Node ID"]

Aggregation settings: [Group results together]

I then selected a view format of fields showing title, image, price and hidden fields of "add to cart form" and "stock" so that I could filter to relevant products that are in stock. For aggregation, I used "Group results together" and "entity ID"


I think you are making a little mistake that confuses you.

TVI does not allow to define a view for the vocabulary itself so the path www.example.com/[vocabulary name] cannot be handled by the module. The vocabulary settings are the default ones for all terms within the vocabulary. These settings can be overriden for each term and can be inherited with the latest version. If you want a specific view for your entire vocabulary, you will have to create it by yourself because no vocabulary page exists by default in Drupal.

If I get your problem described in this post and on drupal.org (https://drupal.org/node/2066015) I can suggest you the following :

Define view1 as a page display and give it the path related to your vocabulary's name
Define view2, view3 dans view4 using any path of your choice, it does not matter as TVI will call them directly
Define view2 as the vocabulary's default view
Define view3 and view4 as term's specific settings if needed

When trying to show a term page, TVI will do the following :

If the term has TVI settings, use it
Else find its first parent having a TVI setting with the "override" option and use it
If no parent is found, use the vocabulary's TVI settings

If I take your drupal.org sample you will have :

Terms

Vocabulary (view2)
T 1 (no settings)
    T 1.1 (view 3, not inheritable)
        T 1.1.1 (no settings)
    T 1.2 (view 4, inheritable)
        T 1.2.1 (no settings)
    T 1.3 (no settings)
T 2 (no settings)

Results

T 1 (view 2 from vocabulary)
    T 1.1 (view 3 from itself)
        T 1.1.1 (view 2 from vocabulary)
    T 1.2 (view 4 from itself)
        T 1.2.1 (view 4 from T 1.2)
    T 1.3 (view 2 from vocabulary)
T 2 (view 2 from vocabulary)

I hope this will help you to achieve what you want to do.


If you want to keep the video stored somewhere else and you don't need to consider the video as a managed Drupal file, then you could just migrate the 'video url' to a text field or a custom field type.

Depending on how you would like to output the video to your visitors you could create your own field formatter. And use the stored 'video url' as a source for your video player.


If you're looking for a pct fee on top of your order, you've got a couple of options, the quick and dirty one is to create a fake tax of the percentage you want, see http://www.drupalcommerce.org/user-guide/tax-configuration, another option is to multiply the amount by 0.15 or whatever quantity on the rules event you choose.

For fixed fees you can check Commerce Fees

You've got also commerce discount and commerce coupon that do the exact opposite operation, so you can check how to add and modify stuff in the checkout, if you're looking for a more advanced solution.


First of all. Are ... and ... the same?

Assuming your entity type class doesn't override Entity::load to do something different, yes they are the same. If you look at that method you can see it uses exactly the same op:

public static function load($id) {
  $entity_type_repository = \Drupal::service('entity_type.repository');
  $entity_type_manager = \Drupal::entityTypeManager();
  $storage = $entity_type_manager
    ->getStorage($entity_type_repository
    ->getEntityTypeFromClass(get_called_class()));
  return $storage
    ->load($id);
}

So Entity::load is simply a shortcut to loading the entity via the manager service.

  When I talk directly to the class's load function also?

They're identical operations, so yes, they share the same caching.


How to display node teaser in Display Suite custom field?

I did this by adding a preprocess field which then becomes available in DS.

<?php
      function MYTHEME_preprocess_node(&$variables) {
        // Get the summary as a discrete field.
        $body = array_pop(field_get_items('node', $variables['node'], 'body'));
        $variables['node_summary'] = $body['safe_summary'];
      }

Then in display suite add a preprocess field named node_summary.


To identify:

Install the Devel module
Visit admin/config/development/devel, enable the "Display query log" option.
At the bottom of every page you'll see a log of the queries run for the page, and what module and function has been responsible for invoking them. Run time of each query is also listed so you can see where the problems are.

As for stopping them, that will depend entirely on the individual query; whether you need it, whether the bottleneck is simply a matter of weight of data, poorly designed tables (contrib or custom, core tables are fine), not enough system resources, bad caching strategy, and so on. You'll need to profile that in the context of your web server for it to make any sense, there's no recipe for it.


Root term in Pathauto only works for child terms?

I encountered the same problem and wrote the patch for token module
Here is patch https://drupal.org/node/2050421#comment-7806099


Multiple shopping cart view in cart page

Try https://www.drupal.org/project/commerce_responsive_ui as a starting point. This module uses different displays (no tables) for the cart and checkout views.


How to send a newsletter to all email addresses attached to a content type?

Unfortunately, it doesn't look like Newsletter supports that.

On the other hand, the Simplenews module has decent Rules support which may make managing your subscribers easier. As far as I know a user account isn't required to subscribe.

Off the top of my head, here is an example of a rule that might automatically add an email address to a subscription list when a new 'Customer' node is created:

IF
  (condition) 'After saving new content' (node is created)
AND
  (condition) 'Entity is of type' (node is 'Customer' type)
AND
  (condition) 'Entity has field' (node has 'email' field)
THEN
  (action)  'Set a data value' (get value of email field)
THEN
  (action)  'Subscribe an e-mail address to a newsletter'

(The full implementation is beyond the scope of this answer but there are plenty of other posts dealing with Rules.)

As for importing email addresses, in both of the 7.x branches there is a "mass subscribe" option at People > Subscriptions.


The Math Field module defines a new field type to dynamically calculate values on entity forms. This is an alternative to Computed Field
that does not require the use of PHP Filter.

Note: the above info is an excerpt from its project page.


A node reference is empty, although the multilingual support is enabled, and the node is translated

Have a look at this.

http://www.ostraining.com/blog/drupal/multi-lingual-drupal/


Drupal 7 Draggable Views in different order when logged in

This can be resolved by following this link:-
http://drupal.org/node/616658

Scroll to the bottom, and follow instructions in the last Post whereby you install the Rule module, create a rule to clear cache on sorting a View, you may have a problem where the option to create custom PHP is not in the drop down list, if so, this is resolved by enabling the 'PHP Filter' module.

All tested and works perfectly ! :)


How can I overwrite existing menu tree manipulators?

I was unable to find a way to alter tree manipulators of an existing menu.
But it is possible if you render menu, let's say in a custom block.

Create your own tree manipulator service.

Copied from core.services.yml:

  menu.default_tree_manipulators:
    class: Drupal\Core\Menu\DefaultMenuLinkTreeManipulators
    arguments: ['@access_manager', '@current_user', '@entity_type.manager']

you can define your service in a similar way:

  mymodule.my_custom_tree_manipulators:
    class: Drupal\mymodule\MyCustomMenuLinkTreeManipulators
    arguments: ['@access_manager', '@current_user', '@entity_type.manager']

Then create MyCustomMenuLinkTreeManipulators class that extends DefaultMenuLinkTreeManipulators, define custom method, let's say checkAccessIgnoreStatus() and implement logic you need.

There are many ways to use it, I'd create a new block plugin for that.
Refer to my answer for details on how to render menu with manipulators.

Use your manipulators:

$manipulators = array(
        array('callable' => 'mymodule.my_custom_tree_manipulators:checkAccessIgnoreStatus'),
        // ...
      );


how to add parameters to html email template

you can use the yourtheme_preprocess_htmlmail() function for htmlmail email template in put in the template.php file of your current theme. I will give an example.

function yourtheme_preprocess_htmlmail(&$variables) {
  switch($variables['key']){
    case 'password-reset':
     $variables['var1'] = t('SAMPLE TEXT');
     break;
    case 'register-no-approval-required':
     $variables['var1'] = t('SAMPLE TEXT');
     break;
    break;
   }
   $variables['heading'] = t('Heading text');
   $variables['copyright'] = t('Copyright text.');
 }

In this example. I created some customized variables base on the mailkey and defined some others like heading, copyright


How to create menu and submenu using taxonomy collection in drupal commerce kickstart?

There is module Taxonomy Menu. You should use this module.


There is no native support for this in VBO, due to the way that Taxonomy has now been moved into the fields API. There is an outstanding task that is being worked on to bring Taxonomy actions back into VBO.

In the meantime, you can try this patch against VBO 7.x-3.0-beta2, kindly posted by erik2e.


View with paged output - how to alter number of pages?

I did it:

function MYMODULE_views_pre_execute(&$view) {
  if ($view->name == 'taxonomy_term') {
    if (user_access('view all pages')) {
      $view->query->pager->options['total_pages'] = NULL;
      $query = $view->build_info['query'];
      $offset = $view->query->pager->current_page * $view->query->limit;
      $query->range($offset, $view->query->limit);
    }
  }
}


How to not display redundant information in table Views?

You can try Views Field View module.

Create a "secondary" view of Field2 contextualy filtered by
relationship with EntityA.
In your main view, use Field1 and new Views Field of your "secondary" view (this field type is added by module).
Set up that new Views Field in your view to pass proper argument to "secondary" view contextual filter (and therefore show relevant Field2s related to EntityA)


How to use a separate file for IE responsive.css for version 10/11 in Drupal

I suggest customising a pre-built theme template that has already taken care of that such as Zen or Omega.


Integrating the Webform module in a page

You can achieve this goal using Entityforms module.Using this module you can take input of text as well as image like webform. This module can be integrated with rules and data export etc. for sending mail and downloding submission as like webform.

There are a lot of advantage over webform but it is different form webform.

For more info go through module documentation.


How to manage by cron a long-running queue of very many items

The problem with using queue for an operation like this is that you have to fill up the queue frequently.

Queue makes sense if you have something that is e.g. user or somehow else triggered one by one (or a few at a time), added to the queue and then processed in background. For something like your use case, you want to process tens of thousands of entries, it is a lot of overhead to add them to the queue first and then process them again.

Instead, a simple approach would be to keep track of the file ID. process the first 100 files, sorted by fid, ascending. store the last file ID in state, then on the next run get the next 100 files, where fid is bigger then the last processed fid. If you reach the end (identified based on having processed less than 100 files, you reset the fid back to 0 (possibly combined with some kind of timestamp, so you only start again after N seconds passed since you started the last time). 100 could be configurable, so users can process fewer or more files per run, depending on whether they have them local or not.

Keep in mind that by default, there is only one cron process, if you're running for a long time, it will block everything else. Ultimate Cron could help there, also with running your cron job more frequently than others. It supports multiple threads, but I honestly don't know how well that works already in 8.x (And I am the 8.x maintainer of that module ;)).

You could also always expose it as a drush command, then it would be easy to do it as a completely separate, standalone cron process.


Field is not removed from 'field_config_instance'

If you've got a fair amount of data, you'll need to allow cron to run a few times, or else do a larger batch purge

field_purge_batch(10)

Will only delete 10 records.

  $batch_size: The maximum number of field data records to purge before
  returning.


How do I use field_view_field() to print a user profile picture?

Try this

Meet the author

  <?php print drupal_render(field_view_field('user', $user, 'picture', array('settings' => array('image_style' => 'user-pic-style'))));?>


The following four fields would be easily possible for making "timeslot" products:

Start - date field, single date (not a range)You want a single date field because views will be more straightforward when not dealing with ranges on one field. It's much easier to do two fields and have two filters than it is to have one field with a range filter (date supports both use cases).
End - date field, single date (not a range)
Timeslot - Product title would be easiest OR taxonomy reference The taxonomy route would allow you to make the timeslots fieldable and help you connect products of the same timeslot (if it is helpful to have all 9am - 10am products in a single list).
Stock - You could use commerce_stock to create a single stock availability OR you could just disable the product on checkout.

So, the simplest route would only include a "start" and "end" date field with the product title being the "timeslot" and using the "status" of products as a simple "single availability" flag.

Hope that helps!


Generate a cookie when user closes a webform block

First you need to create a custom module and add javascript user identificator on your page with web form(to find out user anonymous or not)
Here is example

Next use jquery library and do the next thing:

// its just an example you need to put your #id or .class
$("#subform_close").on('click', function() {
      if(Drupal.settings.user_js_uid == 0)
           {
              // set cookie for whatever you want
              $.cookie("dont_show_web_form", 1, { expires : 1 });
          }
})

and in your php code
check for that cookie

$_COOKIE["dont_show_web_form"]

and hide your webform.


no search_api_solr results when search term ends with number

I would try this.

Go into The solr server configuration - assuming it's named 'solr'
/admin/config/search/search-api/server/solr/edit

In Advanced, see if "Targeted content domain" is set to scientific. And see the description next to it to see why I'm thinking this might be your issue.

Save. You'll probably need to re-export your config zips and definitely need to clear and re-index.


Well if I understand you right...

In template.php

function mytheme_preprocess_page(&$variables) {
  $node = menu_get_object('node');

  if (isset($node) {
    $variables['node_type'] = $node->type;
  }
}

In page.tpl.php

<?php if ($node_type == 'your_type') : ?>
  // something here for node type your_type
<?php endif; ?>

Additionally, you can simply add new template suggestions.

In template.php

function mytheme_preprocess_page(&$variables) {
  $node = menu_get_object('node');

  if (isset($node)) {
    $variables['node_type'] = $node->type;
    $variables['theme_hook_suggestions'][] = 'page__node__' . $node->type;
  }
}

After clearing your cache, you can create page--node--(node_type).tpl.php and put page specific markup for that node type there.


You can do the same with xmlsitemap modules

Enable XML sitemap node, XML sitemap taxonomy submodules.

After that you will get these options.


Your question is equivalent to asking if you can edit a file before doing a git pull.  The answer is yes, but if there are conflicts, then you will need to merge them.

Returning to your example, if there are no changes to your local configuration, then the files that drush fu will write will be the same as the files currently in the repository.  In this instance, git will happily do the pull, as it will consider the files to be unchanged, even if drush fu rewrote them.

If you do have changes (git status after drush fu will show this), then it would be a good idea to run git stash prior to git pull.  After you pull, git stash pop will overlay your stashed changes on top of the pull, and you can see what the conflicts are.

Disclaimer:  I have never hand-merged conflicts from features.  I always pull the database from live to dev, and push code from dev to live to avoid this.


The first steps when dealing with translations, particularly with user entered strings like Views Tabs labels, is to clear the cache and visit the page showing the string in question but make sure you visit in a language other than English!

The visit to that page with the interface in another language will trigger Drupal to refresh the Translate Interface list, and you should be able to find the new string when doing a search there (admin/config/regional/translate/translate).

Remember that the Translate Interface search is case sensitive! You have to enter "My Articles" and not "my articles" or any other case style.

If that search still isn't giving you any results, it may be you're missing a module that enables those strings to be included in translations. Make sure you have "String translation" or perhaps even "Variable translation" enabled.

If you've just enabled "String translation", similar to above, visit the page in another language then search for the string in Translate interface.


You can create a computed field in Venue with the content of the fields you want and use that field.
& 3.  Once you have the node reference you can show whatever fields you want using a template for the gig. Alternatively you could use a view.


Remove search form from search results page

Write a form alter:

function module_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == "search_form") {
     $form['#type'] = 'hidden';
  }
}


How do I see the names of all view fields in the formatter option form?

A little late, but maybe still helpful for someone.
You can use $fields = $this->displayHandler->getFieldLabels(TRUE); to get an array of all currently chosen fields in the view.


From this comment:

  in D7 history is a field on the user entity

  goto admin/config/people/accounts/display set the format of the
  history field to 'hidden'


Bizarre Behavior with Markdown Filter and Cache Clearing

I fixed the problem. I don't know why it acted the way it did, but it started working after I deleted the markdown folder in sites/all/modules, and re-installed using the "official" /admin/modules page (which is SSL enabled).


How do I attach an existing file to a node?

A few things..

You should avoid raw sql queries against entity tables, they are managed and it is not guaranteed that the structure will always break. Use entity queries and then load the entities using Node::loadMultiple() for example, or $storage->loadMultiple().

A few lines of your existing code are not necessary. the size is calculated, language() is a getter that has no arguments, it is automatically new.

To set the uid, you can use setOwner($user) or setOwnerId($uid), and there are corresponding getter methods on the node objects, so once you load them, you can just set it from the node with $file->setOwner($node->getOwner())

However, that seems to be a completely different question than what you have in the title. That just syncs the owner (which is not that important, not for public files at least). It doesn't do anything to connect them to the node. To get the usage tracking, you can rely on what Drupal does by default if you include the UUID as an data attribute. I don't remember the exact name right now, just manually add an image with CKEditor and you'll see it in the source code. If that's there then Drupal does it for you automatically.


This functionality is already provided by Drupal core. Just edit the settings for your image field in content type and enable 'Enable Title field' to have Title field for your image field.

For example,
Go to 'Structure » Content types » Article' and 'Edit' the settings for 'Image' field. (admin/structure/types/manage/article/fields/field_image)

There you will see two checkbox fields 'Enable Alt field' and 'Enable Title field' which can be enabled to provide image related info for each image upload.


Try to change drupal_goto with $_GET['destination'], e.g.:

function submission_user_login(&$edit, $account) {

   // Redirect user to to desired location.
   $_GET['destination'] = 'node/add/page';
}

Hope this will work.


Can I use hook form alter to add an attribute to a webform field?

You have to do something like this:

function addonchange_form_alter(&$form, &$form_state, $form_id){
  // target a single form
  if($form_id == "webform_client_form_22"){
    $form['submitted']['company']['#attributes']['onchange'] = 'changevalue';
  }
}


How do I allow date-time filtering on my custom entity's ISO date field

After checking your module provided for me on github and some reverse-engineering  I find out the problem is on create('datetime') and you should use create('created') So the following code

$fields['date'] = BaseFieldDefinition::create('created')
  ->setLabel(t('DateTime'))
  ->setDescription(t('Date and time.'))
  ->setDisplayOptions('view', array(
    'label' => 'above',
    'type' => 'timestamp',
    'weight' => -4,
  ))
  ->setDisplayOptions('form', array(
    'type' => 'datetime_timestamp',
    'weight' => -4,
  ))
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE);

Results the below image for me. it seems it's Ok now.


I got a possibly easier solution. you need to have entity_browser and entity_browser_block required as dependencies and installed in your module. Then in your BlockBase buildForm or LayoutDefault buildConfigurationForm you can do something like what they do in the entity_browser_block module in the EntityBrowserBlock.php
// make sure you have this at the top of your file
use Drupal\entity_browser_block\Plugin\Block\EntityBrowserBlock;

// blockForm or buildConfigurationForm
$test = EntityBrowserBlock::loadEntitiesByIDs(explode(' ',$configuration['selection']['entity_browser']['entity_ids']));
$form['selection'] = [
  '#type' => 'container',
  '#attributes' => ['id' => 'entity-browser-block-form'],
];
$form['selection']['entity_browser'] = [
  '#type' => 'entity_browser',
  '#entity_browser' => 'classes',
  '#process' => [
    [
      '\Drupal\entity_browser\Element\EntityBrowserElement',
      'processEntityBrowser',
    ],
    ['\Drupal\entity_browser_block\Plugin\Block\EntityBrowserBlock', 'processEntityBrowser'],
  ],
  '#default_value' => $test,
];

$order_class = 'entity-browser-block-delta-order';

$form['selection']['table'] = [
  '#type' => 'table',
  '#header' => [
    $this->t('Title'),
    $this->t('Operations'),
  ],
  '#empty' => $this->t('No entities yet'),
  '#tabledrag' => [
    [
      'action' => 'order',
      'relationship' => 'sibling',
      'group' => $order_class,
    ],
  ],
  '#process' => [
    ['\Drupal\entity_browser_block\Plugin\Block\EntityBrowserBlock', 'processTable'],
  ],
  '#default_view_modes' => 'default',
];


Allign block content next to title - CSS

Okay, so after looking at your demo, there's a couple things you can do.

The easiest method is to simply float #block-block-16 right, float .page-header left, set #block-system-main to clear: both, and be done with it.

But that's not great because we are kinda circumventing div.region.region-content by doing that. It'd be better if the header and the buttons actually shared a common parent. That seems to be what you truly want to do here. We can accomplish that with some JavaScript. That will also help with the minor problem the first solution introduces of having your gray underline not stretch across the page.

$(function() {

  $('#block-block-16').insertAfter($('h1.page-header'));
  $('#block-block-16, h1.page-header').wrapAll('

');

});

From here, again we'll just float the buttons right and the page header left as before.

We can also take care of some details and clearfix the new div (included in the JS) and perhaps change our bottom border from being set on the h1 to being set on our new div, so that it stretches across the page, below the header and buttons.

You may also choose to remove the 9px padding-bottom on the h1 and instead change that to a 9px padding-top on div.region.region-content.

Hope that helps!


What's a good access module for a state-level organization?

You should look at the Organic Groups module. This will allow you to designate individual users as responsible for the each group, and will allow each chapter to post content to their own chapter (kind of a mini web page for each chapter).

You can see an example of this format here.


How do I send data using JSON as output format?

You will need to write a custom module that will select data from the webform tables in the database, encode your response and then call the URL

$crmurl = 'http://www.crmdomain.com/api/datafromdrupal';

if (isset($response)) {
  $json_response = drupal_json_encode($response); /* Pure json encoding */

  $options = array(
             'method' => 'POST',
             'data' => $json_response,
             'timeout' => 15,
             'headers' => array('Content-Type' => 'application/x-www-form-
             urlencoded'),);
  $result = drupal_http_request($crmurl, $options);
}


Drupaliest way to remove login and registration page descriptions

you write a hook for user login form alter, then you can set the #description to null. you need something like this:

function YOURMODULE_user_login_form_alter(&$form, &$form_state) {
    $form['name']['#description'] = '';
}


Can I automatically regenerate all images after using Drush image-flush?

I usually see people using wget or httrack for this - request every page in your site, and all of the images will be regenerated. Not very sophisticated, I know.  As far as I know, though, there is no Drush command to do this.


I don't see any current bugs like this in the issue queue of the module. So let's check the following:

What's up with the theme you're using? Have you tried this with another theme?
What performance settings do you use? (Is Javascript aggregation enabled? Do you use page caching?)
Is the Analytics code missing from the output when you're logged in as user 1? (If it's there, what's happened with the permissions of the module?)


Two separate Panels everywhere variants, one with a selection rule "User is anonymous", the other with "User is authenticated", could accomplish this.


There aren't any other ways, as the hooks that the modules need to implement to validate a node are hook_validate() (if the module implements a content type) and hook_nodeapi('validate') (for all the other modules). Those hooks get a $form parameter, and are supposed to call form_set_error() in the case there is a validation error.

The easier way to find if there are errors set for a form is to use form_get_errors(), which returns the array with all the errors set with form_set_error(), the function that is also called from form_error().

In the case more than one node is validated, you would need to call form_set_error(NULL, '', TRUE) before node_validate(), and then get from form_get_errors() the array containing the error messages; if this is empty, there are no error messages.

form_set_error(NULL, '', TRUE);

// node_validate() call.

$errors = form_get_errors();

if (!empty($errors)) {
  // Some module reported an error.
}

Alternatively, you can use the following snippet to verify no module reported an error, after you call node_validate():

if (!empty($_SESSION['messages']['error'])) {
  // Some module reported an error.
}

Before calling node_validate() from the cron task, you would need to set $_SESSION['messages']['error'] to an empty array; in that way, you are sure the errors reported in the array are caused by the node validation hooks.

$_SESSION['messages'] is the variable used from drupal_set_message() to store the messages passed to the function.

function drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE) {
  if ($message) {
    if (!isset($_SESSION['messages'])) {
      $_SESSION['messages'] = array();
    }

    if (!isset($_SESSION['messages'][$type])) {
      $_SESSION['messages'][$type] = array();
    }
    // …
  }
  // …
}


How can I preserve nids during a migration?

This is actually easy to do. In the prepare() function of the node migration class, just set the nid and is_new to true:

public function prepare($node, $row) {
  // Preserve old nid so that old links to nodes using /node/nid still work
  $node->is_new = TRUE;
  $node->nid = $row->nid;
}


AJAX button on table rows to delete rows

I found the answer using drupal_render(). The buttons are now generated in each row, havin their own ids, so that I can read the triggering element in the callback function.
Now I only have the problem whe I click one of the buttons, the complete form is submitted. There seems to be no ajax callback. I will search further an will the edit the answer...

  foreach (aPersons as $key => $value) {
    $form_button['button'] = array(
      '#id' => 'del_'.$key,
      '#type' => 'button',
      '#value' => 'Delete',
      '#ajax' => array(
        'callback' => 'delete_person_ajax_callback',
      )
    );
    $deleteButton = drupal_render($form_button['button']);
    $row = array($value['dname'],$deleteButton);
    $aPersonsTable[]=$row;
  }


Where does the query table "taxonomy_term_data_node" come from?

taxonomy_term_data_node is the alias used for the SELECT that is part of the first LEFT JOIN.

LEFT JOIN (
  SELECT td.*, tn.nid AS nid
    FROM {taxonomy_term_data} td
    LEFT JOIN {taxonomy_vocabulary} tv ON td.vid = tv.vid
    LEFT JOIN {taxonomy_index} tn ON tn.tid = td.tid
    WHERE  (tv.machine_name IN ('category_child')
  )
) taxonomy_term_data_node ON node.nid = taxonomy_term_data_node.nid


Batch processing possible without redirects?

Redirects work just fine if your infrastructure is set up correctly.  I will assume your issue is that you have a mount point for your public files directory - but not for your temp directory?
If you don't want to make two mount points (three, if you have a private folder), instead have one and just have three folders inside for tmp/ public/ private - then symlink tmp and public (e.g. tmp to /tmp/drupal).
The reason being is that file processes create temporary files which then can't be used by other instances if they're not shared.  The external page cache isn't a factor here as it doesn't care so much about any of this, and I'm going to assume that this is for authenticated users too - so it's actually being bypassed (further assuming it's set up correctly). The load balancer cares even less, it just bounces you between instances unless you're using sticky sessions.  Every instance should have access to the same database, files and cache - there won't be any problem.


How do I know if a link has the "active" class?

In some cases, the active state is not set by design due potential problems with caching. This behavior is documented in this change record.

  Setting the active class is now an opt-in feature:

  l() and LinkGenerator::generate() now have a set_active_class option that defaults to FALSE
  theme_links() now accepts a set_active_class key that defaults to FALSE
  Those links that you'd expect to get the active class set, do get it: menu links, language switching links …

  The output of l(), LinkGenerator::generate() and theme_links() no longer contains the active class, even if you do opt in. Instead, they get a data-drupal-link-system-path attribute, and if there's a GET query, they also get a data-drupal-link-query attribute…

In those cases, where it is not set on server side, you can take a look at core/misc/active-link.js to get an idea how to manipulate the active state on client side.


Show a block on a certain URL with wildcard

If the page is not a node (is a landing page, view, panel etc) you can use the function arg

if(arg(0) != "audio" && arg(1) != "track") {
  print "

";
}

Or if is a node you can make the conditional using a taxonomy or using the node type.

if(arg(0) == "node" && is_numeric(arg(1)) && $node->type != "your-node-type" ){
  print "

";
}


Field available only when a value from a Hierarchical Select is chosen

I created a module that implemented the node_validate function and from the values selected determined if child taxonomies existed when the form was submitted. If they did then obviously the user had not made a selection from the second drop down list.
This is the code I wrote.
function mp_admin_node_validate($node, $form, &$form_state) {
    if ($form["#form_id"]=="jobs_node_form") {
        $loc = taxonomy_get_children( $node->field_tax_regions[und][0][tid]);
        if ((count($loc)>0) && ($loc)) {
            form_set_error("field_tax_regions", t('Location region is required.'));
        }
    }
}


CKeditor stripping allowed style attribute

Your problem comes from the "Limit allowed HTML tags" option. According to this post (for Drupal 7, but the same logic applies on D8), setting this option triggers XSS filter in order to remove dangerous tags.

As for Drupal 8, it uses the core Filter module and calls filterXss() method in \Drupal\editor\EditorXssFilter\Standard class. First line of this method is:

$dangerous_tags = ['script', 'style', 'link', 'embed', 'object'];

Hence, your style tag will always be removed with the "Limit allowed HTML tags" option set.

If you really wish to use inline style, you have to either:

unset the "Limit allowed HTML tags" option (which I do not recommend depending on the kind of users you give access to "Basic HTML" text format)
or use "Full HTML" text format

Best solution would be to rely on classes and styling in CSS stylesheets and inline styling should be used sparingly.

Hope this helps.


Ouput yes/no in commerce product table if product image available/not available

Simply add your image field. When you add it, or if you click on it if you already added it, you will see something similar to the following date field screenshot.

Click on rewrite results and put "Yes" here.
Click on no results behavior and put "No" here.

  Is there a way to solve this in a similar way if you have a default
  image set - if none is uploaded a default image shows up?

In this scenario you would have to use Image URL Formatter and set the view image field formatter to display url.

Then you would simply perform a conditional check to see if the URL is equal to the default image url either using Views template file & custom code OR alternatively using Views Conditional for a zero coding solution.


Why do Chinese auto path URLs become something else?

The process you are describing in your question is called transliteration.
The reason for what you see happening in your site, might be because you're using the Transliteration module. Here is a quote from its project page:

Provides one-way string transliteration (romanization) and cleans file names during upload by replacing unwanted characters.
Generally spoken, it takes Unicode text and tries to represent it in US-ASCII characters (universally displayable, unaccented characters) by attempting to transliterate the pronunciation expressed by the text in some other writing system to Roman letters.

Here is a sample of what this module does for "file names":

However, it can also be used to transforms an URL like mydomain.com/последние-новости-в-Украине-и-мире in something like mydomain/poslednie-novosti-v-Ukraine-i-mire. To do so, you also need to enable the Pathauto module. After that, go to the Pathauto setting page and check "Transliterate prior to creating alias". For more details on that, refer to "D7 Pathauto transliteration". Attention: this does not "fix" already created aliases (those need to be deleted and recreated).
Note: There is also a transliteration tag on drupal.SE (with only 4 questions using it though ...).


Configuring Drupal for Upstream Deployment

This might be just a shorthand difference, but the include is looking for /drupal-7.15/ but you mention /drupal-7/ earlier in the post. Do you have two different versions of Drupal installed somehow, or is this all deployed from the same duplicate codebase and you're just trying to switch directories depending on the env?