How can a site programmatically detect if cron has not run in a long time?

What is a safe and performant way for the site to periodically check
  if the 'cron_last' variable is too old, that doesn't rely on cron?

As said before by @Clive, you a script running periodically to do this check for you. Having said so, the simplest way is to create a basic module that checks the last time Drupal Cron ran succesfuly and acts based on that. You could include a drush command so you can call it via a server cronjob. E.g.

Check if cron hasn't run in X minutes and send e-mail if so, using  Drush

1) Create a file named cronwatch.drush.inc

2) Create the drush command that you will invoke via a crontab / automated task in your server. For instance, you would be running drush cronwatch every X minutes.

/**
 * Implements hook_drush_command().
 */
function cronwatch_drush_command() {
  $items = array();
  $items['cronwatch'] = array(
    'description' => dt('Check last time Drupal cron ran and send an email if necessary.'),
  );
  return $items;
}

3) Add a function to check if Drupal Cron hasn't run in longer than X minutes, send an alert email.

/**
 * Callback function for drush cronwatch command.
 */
function drush_cronwatch() {
  // Minutes since the last time cron run.
  $last_cron = variable_get('cron_last', 0);
  $minutes_ago = (time() - $last_cron) / 60;

  // How many minutes to allow without having run the cron.
  // This number should be larger than the frecuency of Drupal cron. E.g. If
  // Drupal cron is set to run every 60m, this number could be 70.
  $tolerance = 70;

  // If the cron last ran longer than tolerance minutes ago, it means that it
  // probably failed.
  if ($minutes_ago >= $tolerance) {
    $to = 'you@example.com';  // E-mail to get the alerts
    $message = t('Drupal cron could not run successfuly. Last succesful run was !minutes minutes ago.', array('!minutes' => floor($minutes_ago)));
    drush_mail_send_email($to, 'Drupal Cron failed', $message);
  }
}

4) Finally, this is the function to send an e-mail via drush:

/**
 * Send an e-mail to a specified e-mail address from within Drush.
 * @see http://drupal.org/files/mail.drush_.inc__0.txt
 */
function drush_mail_send_email($to, $subject = '', $body = '') {
  // Define $from and headers
  if (!$from = drush_get_option('from')) {
    // E-mail to send the alerts from. Replace here if desired.
    $from = ini_get('sendmail_from');
  }
  $headers = array();
  $headers['From'] = $headers['Sender'] = $headers['Return-Path'] = $headers['Errors-To'] = $from;

  // D7 implementation of drupal_mail
  if (function_exists('drupal_mail_system')) {
    // Prepare the message.
    $message = drupal_mail('drush', 'key', $to, NULL, array(), $from, FALSE);

    $message['subject'] = $subject;
    $message['body'] = array();
    $message['body'][] = $body;
    $message['headers'] = $headers;

    // Retrieve the responsible implementation for this message.
    $system = drupal_mail_system('drush', 'key');
    // Format the message body.
    $message = $system->format($message);
    // Send e-mail.
    $message['result'] = $system->mail($message);
    $result = $message['result'];

    // D6 implementation of drupal_mail_send
  }
  else {
    $message = array(
      'to' => $to,
      'subject' => $subject,
      'body' => $body,
      'headers' => $headers,
    );
    $result = drupal_mail_send($message);
  }

  // Return result.
  if ($result) {
    drush_log(dt('E-mail message sent to !to', array('!to' => $to)), 'ok');
  }
  else {
    drush_set_error('DRUSH_MAIL_ERROR', dt('An error occurred while sending the e-mail message.'));
    watchdog('cronwatch', 'An error occurred while sending the e-mail message with Drush.', array(), WATCHDOG_ERROR);
  }
}

And there you go. If Drupal Cron is set to run -let's say- every 60 min, and for some reason failed, the next time this script is executed, it will send you an alert e-mail and you can act based on that.

---- EDIT: Added code to check without depending on Drush / Server Cronjobs ----

Check if cron hasn't run in X minutes and send e-mail if so (no Drush / Server cronjobs)

You could also run the checks without Drush nor server cronjobs. For this, you will necessarily need to hook your checks to a certain event in your website (e.g. every page load).

In your cronwatch.module file:

1) In this case, we check on every page load, that is almost guaranteed to run periodically. However, you can use any other hook to trigger your checks.

Let's find out when the Drupal cron check was last executed.

/**
 * Implements hook_page_alter().
 *
 * Finds out when was the last time Drupal cron check was executed. If it's
 * been longer than the desired frequency, proceeds with a new check.
 *
 * We depend on page loads in order to emulate a 'periodically running' event,
 * as an alternative to a server cronjob / scheduled task.
 */
function cronwatch_page_alter() {
  // Defines how often we want to run the checks (in minutes).
  // We need this flag variable, since we don't want to make a check on
  // every single page load.
  $frequency = 60;

  // Only proceed if it's been longer than 60 minutes since the last check.
  $last_check = variable_get('cronwatch_last_check_timestamp', 0);
  $minutes_ago = (REQUEST_TIME - $last_check) / 60;

  if ($minutes_ago < $frequency) {
    return;
  }

  // More than 60 min have passed since the last check. So, let's proceed with
  // a new check.
  if (cronwatch_check()) {
    // Check was succesful. Now update the 'last check timestamp' variable so
    // the next check runs an hour from now.
    variable_set('cronwatch_last_check_timestamp', REQUEST_TIME);
  }
}

2) Make the actual check for the last time Drupal cron ran. If more than X minutes have passed, send an email.

/**
 * Checks the last time Drupal cron ran, and acts based on that.
 */
function cronwatch_check() {
  // Minutes since the last time cron run.
  $last_cron = variable_get('cron_last', 0);
  $minutes_ago = (time() - $last_cron) / 60;

  // How many minutes to allow without having run the cron.
  // This number should be larger than the frecuency of Drupal cron. E.g. If
  // Drupal cron is set to run every 60m, this number could be 70.
  $tolerance = 70;

  // If the cron last ran longer than tolerance minutes ago, it means that it
  // probably failed.
  if ($minutes_ago >= $tolerance) {
    $to = 'you@example.com';  // E-mail to get the alerts
    $message = t('Drupal cron could not run successfuly. Last succesful run was !minutes minutes ago.', array('!minutes' => floor($minutes_ago)));
    $mail_sent = cronwatch_mail_send_email($to, t('Drupal Cron failed'), $message);

    if ($mail_sent) {
      return TRUE;
    }
  }
  return FALSE;
}

3) Function to send an e-mail

/**
 * Sends an e-mail from the cronwatch module.
 */
function cronwatch_mail_send_email($to, $subject, $body) {
  // Let's get the mail ready to be sent.
  $module = 'cronwatch';
  $key = 'alert_mail';
  $from = variable_get('site_mail', ini_get('sendmail_from'));
  $language = language_default();

  // Build the mail, but don't send it yet.
  $message = drupal_mail($module, $key, $to, $language, array(), $from, FALSE);

  // Prepare the message.
  $message['subject'] = $subject;
  $message['body'][] = $body;

  // Retrieve the responsible implementation for this message.
  $system = drupal_mail_system($module, $key);

  // Format the message body.
  $message = $system->format($message);

  // Send e-mail (Drupal will log any error).
  $message['result'] = $system->mail($message);

  return $message['result'];
}

Only drawback is you depend on page loads, so accuracy would be affected by a website with very few or no visits (in that case, do you even need this?). And, of course, this code could be refactored, but this should do the trick.


Because there is no link content so there is nothing to click on.

A link should be of the form

Link content

In that example there would be the text "Link content" that you could click on.

For your code I would expect it should be something like this:

Pledge RM10.00 or more

For more information see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a

To modify the pledge markup do no modify the crowd funding module. For more information on why it's a good idea not to hack modules see Why don't we hack core?

The correct way is to override the template that prints the markup.

In this case crowdfunding-reward-options-node-view.tpl.php is the relevant template file.

So copy that template file from the tpl directory of the crowdfunding module and put it in your theme. Then clear the drupal cache and the site will start using the template file in your theme instead of the one in the module.
Then modify the markup of the template that you put in your theme to suit your needs.


Multi-page wizard webform that posts to external URL?

It would appear that this needs to be done using a Remote Post handler (which can be added at site.com/admin/structure/webform/manage/form_id/handlers) instead of selecting the custom POST setting, as described at https://www.drupal.org/project/webform/issues/2961835


This solved my question: https://www.lullabot.com/articles/extending-a-field-type-in-drupal-8

It is an example of how to extend the reference field and also associate a quantity with the reference. It was what I was looking for.


Pre-Populate Dropdown in WebForm from link

hook_form_alter() or hook_form_form_id_alter() is what you're looking for here.

First your link how ever it's constructed should have a query parameter kind of like "/webformurl?product=a". This would be a link back to your webform.

In one of the hook form alters, you'd check for the value in the url if it doesn't exist do nothing. If it does change the default value for the form field.

If you're not sure how to alter the field on your form maybe check out this link for additional details - Programmatically modifying a webform with hook_form_alter()


You may use views template files. If your view name is gallery and it's machine name is block_0 then in your theme folder create a file and name it views-view-fields--gallery--block-0.tpl.php.

There are two fields in the content type, an image with the machine name field_image and a text that is address of some where else with the machine name field_link.

In the views-view-fields--gallery--block-0.tpl.php file the following variables are available

1. $fields['field_image']->content;
2. $fields['field_link']->content;

To create a slideshow like this

with a string on it you can easily use html tags and css absolute positions to set the string on the image. Anyway you can display it in any way you want. Don't forget to clear the cache.


You can use below code , PropertyCondition accepts range values using BETWEEN operator.. Since timestamp is stored as int in database node table created column with data and time together below code works to fetch records of a particular date..

<?php
$day_start = strtotime(date('Y-m-d 00:00:00', $created_ts));
$day_end = strtotime(date('Y-m-d 23:59:59', $created_ts));
$query
    ->propertyCondition('created', array($day_start, $day_end), 'BETWEEN');
?>

Find more about propertyCondition in D.O


Tagging people on blog entries and being able to access their profiles from tags

You can achieve that using the Mentions module

  The Mentions module offers Twitter like functionality, recording all references to a user's username - using the [@username] or [@#uid] filter format - from various locations, providing a centralized page to track all mentions (via the Views module).

This module provides a configuration page, through that you can define the mentions pattern, and path (supports tokens)


The reason why the widget for an Integer field is a text field is that the form element used from a browser is a text field. This means the browser is always returning text for an integer field.

This should not be a problem, since:

When you add an Integer field to an entity, the field value is validated to be an integer; an input containing characters that are not digits (e.g. 2A, Q3, 2.0) is not accepted, and the users get an error message requiring them to enter only numbers for that field.
PHP generally accepts a string containing only digits instead of an integer without to report errors. If you execute the following code, you would get 15 as result. (It requires the Devel module.)

$a = "3";
$b = "6";
$c = "2";

dpm($a + $b * $c);

You would get the same result if $a is set to "3A".


How to deal with someone trying to login as admin?

These kinds of probes are very common across the internet. There are a few things you can potentially do to block this problem and reduce the success of an attacker.

First, I recommend everyone use Two Factor Authentication so that even if the attacker guesses your username and password they still can't login. There was a bounty for $500 to break TFA and although the white-hat attackers had username and password they couldn't break in.

The security review module or Droptor can help monitor these failed logins. If they happen a lot then you need to start taking more actions. Brute force attacks on passwords only work if someone does them a lot so if it just happens a few dozen times I wouldn't worry.

You can track the IP address in use by this person using watchdog entries and then use the built-in D6 Access Rules (or the d7 equivalent - http://drupal.org/project/user_restrictions ) to block access via that IP. You could also deny access to the IP in Apache or some other server level firewall. The firewall/webserver is a more efficient place to block the users in terms of load on the server, but it usually requires a bit more effort.

For Drupal 6 and 7, AjitS has provided an answer with a good description of how to use a rate-limiting feature to prevent repeated login attempts from the same IP.


How to get Node Title and description when nid is avaiable?

You can easily load the node using $node = node_load($nid);

Hoever it can be a bit tricky to get the values you want, so I recommend Entity metadata wrappers. They are part of the Entity API module and they allow you to access node variables like this:

$node = node_load($nid);
$node_wrapper = entity_metadata_wrapper('node', $node);
$node_wrapper->title->value();
$node_wrapper->field_description->value();

At the bottom of the linked Entity metadata wrapper page is a section on Debugging or introspecting wrappers, you can use that to find all available fields and their names.


Is there an easy way to update img src attributes when moving to a new server?

What you are looking for is the Pathologic module.

  Pathologic is an input filter which can correct paths in links and
  images in your Drupal content in situations which would otherwise
  cause them to “break;” for example, if the URL of the site changes, or
  the content was moved to a different server.

Cheers,


db_set_active() is used for connecting to another database. The other database does not need to be Drupal at all.

Just don't forget to switch back to default DB when you are done. If you don't, Drupal will try to perform all subsequent queries in the other database, which will result in a lot of errors and potentially mess up the data in the other database.

Here's example code:

// Connect to your other database.
db_set_active('your_other_db');
// Run any queries you want.
db_query("...");
// Switch back to the default database of your installation.
db_set_active();

You can read more about db_set_active() here.

Another note, per Neograph734's reminder: the argument you would pass to the db_set_active() needs to be the same key you used for adding another DB access info in settings.php file.

Here's an example:

$databases = array (
  'default' => array (
    'default' => array (
      'database' => 'your_default_database',
      'username' => 'username',
      'password' => 'password',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
  'your_other_db' => array (
    'default' => array (
      'database' => 'your_other_database',
      'username' => 'username',
      'password' => 'password',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);


How to alter the $item value in taxonomy_field_is_empty without altering core taxonomy module?

Altering taxonomy_field_is_empty's behavior is, by definition, altering core, so the answer is no. Hacking core shouldn't be done (unless there's a clear what & why you're doing the hacking).

With that said, you should follow back on your original problem:

  I tried adding a custom hook in my module for hook_field_is_empty but it did not execute the hook at all ,even I tried adding -1 weight so it executes before taxonomy_field_is_empty (taxonomy module has weight 0) but still it did not help

The problem is, for some reason, your module's hook_field_is_empty implementation isn't firing so you'll need to troubleshoot that problem.

Look at other module implementations of the hook to see what those are doing that your module isn't and throw debug statements into module_invoke_all to see if your module's hook is even recognized by core.


After lots of searching finally, I got the solution.
I would like to share this.

AjaxController.php

namespace Drupal\ajax\Controller;

use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\JsonResponse;

class AjaxController extends ControllerBase {

  public function call_ajax($controller,$function){
    $args = func_get_args();
    $r = array();
    $r['html'] = null;

    $class = "\\Drupal\\".$controller."\\Controller\\".ucfirst($controller)."Controller";

    $obj = new $class();

    if(method_exists($obj,$function)){
      $r['html'] = render($obj->$function());
    }
    return new JsonResponse($r);
  }

}

ajax.routing.yml

ajax.call:
  path: '/call/ajax/{controller}/{function}'
  defaults:
    _controller: '\Drupal\ajax\Controller\AjaxController::call_ajax'
    _title: 'Get List'
  methods:  [GET]
  requirements:
    _permission: 'access content'

ajax.js

jQuery(document).ready(function($a){
    $a.ajax({
        url: "call/ajax/users/getList",
        method :'GET',
        dataType: "json",
        success: function(result){
          $a(".region-content").html(result.html);
        }
    });
})

Now I have to just pass the controller and function name to call the function using ajax.

The main purpose to use this way is reusability of controller functions.


Features : export content types with FieldCollection

There are two solution to this problem, the first one is a bug in the module that can be fixed via this patch https://drupal.org/node/1084268

The second solution fixes a problem caused by orphan fields in field_collection_item table.
First try removing my_field via drupal interface, if it didn't exists try
 searching your my_field in this table, if it existed , delete it

NOTE : the solution is dirty one, it worked for but it may have side effects, backup your database before trying it


How to display user picture programmatically in a rule (User Relationships)

Try something like this, just for grins. Make sure you're actually returning the URI, and maybe provide an alternative image if they don't have one for themselves. Also, your link might be messed up.

I'm not entirely sure how you're getting that URI for the profile image.

$imgpath = $requestee->picture[und][0]['uid']->uri; // Maybe? I would think the URI is in the picture array.
$vars = array(
  'style_name' => 'thumbnail',
  'path' => $imgpath,
  'attributes' => array(
    'class' => array('RequesteesPicture'),
  ),
);
$image = theme_image_style($vars);
$link = l($image, "user/" . $requestee->uid, array('html' => TRUE));
print $link;


How to fix drush php configuration on the hosting?

I had to use --php-options parameter. The working command looks like this:

/opt/php/bin/php -c /home/pisar/etc/php.ini -d memory_limit=128M
                    /home/pisar/opt/drush.php --php=/opt/php/bin/php
                    --php-options="-c /home/pisar/etc/php.ini
                    -d memory_limit=128M" upc -y drupal


The Modal Form Module supports modal window for webform, you can also use shadowbox module which creates a modal window for anything.


Placing header element inside list element

Not that I know of without a theme function or a view display template.  However one option without any code would be to create two separate blocks views.

The first view, limit the displayed items to whatever your want, three for example. Clone the first view, but set the offset to three, and also limit it.  Add the header to this view. Then plunk them down as you normally would with view blocks.

EDIT:  What it would like like to add a new template file.

As an example, if you are using the unformatted list output, you would need to find the theme suggestion for that particular view.  Example below.

Then as you can see it is currently using views-view-unformatted.tpl.php

So use that file as a base, it is located in:sites/<all|default|siteurl>/modules/views/theme/views-view-unformatted.tpl.php

It currently contains this code below

<?php

/**
 * @file
 * Default simple view template to display a list of rows.
 *
 * @ingroup views_templates
 */
?>
<?php if (!empty($title)): ?>

<?php print $title; ?>

<?php endif; ?>
<?php foreach ($rows as $id => $row): ?>
  <div<?php if ($classes_array[$id]) { print ' class="' . $classes_array[$id] .'"';  } ?>>
    <?php print $row; ?>

<?php endforeach; ?>

So you need to copy this file into your theme templates folder, rename it, and edit it.

You're going to want to create a count variable, and then when the count reaches the right number, print the title you want like so

<?php

/**
 * @file
 * Default simple view template to display a list of rows.
 *
 * @ingroup views_templates
 */
?>
<?php if (!empty($title)): ?>

<?php print $title; ?>

<?php endif; ?>
<?php $count = 1; ?>
<?php foreach ($rows as $id => $row): ?>
  <?php if ($count == 3) print "
" . t('Header') . "
"; ?>
  <div<?php if ($classes_array[$id]) { print ' class="' . $classes_array[$id] .'"';  } ?>>
    <?php print $row; ?>

  <?php $count++; ?>
<?php endforeach; ?>

That will print a H1 header after the third row.


That depends on a lot of factors: hardware, configuration of your LAMP stack, ...

The only real way to test this is to benchmark it yourself, on your hardware, under your circumstances.

There's no real answer to this question.


Using date and rules to publish and unpublish content

Create a new node of a certain content type using rules

Use rules action "Create entity" to create a node, whereas "node" is a type of entity.

For the fields that you want to provide some value for (as part of your rules action), make sure to add a Rules conditions - "Entity has field" (with the field corresponding to each such field). Doing so will ensure they are available in the Rules action (to set a value for it).

Repeat the creation of such new node

Use the rules scheduler as explained in the video about "Repeating scheduled events". The "clue" here is:

as the last action of your rule, you reschedule the same rule to be executed again after +13 days from today on. Or maybe execute the rule again "weekly" (as per your details in "2.").
the very first time (today + 13 days) you need to trigger the execution of this rule manually (from the rules UI). Since there doesn't seem to be any event in your question that you can use to trigger this rule.

Video tutorials

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

PS: Your question seems to contain 2 questions, of which "1." is not clear to me (something about creating a view?). After you enhance your question (as suggested by Shawn also), I might enhance my answer also.


Commerce Search API with Custom Search Form

You should use the same faceted search block on front page too. You can invoke the faceted search block on front page.


Keep something in cache even after flushing the cache from the Drupal back-end (not drush)

For this use case, you might need to consider another storage instead of cache.

warmer -> cache

warmer -> storage -> cache

storage could be either key value or entity or any other storage you prefer.Check here if you are not sure which one to pick.

This way, your warmed data always persistent in the system and can be purged only by warmer (crontab).

When cache clear happen, you can always fallback to storage.


First, try to provide $block['subject']. Second,  omit status in hook_block_info implementation, it may cause problems when there is no region assigned.


Title Patterns was printed in exactly its self

I think you should use [current-page:title] instead of  [current-page:page-title]

Run cron manually and clear the performance cache. If it doesn't help then
Reload the same version of the Token module. If you use drush, command is:

drush dl token-[version]


page--front.tpl.php being ignore in favour of page--node--page.tpl.php

If you need to have a custom theme for nodes, try to do this using THEME_preprocess_node as follow

function THEME_preprocess_node(&$variables){
     $node = $variables['node'];
     if($node->type == "SOME_CONTENT_TYPE")
          $variables['theme_hook_suggestions'][]='page__node__SOMETHING';
}

Then create page--node--SOMETHING.tpl.php in your theme folder. To get the values of the fields you can use the entity module and do something like the following code (I supposed field_something is machine name of one of your fields):

function THEME_preprocess_node(&$variables){
     $node = $variables['node'];
     if($node->type == "ANY_CONTENT_TYPE"){
        $variables['theme_hook_suggestions'][]='page__node__SOMETHING';
        $wrapper = entity_metadata_wrapper('node',$variables['node']);
        $variables['title'] = $wrapper->title->value();
        $variables['something'] = $wrapper->field_something->value();
     }
}

By this code $title and $something variables are available in  page--node--SOMETHING.tpl.php file.


Looking around, it would appear that users with the Administer Content permissions can do what you want to accomplish. However, this permission has the following warning: Give to trusted roles only; this permission has security implications. Promote, change ownership, edit revisions, and perform other tasks across all content types. If this is a limited permission that you want to give and to trusted users only (as suggested by the warning provided by Drupal), you should be fine.

However, if you want many (possibly untrusted) users to be able to do this, the best suggestion I have at the moment is to add a field to the node itself asking the user if they want it to be published or not and to write a hook  that checks the value of that field and publishes it based on that information. There are many variations of this - you can make the field appear only for certain roles, etc.

Edit: Another option you have, instead of writing a hook, is to use the Workflow module. You can set various access permissions from within the module itself to replicate published/unpublished behavior (i.e. make it so that only the author can see nodes published under a certain workflow state). This is probably a better option in the long run since these can be saved in configuration. I'm sure there are other benefits as well.


Removing the email validation requirement

That setting is part of core Drupal.

Go to admin/user/settings, and under 'User Registration Settings' set 'Public registrations' to 'Visitors can create accounts and no administrator approval is required'. Also untick the 'Require e-mail verification when a visitor creates an account' checkbox and you should be good to go.

Once you've done that it might be worth re-checking your Login Toboggan settings just to make sure there's nothing interfering with your new settings.


Well, actually it's not too late to implement if you do the following:

1) Add a following count (integer) field as a user field.

2) Go to /user/1/edit and put any number other than 1, inside of this field. (this is just a temporary place holder).

3) With PHPMyAdmin or a DB viewer program, export the following count field as a CSV file.

4) The 1 is where the USER ID goes, and the other random number is the actual following count.

So with views, create a view that shows the user ID and the following flag count number.

Then you open the exported .csv file on Excel and paste these data in the proper columns.

5) Import back into your Drupal DB and clear flush cache.

*Note: Instead of doing steps 3, 4 and 5, you could just do this with Views Bulk Operations + Rules.

6) Using the Rules module, create a rule that +1's the user following count field, when a user flags the follow flag and -1's it when they unfollow.

7) In views, in your List of Users View, for Filter, simply add the following count field and put less than 5.

8) Use the Field Permissions module to hide the following count field, that way when they edit their profile, the user cannot insert/modify the number.


You can use metatag module to adjust metatags like these.

After installing you can visit the settings page /admin/config/search/metatag and there is a specific set of metatags to adjust for front page.  Edit those settings and adjust canonical but I believe by default it sets this to [site:url] which should be OK.

Alternatively or if you don't want to install a module just for this you can do it using hook_preprocess_html in your THEMENAME.theme

function THEMENAME_preprocess_html(&$variables) {
  //if not front page do nothing
  if(! \Drupal::service('path.matcher')->isFrontPage())
    return ;

  //unset if set
  foreach ($variables['page']['#attached']['html_head'] as $key => &$value) {
    if ($value[0]['#tag'] == 'link' && $value[0]['#attributes']['rel'] == 'canonical') {
      unset($variables['page']['#attached']['html_head'][$key]);
      break;
    }
  }

  //add canonical
  $canonical = [
    '#type' => 'html_tag',
    '#tag' => 'link',
    '#attributes' => [
      'rel' => 'canonical',
      'href' => '/',
    ],
  ];
  $variables['page']['#attached']['html_head'][] = [$canonical, 'canonical'];
}


Module for extracting information from remote site?

I think that Feeds XPath Parser and Example Web Scraper could be a guidance to your needs.


How to replace "default" with website domain name during drush user-login

You can use option --url:

  -l <http://example.com:8888>,             URI of the drupal site to use (only needed in multisite environments or when running on an alternate port).
   --uri=<http://example.com:8888>

$  drush uli -l yoursite.dev

Or create a record in your aliases.drushrc.php file:

$aliases['yoursite-dev'] = array(
  'root' => '/vhosts/yoursite.dev',
  'uri' => 'yoursite.dev',
);

Now you have an alias @yoursite-dev and can use it:

$ drush use @yoursite-dev
$ drush uli

Update:

Now I prefer to create sites/default/drushrc.php file for each Drupal folder:

<?php
$options['l'] = 'http://yoursite.dev';
$options['r'] = '/vhosts/yoursite.dev';

More info about drushrc.php: https://github.com/drush-ops/drush/blob/master/examples/example.drushrc.php


Webform confirmation message on same reloaded page

Once you've set up  your webform you have the option to set up how the form responds after asubmission has been made. On the your Webform's Setting page...:

If you click the 'Customize Confirmation' checkbox you can - "Configure your website's actions when a user submits a response to this webform."

  Select from the following form submit options in the menu:

  Show standard confirmation page - Displays a confirmation page that contains the information you enter in the Page body field.
  Redirect to a different page - Redirects users to the page in the Path field. You can also display a confirmation message by selecting the Show a confirmation message check box, and then entering information in the Page body field.
  Stay on the same page - Users stay on the webform page. You can also display a confirmation message by selecting the Show a confirmation message check box, and then entering information in the Page body field.

You probably want to select the third option...


Can't get Jcarousel to work, followed the instructions

I have installed Jcarousel module and it works. The directory in the libraries folder is like this

and it works. I downloaded the module's library from

  https://github.com/jsor/jcarousel

and Those files are under dist and src directory


Set a token as the default value of a new field

What information do you try to get??

In one of my Content Type, I need to retrieve the node ID. I found that the token for the current node ID is this:

[current-page:url:args:last]

Tested and working for me!!


Add commas between allowed file extensions

You are definitely allowed to separate file types by comma in the admin are

For user area, find the ID of the form (you can find this in the firebug) then

function YourTheme_form_alter(&$form, &$form_state, $form_id){
      if($form_id == "TheFormID"){
            kpr($form);
      }
}

In this way you can find the form elements. get the Key of image field in the form array, if it is image then write

function YourTheme_form_alter(&$form, &$form_state, $form_id){
      if($form_id == "TheFormID"){
            $form['image']['#description'] = t('File types are comma separated')
      }
}

This is the general idea but a few modification might be needed


Various "Undefined" notices on content admin screen

Try this, check to make sure it's set first:

<?php if (isset($field_twithandle[0]['value'])): ?>
<a href="http://twitter.com/<?php print $field_twithandle[0]['value']; ?>" class="twitter-follow-button" data-show-count="false" data-show-screen-name="false">Follow @<?php print $field_twithandle[0]['value']; ?>
<?php endif; ?>

The problem is that those values aren't set on some pages, which is why you're getting the error. So that's a fix for an undefined index error. You also have things like undefined variable, for which a fix could be like:

<?php if (isset($messages)): ?>
  /* Do stuff here with $messages */
<?php endif; ?>


Why the main theme isn't applied in the preview?

There are lots of reasons why the main theme isn't applied. I think this comment by merlinofchaos sums up some of the larger hurdles well:

Right now, in Drupal, we store temporary data in a cache by caching the generated form. In order to preview, we have to process that form and reassemble data. This is fine when you click preview, but in a system like this, you're actually visiting a different URL from the form.
Logically, we could put the form build id in the URL and load the form and process it, but there are several weaknesses with that:

It is wasteful (processing a form that was not submitted)
Form build IDs are sha generated strings. There is no way to reproduce it if you don't have it. This means you can't do content locking.
It continues the trend on Drupal of the form owning the data when the form typically should only be a representation of the data.

Read More »
Lot's of contrib modules have attempted to address these issues:

Site Preview System
Page Preview

That said, "Allow to preview content in an actual live environment" recently made it into Drupal 8 Core
But don't get too excited. "Allow content creators to preview exactly how content will appear on the site after it's saved" is still very much a work in progress. And recent comments indicate it will be a Drupal 9, not 8 issue.


views showing only 1 node with specifiec field value

Views is a simple query builder. It is good at building 1 query, or many simple queries. There are times when relying solely on Views, and the assumption that your logic and be easily tailored to Views may fail.

This is such an example where it would benefit you to do some of this work outside of Views itself and store and compute metdata on to more easily generate reports.

For example you could install Nodequeue, Views Bulk Operations and Rules to perform the following tasks:

create a nodequeue for city_fastest_times_results. Create 1 nodequeue per city.
Write a Rule that upon saving of a track time examines if it is the fastest time yet recorded for that city. If so, insert it into the appropriate nodequeue.
Using VBO to reuse the rule you defined in 2 to run this processing on any previously entered data on the website.

note: a SmartQueue may be able to allow you to encode this logic as well, as opposed to Rules.

Instead of Nodequeue you could also use the Relation module to relate cities, runners and times.

So, the nodequeues can store the fastest times per city and self-update based on Rule logic, or occassionaly by an admin using a VBO form. To show a report you would then just have SELECT * FROM {nodequeue_N} ORDER BY time DESC, which is trivial using Views.


I can recommend you Menu Link Weight together with Client-side hierarchical select. The combination of those two modules allow you to separate each level in an own select field and makes sorting pages within a level very handy.

After installing both of them visit /admin/config/user-interface/menu-link-weight and select "Client-Side hierarchical select".

This solution works very well for a site where we use a lot of levels and menu items.


Content From Another Page Displaying on Current Page

I think we might need a bit more detail to answer your question.

Is training really a content type or a view?  Normally content is displayed inside a view unless your are viewing the actual node page.  If you are really talking about a view that you could just add a content type filter.

Also, what version of drupal are you using?  My above response assumes 7.


You could try the cache warmer module, which apparently does just that.

There are also a bunch of blog posts on the topic around the web.


Views - adding relationship adds duplicate row for each relation

Do this:

Add relationships:
1. Commerce Order: Referenced line items
2. Commerce Line item: Referenced products

In Other set Set Aggregation to Yes

Include fields:
1. Commerce Line Item: Line item ID, set aggregation to COUNT and tick Exclude from display
2. Commerce Product: SKU, set aggregation to COUNT and tick Exclude from display.

Add a Filter criteria:
1. Commerce Product: SKU. Expose it to the visitor to your liking, and leave aggregation type to Group results together.

Now you will have only one row returned with no duplicates and you can filter SKU


Gift Certificates for Ubercart 3 & Drupal 7

There's an effort going on to port UC Gift Certificate to Drupal 7: link to issue


How to access the view display's field list in row plugin options

i found $this->display->handler->get_field_labels(); in views_plugin_style.inc and it seems to do the trick.


How to create several -lists in one display with Views?

As far as I know you need two views, one for the first list and another for the second. You can "embed" the first view in the Header of the second view using the Views Field View module.
Views Field View:

This module allows you to embed a view as a field in a view. A new field handler is made available, so this can also be used in area (header/footer/empty) handlers as well as rows.
This view handler can accept arguments from fields of the parent view using tokens and pass them into the child view for each row. Raw or rendered token values can be used, as well as static values.
It's highly recommended to use this module in conjunction with views caching.
Views Content cache and Cache Actions are good ways of caching views.


How to use hook_field_preprocess to add a prefix/suffix to an entity reference field for different view modes?

If you have configured the reference field to render the referenced entities then the build array usually contains #cache keys, which result in a separate cache entry for this render array including anything you've attached to it in preprocess. This has nothing to do with the view mode of the parent entity, the cached result will also be reused when the media is displayed in a different entity.
You could split up the field content in multiple render elements so that you have the prefix/suffix outside of the cached element content:
$variables['items'][0]['content'] = [
  'prefix' => ['#markup' => $prefix],
  'content' => $variables['items'][0]['content'],
  'suffix' => ['#markup' => $suffix],
];


Edit "Read more" and "Add new comment" links in teaser

You can do this in a couple of different ways. By looking up the Drupal\node\NodeViewBuilder::renderLinks method, you can see how it works.

1. Implement hook_node_links_alter()

This should work for a module.

function mymodule_node_links_alter(array &$links, NodeInterface $entity, array &$context) {
  $links['node']['#links']['node-readmore']['#attributes']['class'][] = 'btn btn-primary';
}

2. Implement template_preprocess_links()

And I think this should work for the theme...

function mytheme_preprocess_links(&$variables) {
  // some logic enclosing this block
  $variables['node']['#links']['node-readmore']['#attributes']['class'][] = 'btn btn-primary';
}


There's no conventional way of doing this as far as I'm aware but if you want to do this it can probably be achieved with some processing in your theme.

function THEME_preprocess_page(&$variables) {

  // DO SOMETHING WITH request_uri() or similar

  if (isset($SOME_VARIABLE)) {
     $variables['theme_hook_suggestions'][] = "page__comments";
  }
}

Then create a copy of your page template as page--comments.tpl.php and take out what you dont need.

This is nasty though and not the 'Drupal' way of doing things.


hide a DIV on node edit form, but display on node creation

Whene you go to node create page, the body tag has class "page-node-add", but on edit node page - "page-node-edit".
So you can add CSS code:

.page-node-edit #your_div_id {display: none;}


If you go to admin/user/user, you can block the user, which will cause them to be logged out.  After that, if you want them to be able to login again, you can just immediately unblock them.  Also, if you as an admin change a user's password, they will be logged out and will have to use this new password to log back in.

If you want to get fancy, you could do something like this in a custom module as well:

function YOURMODULE_user_operations($form_state = array()) {

  $operations = array(
    'logout' => array(
      'label' => t('Logout the selected users'),
      'callback' => 'YOURMODULE_user_operations_logout',
    ),
  );

  return $operations;

}

function YOURMODULE_user_operations_logout($accounts) {
  foreach ($accounts as $uid) {
    sess_destroy_uid($uid);
  }
}

which would add a "Logout the selected users" option to that menu as well.


Restrict "add more" button to add new fieldset after adding 5 fieldsets

This can be achieved using css. First of all write hook_form_alter() on your custom module. and your code should be like this..

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'your_form_id') {
    if (isset($form['your_field']['und']['#max_delta']) && $form['your_field']['und']['#max_delta'] == 4) {
      $form['your_field']['und']['add_more']['#prefix'] = '';
      $form['your_field']['und']['add_more']['#suffix'] = '';
    }
  }
}

Where $form['your_field'] is your field collection field machine name. You can write your custom css on #prefix and #suffix and set it to display none.


How to add the configuration changes from a website to another website?

There was a discussion in the Drush issue queue on allowing config-import to force the adoption of the UUIDs in the imported configuration to be inserted into the database.  The problem with allowing this is that this operation is equivalent to deleting all of your configuration (e.g. all of your content types) and then re-creating them, which has the side-effect of deleting all of the data associated with that configuration (e.g. all of the pages in your site).  It was thought that erasing a site entirely was too surprising of a side-effect for a config-import operation, even with a --force flag, so this use case will not be supported.

The current thinking is that the right time to force the UUIDs of a site to change would be at site-install time.  At the moment, the Drush site-install command does not support this directly; however, there is a configuration import installation profile that Alex Pott wrote that will perform this function.  It should be possible to use this from Drush site-install.

In general, though, if your use-case is moving configuration from one site to a different site, you should use features, not the configuration system.


Push Notifications: How can I send extra parameters in push notification data?

The current D7 release of the Push Notifications module does not allow/support such extra fields (as in your question). However below are some suggestions to get you closer ...

Integrate 'identifier' in your Alert message

You could produce 2 types of alert messages, based on the content type (= News or Music), by adapting your Rules Action. This by also integrating the available [node:content-type] token, it could look something like so:

      { "push_notifications_send_message_bulk" :
        { "message" : "[node:content-type] notification: [node:title]",
          "target_group" : "authenticated" } }

Using this approach, your message starts to look like a kind of transaction to be processed, for which there might be solutions to further process it on your target platform).

Integrate 'some value' in your Alert message

Using a similar approach, you could further extend this to also include that "some value" related to your "extraField 1" (as in your question), probably you'd want to use the available [node:nid] token for that.

However, as per your comment (="it will appear {1234 (nid)} / {music (node type)} / The title (The title of the node) which does not looks good actually."), you may want to try another approach (as explained in the next suggestion).

Send JSON messages

Your data example seems to be a variation of what's shown in the issue about "sending JSON messages", in which the notification message is a JSON string that looks like so:

{"title": "my title",
 "message": "my message",
 "additionalData": { "key": "value", ... }}

Comment #3 in that issue refers to the issue about "Custom Payloads for Push Notifications", and which includes a patch (current status = needs review) with which you might get it to work somehow.

Upcoming improvements in D8

Help is on its way, as detailed in the D8 related issue about "Create content entity for push notifications".


How to add a variable to a twig field template?

Since you asked about passing the node title as a variable via the .theme file, you could use template_preprocess_field to do something like this:

  function themename_preprocess_field(&$variables, $hook) {
    if ($variables['element']['#field_name'] == 'field_example') {
      $variables['node_title'] = $variables['element']['#object']->getTitle();
    }
  }

then in your field--field-example.html.twig you could simply just use {{node_title}} to render the node title.

Also see 4k4's answer below.


How i can increase the Block settings limit?

There are a couple of things you could do for increasing the limit on blocks that you can add to your site. For instance, have you tried increasing max_input_vars limit in your .htaccess or in your php.ini file? From 1000 to, let's say, 2000?

Or increasing your limit in your settings.php file if not?

See if this post here (its second half rather) can be of any help: https://www.optasy.com/blog/how-add-more-lot-more-blocks-your-drupal-site


Using taxonomy term value as title for the view

Try to use the hook_views_pre_render on your view to override the page title

function custom_views_pre_render($view) {
  if ($view->name == 'your_view_name') {
    // get the $tid from the view's args
    $term = taxonomy_get_term( $view->args[0] );
    if( $term ){
      drupal_set_title( $term->name );
    }
  }
}


Get a sortable link in Views table display

You should use the first option, but with a slight alteration. If you use the base url when you create a link using override - views will render the link using the Drupal APIs and the the link will use any path alias created.

So all you have to do is to create the link like: node/[nid], instead of doing content/[title]. These urls are examples.


How to approve comments from a user with previously approved comments

If you don't have programming skills use the Rules module.


Filtering the terms of a specific vocabulary

In a view, to filter terms from a page tagged with more than one vocabulary, so that only the terms from, say, Hardware show, you would:

under Format, change the default 'Content' format to 'Fields'
under Fields, add a 'Taxonomy: All Terms' field
scroll down to the 'More' section and click
you should see a screen like below, which allows you to filter terms to a single vocabulary (or more, if needed)
http://img850.imageshack.us/img850/9266/filtertoonevocabulary.png


How do I make several displays of one image field in a node?

The right solution would be an image formatter, which is configurable to have multiple instances of the same image with different display options.

If you can't find this in a module, you can improvise in preprocess of the node template:

mytheme.theme:

function mytheme_preprocess_node(&$variables) {
   if (isset($variables['content']['field_image'])) {
    $image = $variables['content']['field_image'];
    $image['0']['#image_style'] = 'gallery';
    $variables['content']['field_image_gallery'] = $image;
    $image['0']['#image_style'] = 'full';
    $variables['content']['field_image_full'] = $image;
}

This code makes a copy of the image field and puts it in two additional fields, each with a different image style. This is for a single value field. I suppose your gallery is a view of multiple nodes with a single image. If there are multiple images in one node you would have to process the images in a loop (a bit more improvisation needed).

If it is a responsive image use this line to change the image style:

$image['0']['#responsive_image_style_id'] = 'gallery';

All three images should be of the same kind (standard or responsive), otherwise there would be some more work to do.


Is there a way to restrict some pages like node/add, /user/login and more?

You can use the Rules module to restrict access to those selected pages. Here is a rule (in Rules export format) which should be pretty close to implement such access restrictions as you're asking for:

{ "rules_limit_access_to_some_urls_" : {
    "LABEL" : "Limit access to some URLs",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "init" : [] },
    "IF" : [
      { "user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "1" : "1" } }
        }
      },
      { "OR" : [
          { "data_is" : {
              "data" : [ "site:current-page:path" ],
              "op" : "IN",
              "value" : { "value" : [
                  "node\/add",
                  "user",
                  "user\/register",
                  "user\/login",
                  "node\/200",
                  "node\/500"
                ]
              }
            }
          },
          { "text_matches" : {
              "text" : [ "site:current-page:url" ],
              "match" : "node\/\\d+\/something",
              "operation" : "regex"
            }
          }
        ]
      }
    ],
    "DO" : [
      { "redirect" : { "url" : "no_access" } },
      { "drupal_message" : {
          "message" : "Access to the content located at the path you tried to use is not allowed.\r\n\u003Cbr \/\u003E\r\nIf you think this is an error, please contact us.",
          "type" : "warning"
        }
      }
    ]
  }
}

Check the paths in the above rule to ensure it fits your own needs. Also note that I include an extra path that corresponds to "node/*/something" (in case you'd also want to limit access to any such URL. Replace the something in it to fit your needs. Or if you don't have such URLs then just remove that entire Rules Conditions (with the regex in it).

And indicate the correct path of the redirect to be perform (= change the "no_access" make it fit your "no access" page). Possibly you may also want to adapt the roles for which these validations should be applied.

For more details/background about using such rule, refer to my answer to the question "How to make the permissions of a module more granular?".


How to get an anonymous user session id?

You're looking for PHP's session_id():

  session_id() is used to get or set the session id for the current session.


Use Views to delete a record from the database

Userpoints can not be deleted, at least not through the UI.

Instead, you need to create a reverting transaction that removes the points that the other transaction added, or the other way round.

The only thing that you can currently do out of the box is building a link that points to the add points form with the username pre-filled, by using that as a token in views. Then you just need to add the points and save.

Everything else currently requires custom code, by e.g. writing a custom action.

Userpoints 7.x-2.x will allow this using bulk operations and better rules integration, but there is currently not much progress on that branch. As in, pretty much none.


Generally, Drupal caches pages for anonymous users. This is true for all nodes. You can turn this, together with some other caching settings, on and off at admin/config/development/performance

If memcache handles the data that otherwise goes into cache_page, then you will benefit from memcache in returning nodes.


Is there a way to import a view grid into a Carousel

Try using the jCarousel module which has great integration with views module.

This tutorial might help you as well - https://www.youtube.com/watch?v=jEMBVGBFskE


FeedsHTTPFetcher: how to parse object to get source url?

Ok, I found out a dirty solution to extract an URL from a random string text!

preg_match('#\bhttps?://[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/))#', $row->node_feeds_item__feeds_source_config, $match);


Pressflow Install - Redirect to database configuration without error

Make sure that in your settings.php all your configurations are properly set. (e.g $db_url, $base_url ..)


Drupal 7 PHP version migration from PHP 5.3 to PHP 5.6

Is there any known issues for an existing Drupal 7 site migration into php 5.6?

For Drupal core specifically, that information will be in the issue queue. A quick search for "5.6" brings up no results. It it helps, I've been running D7 on 5.6 for ages now with no problems.

Contrib modules might be a different story, you'll need to check each of those individually, unless they offer that info specifically on the project page, or through a minimum PHP version specified in the module's .info file.

  Any tools/modules to check the version compatibility of current Drupal 7 in PHP 5.6 ?

Not Drupal-specific tools (it wouldn't make sense for there to be since this just a plain PHP question). You can probably make good use of something like PHPLint. Personally I would start with IDE tools (switch the language version to 5.6, run a validator, then check the current issue list for errors)

  Other than this any suggestion or advices prior to the migration ?

The only sane advice is for you to treat this as any other upgrade, whether that be code or server - make sure the site is fully tested in a development environment before pushing anything live. Have a plan in place to downgrade quickly on the live servers in case something goes wrong. If that's not an option (i.e. you don't control the server software), then re-double your testing efforts, and make sure server config is as identical as you can get it before pushing anything live.


Adding CSS and JS to form with attachments

Have you looked at the documentation?

Attach CSS and JS to form

http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#attached

$form['#attached']['css'][] = drupal_get_path('module', 'ajax_example') . '/ajax_example.css';

$form['#attached']['js'][] = drupal_get_path('module', 'ajax_example') . '/ajax_example.js';

External files

http://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_process_attached/7

External 'js' and 'css' files can also be loaded. For example:

$build['#attached']['js']['http://code.jquery.com/jquery-1.4.2.min.js'] = array('type' => 'external');


How do I retrieve the query parameters from a path?

The problem was the block was cached.  See Clive's comment:

public function build() {
  $test = \Drupal::request()->query->get('keys');
  return array(
    '#markup' => $test,
    '#cache' => array(
      'contexts' => array(
        'url.query_args:keys',
      ),
    ),
  );
}


You can use a module call Sub Path Auto

here is a help video with an example that should work for you.

Module description :

  For example, if user/1 is aliased to users/admin, this module rewrites
  the link to the user contact page user/1/contact to use the aliased
  URL users/admin/contact instead. This also includes Views URLs taking
  a node as argument (e.g. node/%/yourview), in short, every URL that is
  based on, or extends, an existing alias. In combination with the
  Pathauto module it is possible to get rid of all remaining exposed
  internal non-administrative URLs.


Unpublish node based on date field with Rules

1. Timing of a scheduled Rules Component

After a rule is scheduled (using the Rules Scheduler, a submodule of Rules), it will only actually execute next time cron runs. Example:

schedule a rule to execute at timestamp X (which appears to be node:field-termin-datum:value in your case).
if the next time that cron runs is at Y mins after timestamp X, then the Rules execution will only happen then (= at Y mins after timestamp X).

BTW, as per the edit of your question, it seems that the Rules Component actually does get scheduled, and that your real issue is related to the execution of that scheduled component ... read on for more details about that.

2. Cron runs anonymous

Cron (always) runs with user anonymous, rest assured about that (in any Drupal 7 site). But here is an "educated" guess: your site is configured so that anonymous users are NOT allowed (= do not have the permission) to unpublish nodes.

Up to you to confirm if my guess is correct, but if it indeed applies, the answer to your question is that to get this to work you would need to grant anonymous users the permission to unpublish nodes. I bet it is not going to be what you want to do (I wouldn't ...), but trust me, that would be a prereq to make it all work in your site.

3. If everything else fails ...

If none of the above helps to find out what is causing your issue, then try either of these suggestions to get a better understanding of what is (not?) happening:

Try to execute your Rules Component "manually" (just to test), to unit-test if it works as desired, so without using the Rules Scheduler. To do so, use the "execute" link to the right of the Rules Component (in the Rules UI).
Do some Rules debugging ... For way more details about that, refer to the answer to "How can I display the value of a variable inside a condition?".


FlexSlider, Media Galleries, & Nodes (entity reference)

I can recommend the ”Entity Reference Views Formatter" module.

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

You then have full flexibility of views to output your Entity reference fields!

Here is a good thread on how to use the Entity reference views formatter module, setting up the correct Relationship and Argument can be a bit tricky.
https://www.drupal.org/node/1889358


How do I send an email to all users with a particular role?

I'm a bit familiar with the (amazing!) Rules module. But to my knowledge the current answer to this question is a No go, that is: can't do that yet with the most recent D8 version of Rules.
Refer to #d8rules status update November 2017 to get a better understanding of the current status of Rules for D8. Here are some quotes from it:

... Fago can’t dedicate time required to develop the module further. What Rules is really missing at the moment is development capacity to help finish the last milestone.

... Even if we got more funding today, fago the current principal maintainer of the Rules module wouldn’t have enough capacity to do the work himself.

One never realizes what has been done, only what remains to be done ... So start here if you wonder how to contribute.
BTW, Rules documentation for D8 contains the official Rules documentation specific for D8.
Plan B
While waiting for Rules to become more mature, you can use the Admin Content Notification module as a temporary alternative (which does have an official D8 release already). Some details about it (from its project page):

... can be used for receive email notification when a new content of any content type will be created on your site. Although one can use rules for the same functionality but it's not good to use rules only for notification as it is a huge module, so we can use this module for small websites.

The "...Although one can use rules for the same functionality ..." part of this clearly does not apply to the D8 version of Rules (yet).
The image shown on the project page gives an idea of what this module can be used for.
Obviously, your question is about updates of content. But even though it doesn't say so (yet) on the project page, just have a look at the issue "Also trigger event on update", which appears to be as in your question.


Creating specific front pages for departments

If you don't want to code, and you are familar with context module you can use this Context Reaction Menus.
Add new context with a URL as a condition, for example "department1/*" and as a reaction change the main menu, this will change in all pages that start with "deparmente1"


How to get height and width of image style?

No Sssweat's answer inspired this.

I added this before if statement (if($node_image->isEmpty())) to get the height and width.

$image_style_config = (ImageStyle::load('medium')->getEffects()->getConfiguration());

foreach($image_style_config as $config) {
  if(isset($config['data'])) {
    if(isset($config['data']['height'])) {
      $image_style_height = $config['data']['height'];
    }
    if(isset($config['data']['width'])) {
      $image_style_width = $config['data']['width'];
    }
  }
}


How to show pager in terms of views of tags?

Create a view of content ( as a page with pager ) and add a contextual filter named Content: Has taxonomy term ID. Refer the images below.

Once you have configured this then you can acces this view using a url like mysite.com/view-path/tag-name.


How do you update a data blob column by searching and replacing a string using drush?

You can use the following MySQL statement in the drush SQL console:

drush sqlq "update users set data = replace(data, 'string_here', replacement_string') where uid = 1"


Pre populate a text field when creating node

I would suggest you create a content type called "Text Templates". Then add a reference to this content type in the content type that you are using.

In hook_node_submit you can get the value from the body fields of the Text Template node using the node-reference and then pre-populate in your current node.

If you want the body to be filled during the node edition then you will have to write an ajax call to fetch the body based on the drop-down value and fill it in the body.


What's the best way to add an element to a form AFTER submission?

Expanding that comment into a minimalist example code answer:

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

  // get the submitted data
  $foo = $form_state->getValue('foo');

  // call any other service to process your form submission values
  // (you can replace this with dependency injection of course)
  $bar = \Drupal::service('other.service')->baz($foo);

  // add results element to the $form

  $form['results'] = [
    '#type' => 'table', // or markup, or whatever you want to build your results
     // could also do #theme for a custom theme hook.
     // Use $foo, $bar etc however you want here
  ];

  // rebuild the form with your newly added results element,
  // and prevent drupal from redirecting to a separate GET page,
  // so that the populated form remains visible above the results.
  $form_state->setRebuild(TRUE);
  $form_state->disableRedirect(TRUE);
}


Adding multiple links to the same table cell

I think you can do it as Clive alluded to with render array:

  $link_1 = Link::createFromRoute('Link 1', 'route_1')->toString();
  $link_2 = Link::createFromRoute('Link 2', 'route_2')->toString();
  $link_concat = ['#markup' => $link_1 . ' - ' . $link_2];

  $header = [ ... ];
  $row = [];
  $row[] = [
    'data' => \Drupal::service('renderer')->render($link_concat),
    'class' => 'middle',
  ];
return [
  '#theme' => 'table',
  '#header' => [..],
  '#rows' => $row,
];

This is just one method of doing it, there are a lot of ways you could potentially work this scenario. This way just puts the two links with a dash in between. But hopefully this will help guide you towards a solution.


How to configure Wysiwyg + Ckeditor Library not to breaks source code lines

I think what you are looking for is WYSIWYG Linebreaks.


Build context menu for news articles (sample image included)

Not really an answer, but perhaps a lead.  In Drupal 6, a similar thing was accomplished with the book navigation block.  You could have the book navigation block filter to a certain number of steps up/down tree from the node page that you were currently viewing.

I am not sure how this could be accomplished with existing views configuration, as I think tree navigation is not a common thing for views.

This is more the kind of trick I would expect to find in Taxonomy, based on the vocab's hierarchy.  There, navigation can be a more certain thing, as the structure is defined in the vocab, and they are just filling the tree leaves with tagged nodes.  Again with the Drupal6 reference, but perhaps you can scavange code from http://drupal.org/project/taxonomy_treemenu

If you do code something, release it back to the community?


Need help on adding options to $form via select field

Borrowed From HERE:

If you want to do this hardcoded, you might try to use the #ajax property of the Form API

You can reload your second dropdown on change of the value of the first dropdown and change the value while reloading the form.

I made a little example to give you an idea :

$form['number'] = array(
  '#type' => 'select',
  '#title' => t('Select Number'),
  '#options' => array(
      0 => 1,
      1 => 2,
      2 => 3,
  ),
  '#default_value' => 0,
  '#ajax' => array(
    'callback' => 'ajax_replace_dropdown_default_value_callback',
    'wrapper' => 'wrapper-dropdown',
    'method' => 'replace',
    'effect' => 'fade',
  ),
);

$default_value = !empty($form_state['values']['number']) ? $form_state['values']['number'] : 0;

$form['open_closed'] = array(
  '#type' => 'select',
  '#title' => t('Open / Closed ?'),
  '#options' => array(
      0 => t('Open'),
      1 => t('Closed'),
      2 => t('Progress'),
  ),
  '#value' => $default_value,
  '#prefix' => '
',
  '#suffix' => '
',
);

function ajax_replace_dropdown_default_value_callback($form, $form_state) {
  return $form['open_closed'];
}

In your case you will have to do it in a hook_form_alter and add the #ajax property to your first dropdown and add prefix and suffix to give the second dropdown the proper value.

You can also check this link about AJAX with the FORM API :


Using breadcrumbs with multiple menus for one link

Multiple Node Menu might do the trick:

  This module modifies the "Menu settings" in standard node editing form
  to allow managing multiple menu links to a node. The Drupal standard
  behavior is to only care about a single menu link for anode, all other
  menu links must be added through menu administration.


Differences between value and safe_value

It is a value, passed through the function _text_sanitize(). You can read more in the official docs.

If you are using 'safe_value', you may be also interested in this article: Rendering Drupal 7 fields (the right way).


How to save/map uploaded image in term field of type image with storage location equals s3://

An Image type field should contain a file fid of an image file. The following should resolve your issue:

$img = $form_state->getValue('image_dir');

if (!empty($img['fids'])) {
  $img = reset($img['fids']);
}


How can I change page elements (menu, blocks, etc) based on a chosen 'audience' link?

Explaining the whole process would be bit complicated

i ll provide you some steps try to follow that.

In our project the same structure you have mentioned is used we have global pages like mysite.com/products and some further branch level pages like mysite.com/chennai/products

Step one: create a view page in views.

Step two: create a taxonomy term reference for the audience.

step three: create a block and in contextual filter add taxonomy term as contextual filter and in provide default value give get taxonomy term by url.

step four: for every content you create it should have the term reference field.

step five: when you pass the audience name in the url it should display the content related to the taxonomy term.

step six: like wise you have to configure the block in all the pages

step seven: in block settings give display only in that particular  page

now what this will do is for every block it will be displayed their content based on the url if you change the url to audience two it will show the content having the taxonomy term as audience two as their value.

hope this will give you a start up for the task :p


Using version control/deployments with Context

OK; so I swear I did look reasonably hard for this before I posted the question, but I have done the thing where I've genuinely found the answer 15 minutes after posting.

http://www.mcdruid.co.uk/content/default-drupal-contexts-like-default-views was the blogpost I needed - he's created an issue to get this information into the module, but it looks like it won't happened.

This seems to work really well, and I've created a separate submodule just for contexts.


Get field machine name inside HOOK_preprocess_file_link()?

You need to pass the field name to the file link through hook_preprocess_field()
A similar approach is used in Themable Forms module.
Check its module file.


Can't use exit(0), how else can I terminate a response?

You need to terminate using the kernel. You'll have to generate $currentRequest and $response, which may already be available depending on where your code lies. After you have them, you can terminate the request using:

\Drupal::service('kernel')->terminate($currentRequest, $response);


How to implement Slider Effect for pages?

It depends on the JavaScript library a module uses.

I use the Flex Slider https://www.drupal.org/project/flexslider that it have both arrows for desktop and swipe for mobile.

I can't understand what you want to achieve (static?), but:

I think the best way it to create a new content type (let's say slider) to upload images that will be used by the slider plus a taxonomy field that you will specify the slider you want to display the image.
Then create a slider view with a filter based on that taxonomy.
Finally render the view as a block.

-- EDIT --

So, you want to create a slider that will present nodes.

Let's say we have two content types Article & Basic, with fields: Title, Description, Image, Taxonomy.

Create a View
Format: FlexSlider, Show: Fields
Fields: Title, Description, Image etc
Filter criteria: Content type->Article, Basic
Save
Edit the appearance of the slider with css
Enjoy

The nodes will be pre-loaded and there will be no waitting time from slide to slide (but it will take longer to load the page).


looking for a complete documentation for Drupal's database schema - need to have some overview

Check Drupal's Schema API. Here is the link to it. Also the Book "Pro Drupal Development" has an excellent chapter on Working with Databases.You might find that one useful too.


Menu attributes module is for what you want. Some details from its project page:

  This simple module allows you to specify some additional attributes
  for menu items such as id, name, class, style, and rel.


I also have tested rules module in drupal8 but data selectors did not worked, as also mentioned here https://groups.drupal.org/node/516054

Then i tried https://www.drupal.org/project/registration_role which worked for me. You may also try this module if you want to assign a role to a user on registration.

Thanks


Serialization of 'Closure' is not allowed

I believe this comes from loading a connection in the SOAP client, and storing it in memory with $this->soapClient. The problem is that the soap client cannot be serialized. Serialization is the process of turning something into a string, generally so it can be stored in a databse or a file or something, to be retrieved later. The SOAP connection is not something that can be stored, which is why you are facing the issue.

You could potentially store the SOAP client in the construct method, then make the connection using the client when you actually need it. I'm guessing that the client, without a connection, can probably be serialized. I may be wrong though, and you may need to call the soap client dynamically every time you need it.


There are many other methods to do it, but I prefer this method,

Try this on your Rules module.

  Events: User has logged in.

  Condition: User has role

  Actions: Page redirect


Can a content entity type have a bundle which is a configuration entity type as with the contact form?

This may be easier to understand with Nodes, since Nodes have been used by almost every Drupal site builder.

Nodes are a Content Entity. Nodes have bundles (aka content types). For example, a blog. Now, to define the blog type, a new Config Entity is created - the Node Type entity. Config entities have keys. The key for the blog Node type is 'blog'. This key identifies the node type. But the blog bundle is still a Node entity, and therefore is a Content Entity.

The contact form works the same way.

So to answer your question, no, bundles of Content entities cannot be config entities, as bundles are just a subset of the original entity, which is a Content entity. But a Config entity is used to define the bundle (allowing the types to be exported as configuration).

You could almost compare it to the 'type' field on a Content Entity being an Entity Reference to a Config entity that defines the type.


Topics are not getting associated with forum

Try:

drush state:set comment.maintain_entity_statistics TRUE

Explanation:

core/modules/comment/src/CommentStatistics.php in the update() function says this:

// Allow bulk updates and inserts to temporarily disable the maintenance of
// the {comment_entity_statistics} table.
if (!$this->state->get('comment.maintain_entity_statistics')) {
  return;
}

In my case, somehow this was not set, causing this function to bail out and not update the comment_entity_statistics table. Drupal needs this table updated to display the proper forum posts.

"drush state:get comment.maintain_entity_statistics" can be used to check if this is already set.


You can also use below modules :

Yahoo! Finance currency converter

  This module provides Currency with currency exchange rates through
  Yahoo! Finance, which are updated continually throughout the trading
  day.

Currency Converter

  Currency converter module was created for quick currency convertation.
  It contains 10 currensies.

  It is flexibly configurable block. The currency undertakes from
  several banks (on a choice).

Open Exchange Rate Money.js

  This module provides support for the money.js currency conversion
  script from http://josscrowcroft.github.io/money.js/ along with
  support for the Open Exchange Rate currency conversion data.

Exchange Rate

  Exchange Rate API is an extensible module that allow users to display
  and manage the exchange rate in countries from around the world.

  Is common to see tools that present the official exchange rate, the
  problem is that each bank has his own rate, for this reason it is
  important to have a tool that can show the different variations across
  multiple financial institutions.


You can use

https://drupal.org/project/commerce_entitycache

It will cache the commerce entities, rather than build them on each request.

While it works ok as is, after the two "Needs review" patches I added to the issue queue:

https://drupal.org/project/issues/commerce_entitycache?categories=All

I'm using it myself without any problems.

As mentioned previously:

https://drupal.org/project/authcache
https://drupal.org/project/commerce_authcache

Also work well with Commerce


How can I make Plupload in D7 start uploading automatically?

As given in the readme file of this module add following autoupload property to your form element as shown below.

$form['my_element'] = array(
  '#type' => 'plupload',
  '#title' => t('Upload files'),
  '#description' => t('This multi-upload widget uses Plupload library.'),
  '#autoupload' => TRUE,
);

I have tried it and in works fine.


Each element should have only one ID and it should be unique. You can change the body texarea id with the hook_form_alter()

Example

/**
* Implements hook_form_alter().
*/
function YOURMODULE_form_alter(&$form, &$form_state, $form_id) {

  if (isset($form['#node']) && $form['#node']->type == 'article') {
    // body textarea ID
    $form['body']['und']['0']['#attributes']['id'] = 'redHat';
  }
}

but you cannot add the next one.


How can I get single keys in multi-item config objects using debug:config?

No, Drupal Console doesn't support selecting a key from a configuration object. This is clear from drupal help debug:config which even mention grepping.

Using grep isn't beautiful, but it works:

drupal debug:config system.date | grep -A1 timezone

does return the timezone with the first subkey. (Changing the value after A, you get more lines/the user subkey.)

I would of course prefer to get the configuration object as proper JSON and then pipe it to jq to select a key robustly, but Drupal Console doesn't support an output format option yet - see Github issue.


Field collection 'add more' and 'remove' hooks?

I managed to solve this with some jQuery.

Not sure if this is the "cleanest" way to do this, but it works. I hook into the mousedown() event of the "add another item" button,and trigger the other button's mousedown manually.

I also added a delay of 800ms, because of some conflicting events if the 2 mousedowns are too quickly after eachother.

Hope this helps anyone in the future.

$('#edit-field-pressure-calculation-und-0-field-pressure-calculation-line .clearfix .field-add-more-submit').mousedown(function() {
    setTimeout(function() {
      $('#edit-field-heat-calculation-und-0-field-heating-calculation-line .clearfix .field-add-more-submit').mousedown();
    }, 800)

  });


How to change the site logo in a preprocess function?

How to change the site logo in .theme preprocess function?

The site logo is no longer in the page template. You can change it now in the branding block:

function mytheme_preprocess_block(&$variables) {
  if ($variables['base_plugin_id'] == 'system_branding_block') {
    $variables['site_logo'] = '/newlogo.jpg';
  }
}

Caching

You mentioned you want to change the logo based on URL args. This would be difficult to do this in the system branding block, because the template is not rendering the render array, but transferring only the content of three variables and so any attempt to add cache meta data would be useless.

You have two options. Implement your own site logo block plugin in a module or use this theming only solution:

disable the site logo in the branding block
set a variable with the url for the logo in page preprocess $variables['logo']
add your own markup to the page twig to output the site logo

page.html.twig:

<a href="{{ path('<front>') }}" title="{{ 'Home'|t }}">

By doing this in the page template you avoid caching problems because the page is already cached for each url separately.


How do I see the ID of a content type record?

When creating your entity reference field there is a "Mode" selection. The default is simple but you can choose to use a Views entity reference display type instead.

So in views if you create a new view (that displays the data you want) and add a entity reference display type to i. You can then use that in your entity reference field.

EDIT: Just seen the comment above referencing Show node IDs along with titles in Entity reference Autocomplete list Do that


Change the position of the block created from the Locale module

You can put your block into any region you like on the general block config page.

If this is not enough you can change everything about a region in the page.tpl.php file or the corresponding CSS files.


Making content available to a user after certain amount of time

I yes I think this is possible using Rules and Rules Scheduler

Unpublishing Content

You should check out this tutorial  (its also for Drupal 6)

Publish content exactly 24 hours after it was created

What you have to pay attention to is just do the opposite. So in the action you say Unpublish. And then of course you pick the dates.

Hope it helps


Do third party drupal modules pose a security risk?

Well, have you deleted that module without disabling & uninstalling it first? Some of your effects seems to be that way. Anyway, automatically updating a module from 3rd-party server is only as secure as his server. If you did it, and source server was compromised, you should consider yours compromised, too. Only safe way? Revert from backups to the last snapshot you are reasonably sure to be safe, and then do not update that module (possibly uninstalling it as soon as feasible).


Auto-Fill from on content type to another

In my example I've created two content types with two custom fields in addition to your node reference field:

Node type: Point-of-Contact (machine name points_of_contacts)

Text field: To field one (machine name field_to_field_one)
Text field: To field two (machine name field_to_field_two)

Node type: Example (machine name example)

Node reference: Point-of-Contact (machine name field_points_of_contacts)
Text field: Field one (machine name field_field_one)
Text field: Field two (machine name field_field_one)

Then You need to create a custom module to alter node reference dropdown field to ajax dropdown with callback function.

First create custom module by following this tutorial

Second alter node reference field by implement this hook hook_field_widget_form_alter

function MODULE_NAME_field_widget_form_alter(&$element, &$form_state, $context) {

  if(isset($element['#field_name']) && $element['#field_name'] == 'field_points_of_contacts') {
    $element['#ajax'] = array(
      'callback' => 'MODULE_NAME_auto_fill_callback',
    );
  }
}

Third implement ajax callback function

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

  $commands = array();

  if(isset($form_state['values']['field_points_of_contacts'])) {
    // get selected item/node from dropdown list
    $nid = $form_state['values']['field_points_of_contacts']['und'][0]['nid'];

    // load node by nid
    $node = node_load($nid);

    if($node) {

      if(isset($node->field_to_field_one['und'])) {
        // fill text field
        // edit-field-field-one-und-0-value represent the generated html id of the text field
        $commands[] = ajax_command_invoke('#edit-field-field-one-und-0-value', 'val', array($node->field_to_field_one['und'][0]['value']));
      }

      if(isset($node->field_to_field_two['und'])) {
        // fill text field
        // edit-field-field-two-und-0-value represent the generated html id of the text field
        $commands[] = ajax_command_invoke('#edit-field-field-two-und-0-value', 'val', array($node->field_to_field_two['und'][0]['value']));
      }
    }
  }

  return array('#type' => 'ajax', '#commands' => $commands);
}

Note: change MODULE_NAME to your desirable module name.


Display only the terms in the filter set using Views

I would suggest doing the following.

Instead of displaying all the tags in one line display it in different lines. That is in the multiple filed settings you would choose it to display it on different rows. The result would be something like this

node 3 | red
node 5 | white
node 5 | green

Without the filtered nodes.

Now you would group it with the title field so that it would be displayed together.

To do the grouping you would do the following.

Click on the settings link towards the right of Format :

This would bring up a screen as shown below. you would select the field you want to group from the dropdown Grouping field Nr.1


How to set up subscription service with credits that visitors can use to buy products?

The Drupal Commerce site builder's guide refers to modules named Commerce Credits and Commerce Credits Transactions for building sites with a "store credit" feature.

However, these modules seem to be unmaintained and aren't covered by Drupal.org security policies, so you would need to evaluate the value of using them in your integration vs the risk of having to support a site using them without much help.


expose age range in views but DOB field is date

Try using the Computed Field module (in beta in 7). You would simply add a new field, of say age, and of Computed type, (follow a walkthrough here) and then use a Filter in the View to select the range of ages that you require.

Hope this helps!


altering css / asset weight after it's been added?

Take a look at hook_css_alter():

/**
 * Implements hook_css_alter().
 */
function MYMODULE_css_alter(&$css) {
  $css['sites/all/themes/FUZZYGREYEDOUT/css/blog.css']['weight'] = 10;
}


db_set_active() and node_save() not working as expected

Here is some help:

The general format for the $databases array is as follows:
 * @code
 * $databases['default']['default'] = $info_array;
 * $databases['default']['slave'][] = $info_array;
 * $databases['default']['slave'][] = $info_array;
 * $databases['extra']['default'] = $info_array;
 * @endcode
 *
 * In the above example, $info_array is an array of settings described above.
 * The first line sets a "default" database that has one master database
 * (the second level default).  The second and third lines create an array
 * of potential slave databases.  Drupal will select one at random for a given
 * request as needed.  The fourth line creates a new database with a name of
 * "extra".

Are you sure Drupal can connect to the second database? Check your login credential, put some dummy table and do a db_query to verify they exist only in the second one.


How can get path of image (src) in twig template of a module?

You need to use file_create_url much like Drupal 7 to transform a file path to file url. To get the path to the module, you should use drupal_get_path, combined it could look like this:

function my_module_preprocess(&$variables, $hook) {
  $variables['img_path'] = file_create_url(drupal_get_path('module', 'my_module') . '/image/icons/my-image.svg');
}


First of all you should be aware that if you were to display the input of a input like is was full HTML, it would be the same thing as giving the user who created the content access to using the full HTML filter. The only difference is that you wont tell the user that he can type full HTML. This could potentially open your site to exploits, if people write harmful HTML. You should instead give users access to the filters that you want to use for their input.

Now if you want to display any text through any filter, you can do that by using check_markup. You simply pass the text and filter id to the function and it will return a text you can use on your site.


entityform list fitting to selected node

Drupal uses static forms by default, therefor one step doesn't influence another step. You are probably looking for a thing called conditional fields.

You should be able to use the Conditional Fields module for this. Although I am not entirely sure it it works on all form types.


Multi instance Drupal on single server. Is SSO possible to be implemented?

I see that this answer is late but, yes.  I am setting that up now but still working through some config.

I created a D7 installation called auth.local.domain.com (these are currently only on my dev machine).  For this instance I installed oauth2_server and openid_connect_sso modules
I created a separate D7 installation called client1.local.domain.com.  Here I installed the openid_connect and openid_connect_sso modules.
I installed 9 more sub-sites (client2 - client9) under Client 1, using drush.
I used Drush to enable the openid_connect and openid_connect_sso for all sub-sites.
I added all 11 of the sites to my Apache config (I am using MAMP Pro on Mac) and tested them.
I had some config to do on on the auth site relating to each client site and to each sub-site for the SSO.

I am using https://drupalcommerce.org/blog/32567/using-openid-connect-single-sign-drupal as my general guide for setup and configuration of the modules as well as https://www.youtube.com/watch?v=3K-2IfC8lpg but the multi-site part I figured out myself.


How to display blocks depending on the logged in user?

You could go to blocks setting and there are Roles tab.
If you check "anonymous user" - this block will visible only for not loggined user. If you check " authenticated user" - block will be visible loggined user.


How to highlight location on an OpenLayers view

OpenLayers Heatmaps module allows you to create Heatmaps layers through the Openlayers module and it don't have the views integration, but you can highlight the specified location like the below one and honestly I'm not using this before.

Features

  Provides a new kind of behavior in the OpenLayers's maps settings.
  customize the radius, intensity and opacity of each Heatmaps.


How can I include standard bits of text in a node, depending on the node location or a particular term?

If you create a new content type, say "Location Description", you could add a node reference field into your hotel content type referencing the respective location node.


Using google geocoding with geocoder module, you may use another geocoding provider, i think this requires a google map token now given google's new rules :

// @return Geometry Returns a geoPHP geometry object. Generally a Point.
$point = geocoder('google', $address);
$lat = $point->coords[1];
$lon = $point->coords[0];

I did this long time ago, please check.


How to create a list of untranslated content in views?

You can use the Translation Views module.


How to change path that username points to

You can use hook_menu_alter, it's not even too much work to do, just

anymodule_menu_alter( &$items)
{
    $items['user/uid'] = $items['main-profile/uid'];
}

clear cache and it will turns user/uid into nothing more than an alias of main-profile/uid.


how to call a webservices on hook_form_FORM_ID_alter but not when the form is submitted and validation raise no error?

The reason why your alter is called twice is because Drupal needs to build the form at least two times: one for the first time is delivered to the user and a second time when the submit is done. The second build is needed because Drupal needs to know the complete form that was delivered to the user (for validation and security reasons).

You have two approaches to solve this:

Form API

As other have answered modify the form API behavior to avoid that second call:

Detect the second call and do not call the webservice (checking $form_state['triggered_element']['#name'] as told): it's ok but take into account that if the form built in the second call is different form the first one you may have problems with Form API complaining about invalid user input,
Enable form cache ($form_state['cache'] = TRUE). This way Drupal saves the form when is built for the first time, so the second time during submit, form is fetched form DB.

Cache webservice results

A second call to the webservice is not a problem if you cache webservice data  because you retrieve the results from the cache instead of call it again. I think this is the best option if the nature of the webservice data allows to cache it.

This way the problem is solved in the webservice area while the other solutions involves that other components solve the issue (your form API code solves the webservice problem). If there's another similar use case you will have to solve again the proble, but if you solve it using webservice caching the problem is solved for all use cases.


Entity Reference Views - Contextual Filters - Administrator override

I'm not really sure why this works but anyways.. It seems to be what you want.
You'll need Views Contextual Filters OR.
In my test, I used the contextual filter for author UID. So your entity reference field would only shows nodes created by the current user.

In your view, add the Content: Author relationship (don't check required) and Content: Author uid contextual filter (provide default: current user).
Enable Contextual filters OR in Query settings under Advanced.
Add a second contextual filter for Content: Author uid (provide default: current user)
Under More at the bottom of the filter, click exclude.

When added this an entity reference field, normal users only see nodes they've created but as admin, I see every node on the site. Weird but it works.


Concatenate and minify css with Gulp still necessary?

No, it's not necessary, unless you decide there's an appreciable performance benefit by using the gulp method as well (possible but unlikely).

You'll just be minifying twice otherwise, wasted CPU cycles.


How do I enable a module by exporting the configuration?

You need to import the configuration from the file, into the database. Configuration files are only a backup to configuration. The active configuration is in the database.

You can import configuration at /admin/config/development/configuration or run drush cim.


Creating products with Rules and calculating price in Drupal Commerce

Well It looks like I found a way. I needed to save an entity before adding to cart.

If someone will found himself struggling in the same spot, I will leave an exported rule here:

{ "rules_grafeon_doplnkov_slu_by_pri_pridan_do_kosika" : {
    "LABEL" : "Grafeon - Doplnkov\u00e9 slu\u017eby pri pridan\u00ed do ko\u0161\u00edka",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "commerce_discount_extra", "commerce_cart" ],
    "ON" : { "commerce_cart_product_add" : [] },
    "IF" : [
      { "entity_has_field" : {
          "entity" : [ "commerce-line-item" ],
          "field" : "field_doplnkove_sluzby_item"
        }
      },
      { "data_is" : {
          "data" : [ "commerce-line-item:field-doplnkove-sluzby-item:0" ],
          "value" : "Service SLA"
        }
      },
      { "commerce_discount_extra_line_item_has_product_type" : {
          "commerce_line_item" : [ "commerce_line_item" ],
          "product_types" : { "value" : { "product" : "product" } }
        }
      }
    ],
    "DO" : [
      { "variable_add" : {
          "USING" : { "type" : "date", "value" : "now" },
          "PROVIDE" : { "variable_added" : { "variable_added" : "Added variable" } }
        }
      },
      { "data_convert" : {
          "USING" : { "type" : "text", "value" : [ "variable-added" ] },
          "PROVIDE" : { "conversion_result" : { "conversion_result" : "Conversion result" } }
        }
      },
      { "entity_query" : {
          "USING" : {
            "type" : "commerce_order",
            "property" : "order_id",
            "value" : [ "commerce-line-item:order-id" ]
          },
          "PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
        }
      },
      { "entity_create" : {
          "USING" : {
            "type" : "commerce_product",
            "param_sku" : "DS-[commerce-line-item:order-id]-[conversion-result:value]",
            "param_type" : "doplnkov_slu_by",
            "param_title" : "Service SLA",
            "param_creator" : [ "site:current-user" ],
            "param_commerce_price" : { "value" : { "amount" : 100, "currency_code" : "EUR" } },
            "param_commerce_stock" : "1000"
          },
          "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
        }
      },
      { "data_calc" : {
          "USING" : {
            "input_1" : [ "commerce-line-item:commerce-unit-price:amount" ],
            "op" : "*",
            "input_2" : "0.15"
          },
          "PROVIDE" : { "result" : { "result" : "Calculation result" } }
        }
      },
      { "data_set" : {
          "data" : [ "entity-created:commerce-price:amount" ],
          "value" : [ "result" ]
        }
      },
      { "entity_save" : { "data" : [ "entity-created" ], "immediate" : "1" } },
      { "commerce_cart_product_add_by_sku" : {
          "USING" : {
            "user" : [ "site:current-user" ],
            "sku" : "DS-[commerce-line-item:order-id]-[conversion-result:value]",
            "quantity" : "1",
            "combine" : "0"
          },
          "PROVIDE" : { "product_add_line_item" : { "product_add_line_item" : "Added product line item" } }
        }
      }
    ]
  }
}


You would need to do something like this in your my_page_function

$output = '

hello

';

print $output;
die;

So don't return anything. It's not great and avoids everything drupal related really but it sounds like what you want to do. As using anything to do with drupal's theme functions will always be wrapped in the site of the site content


Get paths of files attached to the node from field name

You can get it like this:

$file_uri = $node->field_machine_name->entity->getFileUri();

If your field allows for more than 1 value, then:

$file_uris = array();
foreach ($node->field_machine_name as $value) {
  if ($value->entity) {
    $file_uris[] = $value->entity->getFileUri();
  }
}


Group of CCK fields assigned to the same NID without an additional Node type and Node referrence

It appears to me you are needing a compound CCK field type.

If so, take a look at http://poplarware.com/articles/cck_field_module for a rather in depth discussion of how to write your own.

If you don't want to do that, the 3.0 branch of CCK for Drupal 6 apparently has a Multigroup Module.  Check out How to add cck custom date field? for discussions about that option.