Set the search index and the field_revision_body empty

You shouldn't empty field_revision_body as it will break the content, but search_index is ok to empty.

Regarding search, please review the settings at: /admin/config/search/settings

e.g uncheck the Node and User search under "Active search modules"


How do I migrate from Rhythmyx to Drupal?

Rhythmyx is proprietary software. You're likely to find very little, if at all, people in the Drupal community that have experience migrating from it.

The first thing to know is what technology stack it's built on so you can evaluate tools to pull out content. The vendor's website is scarce on tech details. From what I could find, the language is perhaps Java. It's also supposed to have a static content export & pluggable API so that should be able to assist in pulling out data.

On the Drupal side, there's Feeds &  Migrate. Feeds is best for mostly static content migration where there isn't fresh content coming into the site on day-to-day basis (and thus an ongoing need to sync both the existing site and new site while development/testing is happening). Migration is a best when you have many different custom content types, taxonomy, users, and other custom data that needs to synced regularly while development is occurring.

Whatever means you find to pull out data from Rhythmyx will affect what import tools you use. If you have static structured data (e.g. CSV, XML, RSS Feed) Feeds is the better choice here. If you have an API that PHP can interface with, Migrate will be more useful.


How do I provide multiple menu tabs for a view?

I have solved this problem using the Quicktabs module.

I use a panel to set a page where I can put a quicktabs block, then I call different views with each tabs, also you can even set arguments.


How to set time limit only for one php file?

Don't do this. While it is possible to do this, using set_time_limit(0) is giving your server free rein to execute indefinitely; you're setting yourself up for server instability.

If you have a large workload that you need to execute in a Drupal context, use its Queue API. This API will let you queue up a list of items to process (i.e. the table rows you're checking) and process them with a queue worker (i.e. the task that "does the checks" and generates user notifications).

You can find many examples of creating a queue and a queue worker by searching Google for [drupal 8 queue api].


Using Migrate API, is it possible to UPDATE entities on subsequent imports?

Got the answer:

add --update to your drush command (drush mi your_migration --update)


how to hide view block when other view block not giving any search result?

For such cases, when visiblity of one view need to be dependent on another view, we may alter the view, or we can use hook_views_pre_render or hook_views_pre_render to control the view through custom code.

Here as you are using block, so you can also use block configuration "Show block on specific pages" instead of coding in some custom module.

Then you can select option "Pages on which this PHP code returns TRUE" there.

After doing so, you can use the following code in the textarea:

<?php

$view = "<Your dependee view's machine name on which other view is dependent>";

$display = "<Your dependee view's display ID>";

$all_row = views_get_view_result($view, $display);

if(count($all_row)>0) {
  return TRUE;
}
?>


The other option to try is a custom form alter and add the #states key to those fields. This is a code only, no ui approach, but it should work just as well for what you are looking to accomplish.

Here is an article that describes how to use #states. http://randyfay.com/states


Adding variation types and sub variation types

You can create fruits as taxonomy and assign this to your product type.

Creating Taxonomy:

Go to Administration -> Structure -> Taxonomy.
Click on "Add vocabulary" link to create new taxonomy and it will redirect you to taxonomy form.
Add name(fruits) for vocabulary and save the form and it will redirect you to list of taxonomy.
Click on list terms in row of fruits taxonomy.
Click on 'Add Term' link to add new term for fruits taxonomy.

Assign Taxonomy to product type:

Go to Administration -> Store -> Product
Click on Product types link in top of page and it will redirect you to list of Product types.
Click on Manage fields link in row of Product.
Add Term Reference field and select fruits as vocabulary and save the form.

Selecting taxonomy as menu:

If you want to display taxonomy as menu, you can use 'Taxonomy menu' module.

  Transform any of your taxonomy vocabularies into existing menus
  easily!

Taxonomy menu will create your Taxonomy Term as menu item.

Configuration of Menu:

Edit your taxonomy in admin and select Menu location for taxonomy menu.


To execute just the system_cron() hook, the easiest way is with drush

$ drush php-eval 'system_cron();'

This will start a PHP process, boostrap Drupal, and run the input.  Note that this will run everything that this hook does, in addition to the file cleanup, including garbabe collection on the various database tables with ephemeral data, like {cache}, {batch}, {flood}, etc.  There isn't an individual function in Drupal 7 that just handles the file cleanup.

Also keep in mind that when you run drush like this, you are running as the user who you logged in as.  This user may or may not have persmissions on the files and tmp directories in order to delete files.

You could copy this code into your own script and then do

$ drush scr cleanup-the-files.php


See the example file PolicyCommands.php in the Druhs examples directory. Create a directory named "Commands" in your site's "drush" directory, and put your command file there. Its name must end with "Commands.php" or "Hooks.php".

Create a hook similar to one of the ones shown in the example file. You'll want @hook post-command site:install.


How to get fields of certain content type in template file without writing iteration loops in tpls?

You can pass your $fields to a custom function. Run your logic or foreach loop in the custom function and pass the title,body values back. Thus you would not need to use the foreach loop in template file.

Here is some sample code if it helps.

$field_data = _my_function($fields);
$data = theme('carousal', array('carousal' => $field_data));
return $data;


If you want to add the same form multiple times, you need to implement hook_forms(). See node_forms() for an example.

This allows to use different form_id's, which all point to the same form builder function. For example, you can use yourmodule_some_form_$i and then use hook_forms() to point these to yourmodule_some_form.

See http://www.mohitsharma.net/content/how-show-same-form-multiple-time-page for an example


How to resize images in a slideshow for a Responsive Theme?

You can use Flex Slider either alone, or in combination with FlexSlider Views Slideshow (which provides integration with Views Slideshow in case you already use that one).

Flex Slider module integrates the Flex Slider library with Drupal and allows you to build responsive and resizable slideshows. You'll find plenty of documentation on the project page to fit it to your needs.


How to get product name by id from commerce order?

A product is an entity, so you can use entity_load().

$product = entity_load('commerce_product', $product_id);
$title = $product->title;

Commerce provides its own shortcut, though:

$product = commerce_product_load($product_id);
$title = $product->title;


Invalid form POST data - ajax for Authenticated users

OK think I have it.

As form_form-ymw-BN0Zhp9j2CZf82mZzslbUBiLo8kZbreXhB1y8kE was not being set I looked at form_set_cache().

/**
 * Stores a form in the cache.
 */
function form_set_cache($form_build_id, $form, $form_state) {
  // 6 hours cache life time for forms should be plenty.
  $expire = 21600;

  // Cache form structure.
  if (isset($form)) {
    if ($GLOBALS['user']->uid) {
      $form['#cache_token'] = drupal_get_token();
    }
    cache_set('form_' . $form_build_id, $form, 'cache_form', REQUEST_TIME + $expire);
  }

  // Cache form state.
  if ($data = array_diff_key($form_state, array_flip(form_state_keys_no_cache()))) {
    cache_set('form_state_' . $form_build_id, $data, 'cache_form', REQUEST_TIME + $expire);
  }
}

I dug into cache_set()

function cache_set($cid, $data, $bin = 'cache', $expire = CACHE_PERMANENT) {
  return _cache_get_object($bin)->set($cid, $data, $expire);
}

I then looked into set()

  /**
   * Implements DrupalCacheInterface::set().
   */
  function set($cid, $data, $expire = CACHE_PERMANENT) {
    $fields = array(
      'serialized' => 0,
      'created' => REQUEST_TIME,
      'expire' => $expire,
    );
    if (!is_string($data)) {
      $fields['data'] = serialize($data);
      $fields['serialized'] = 1;
    }
    else {
      $fields['data'] = $data;
      $fields['serialized'] = 0;
    }

    try {
      db_merge($this->bin)
        ->key(array('cid' => $cid))
        ->fields($fields)
        ->execute();
    }
    catch (Exception $e) {
      // The database may not be available, so we'll ignore cache_set requests.
    }
  }

Here an exception is caught and not reported. I added a dd() into catch. Looking in drupal_debug.txt

[message:protected] => SQLSTATE[08S01]: Communication link failure: 1153 Got a packet bigger than 'max_allowed_packet' bytes

I have now increased the value of max_allowed_packet in MySQL. It has fixed things.

With this information I did some more googling and found this post. They have had the same problem that I had.


Creating a page.tpl.php template for a group of pages (Drupal 7)

If the pages www.yoursite.com/special, www.yoursite.com/special/anotherpage, etc are the actual paths to the content and not aliases, then page--special.tpl.php should work for all of them.  If, however, they are aliases to node content, eg, www.yoursite.com/special/anotherpage is really something like www.yoursite.com/node/123, then you could do something like this in your theme's template.php file...

function YOURTHEME_preprocess_page(&$vars) {

  $alias=drupal_get_path_alias($_GET['q']);
  $args=explode('/', $alias);
  if ($args[0]=='special') {
    $vars['theme_hook_suggestions'][] = 'page__special';
  }

  // any other page preprocessing here

}

...which takes a dull ax to the url and chops it apart and if the first part is special then it tells drupal to use your page template for it.  If, however, you know that all of the nodes there are of a certain type, you could do it this way instead...

function YOURTHEME_preprocess_page(&$vars) {

  if (!empty($vars['node']->type) && $vars['node']->type == 'SPECIAL_TYPE') {
    $vars['theme_hook_suggestions'][] = 'page__special';
  }

  // any other page preprocessing here

}

...which would tell drupal to use your template file whenever it displays a SPECIAL_TYPE node on a full page.


custom private message block generates error

In this case, the problem is that privatemsg_get_link() uses array() as default value for $account, but then uses the following code.

  if ($account == NULL) {
    global $user;
    $account = $user;
  }

The function should use NULL as default value for $account, in the same way user_access() does.

function user_access($string, $account = NULL) {
  global $user;

  if (!isset($account)) {
    $account = $user;
  }

  // ...
}

The error message you see is because the function tries to access $account->uid when $account is an empty array. An array doesn't have properties, and that is what the message is saying.
As the function is passing that value to user_access(), the same error would be raised from user_access(), which check the value of $account->uid, and for which an empty array is not the correct value to pass to its $account parameter, which requires an user object, or NULL.

It's fine to use the default values a function has, but you should check what the function does when it gets the default values for its parameters.

It is wrong to call a function as privatemsg_get_link($recipients, $account = array(), $subject = NULL) when you want to use the default values for its parameters. Just call the function as privatemsg_get_link($recipients). With your code, you are setting $account to an empty array, and passing $account as parameter.
PHP doesn't have named parameters, but only positional parameters. If it had named parameters, it would be possible to call a function indifferently as functioname(34, param3 = 4, param2 = 12), or functioname(34, param2 = 12, param3 = 4).


How to get rid of 'security updates available' warnings?

I had a similar problem recently (see How do I avoid checking for updates for a specific module?) and managed to get around it using hook_update_projects_alter(). You can use it to easily remove any module that you don't want to be part of the update process:

function MYMODULE_update_projects_alter(&$projects) {
  $blacklist = array(
    'sharethis',
    // Any others you might want
  );

  foreach ($blacklist as $module) {
    unset($projects[$module]);
  }
}

As Drupal no longer considers any module you put in the $blacklist array as one that needs to be updated, you should stop getting the security warning.

It would probably be a good idea to keep an eye on the progress of the bug in the ShareThis module so that you can remove this restriction when possible.


How to prevent a field from wrapping in Views?

With css you could set a specific width or use white-space:nowrap. I don't know how to do it other than with css or javascript


Best practice for node comparison for more than 2000 nodes

I do not know of a query execution time limit, so I will assume you meant php's max execution time.

If the clone search does not need to be instantly updated, a good approach would be to run the query on cron and cache the results, which means running a single query to fetch the data, process it, and save the results for a quicker fetching at a later time. Cron disables the execution time limit and will run indefinitely in the background.

If the site's cron runs once a day, the clone search results will be up to a day old.

Some resources to give some direction:

hook_cron - do your processing in this hook
Cache API - set and get cache data


In your view under "advanced", next to "query settings" click "settings" and check "Distinct". This option makes sure every node only gets displayed once.


How do I get the plain text value for the {{ label }} field in a twig node template?

You can get the unformatted title from the node object:

{{ node.label  }}


How do I programmatically delete a reference field value?

Maybe something like this could help you out

// Get the list of the associated classrooms ...
$classrooms = $node->get('field_classrooms')->getValue();
// ... if there are any associated classrooms ...
if(!empty($classrooms)) {
  foreach($classrooms as $classroom) {
    // ... get the key of the classroom
    $key = array_search(current($classroom), array_column($classrooms, key($classroom)));
    // ... remove the relationship ...
    $node->get('field_classrooms')->removeItem($key);
  }
  // ... and save the node.
  $node->save();
}

If you want to remove a single classroom from the list and you already know the tid

private function removeClassroomFromNode($node, $tid) {
  if(null != $node) {
    // ... get the list of associated classrooms
    $classrooms = $node->get('field_classrooms')->getValue();
    // ... get the key of the classroom
    $key = array_search($tid, array_column($classrooms, 'target_id'));
    // ... remove the classroom
    $node->get('field_classrooms')->removeItem($key);
    // ... save the node.
    $node->save();
  }
}


Is it possible to use jQuery's modal dialog instead of the browser-standard alert when using ajax_command_alert()?

I solved this problem in two ways - first, I added my own JS file which adds a modal option to Drupal's AJAX commands with the following JS code:

jQuery(function() {

    // Add modal dialog option to Drupal AJAX
    Drupal.ajax.prototype.commands.modal = function(ajax, response, status) {
        // Code to create a modal dialog goes here
    }

});

Then, in my AJAX callback on the server, I used the following code:

function feedback_form_submit($form, &$form_state) {
    return array(
        '#type' => 'ajax',
        '#commands' => array(
            array(
                'command' => 'modal',
                'text' => "Form submission successful!"
            )
        )
    );
}


I think your question is that you want to put inline javascript in twig templates, but it does not work, because jquery is not loaded yet?

You can override the default that the libraries are loaded in the footer and put jquery and any of your own js in the header:

mytheme.libraries.yml:

mylibrary:
  version: 1.x
  header: true
  js:
    js/myjavascript.js: {}
  dependencies:
    - core/jquery

mytheme.info.yml:

libraries:
  - mytheme/mylibrary

The important part is header: true.

If you make a dependency on core/jquery for the header, jquery is not loaded a second time in the footer, even if there are multiple dependencies for core/jquery by other libraries.

Now you can put your jquery dependend js code in the header (in this example in myjavascript.js) or put inline js in twig templates.


View ignores unchecked "require this relationship"

I was able to solve this by changing which field I wanted from the reference node. I was originally trying to get the path, but I switched it to "Link to Content." Still, it's odd that when trying to get just the path, views suddenly requires the relationship.


Get form values into hook_node_insert / hook_node_update

Use an entity builder callback on the form, for example:

function menu_ui_form_node_form_alter(&$form, FormStateInterface $form_state) {
  // ...
  $form['#entity_builders'][] = 'menu_ui_node_builder';
}

/**
 * Entity form builder to add the menu information to the node.
 */
function menu_ui_node_builder($entity_type, NodeInterface $entity, &$form, FormStateInterface $form_state) {
  $entity->menu = $form_state->getValue('menu');
}


How To Embed a video in a body field like facebook does

If I understand you correctly I think that you can use the Video Filter module.

Video Filter allows you to put something like this in the body:

[video:http://www.youtube.com/watch?v=PCLx4fRHmCk]

Here you can see a post about this module:

How to Embed Videos using Video Filter in Drupal 7


Toggle text field depending on checkbox value in drupal 6

You could do something along these lines:

$('#CHKBOX').click( function() {

  if ($('#CHKBOX').is(':checked')) {
    $('#CHKTEXT').display();
  } else {
    $('#CHKTEXT').hide();
  }

});

where CHKBOX and CHKTEXT are the CSS ids of the form elements in the resulting HTML.  If you know it will be hidden at the start, this can be simplified further into:

$('#CHKBOX').click( function() {
  $('#CHKTEXT').toggle();
});


How to add a function to web form submit button?

Your mileage will vary, but it's the same as adding submit handlers to any form:

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'foo') {
    $form['actions']['submit']['#submit'][] = 'MYMODULE_some_function';
  }
}

function MYMODULE_some_function($form, &$form_state) {
  // Do something...
}

See hook_form_alter() for full details.


Ok, just found the problem.

I was using this select:

$query = $this->getConnection()->select('j3_k2_items', 'n')
  ->fields('n', array('id', 'title', 'fulltext'))
  ->condition('catid', array(43, 45, 46, 51, 68, 72, 109, 117),'IN');

but the array inside the fields was the problem. When I removed it:

$query = $this->getConnection()->select('j3_k2_items', 'n')
  ->fields('n')
  ->condition('catid', array(43, 45, 46, 51, 68, 72, 109, 117),'IN');

Which was the same as doing a "SELECT *" the error gone and the migration worked!


How to limit access to certain users for those who have "administer users" permission

The administer users permission is a VERY powerful permission and you shouldn't give this permission anyone that you don't trust. Otherwise, the users with that permission can do all nasty things. For example:

They can manage fields on user accounts at admin/config/people/accounts/fields
They can manage permissions and grant/revoke users including themselves other permissions at admin/people/permissions
They can add/cancel/edit users including admins!

Conclusion: Never, ever give this permission to ANYONE!

There are a few modules that let users granularly administer other users. One of them is the Administer Users by Role. Although, its latest version for Drupal 7 requires to give this mighty permission to the users, but there's a patch, which I also contributed, at this issue page. With this patch, you don't need to give 'administer users' permission to the users and still allow them to administer other users.

There are also other related modules, but I cannot tell anything about them since I don't use them:

Subuser

  This module allows users to be given the permission to create subusers. The subusers may then be automatically assigned a role or roles. The parent of the subusers then has the ability to manager the users they have created.

Role Delegation

  This module allows site administrators to grant some roles the authority to assign selected roles to users, without them needing the administer permissions permission.


Can't get neither CKEditor nor WYSIGYG Module to work!

Go to /admin/config/content/formats and make sure you have a text format for the role(s) you are working with.
Go to /admin/config/content/wysiwyg and make sure you have added buttons to the editor (click on "Edit" and then under Buttons & Plugins).


Mark only event's start date and end date in event calender

If you're using FullCalendar to dispaly the calendar, you need to register two separate events:

Exhibit opening: Wild & Wonderful (starts end ends on the 5th).
Exhibit closing: Wild & Wonderful (starts end ends on the 17th).

Now, the opening and closing event will appear independent of each other,


Remove attribute ID from site-logo (Panels Page Elements)

This logo is created in ctools_page_logo_content_type_render function. Unfortunately we can't alter code of this function.
As a solution you may create your custom Ctools content type plugin, that will return logo without 'id' attribute. You can find more information about Ctools plugins here.


Adding a 'Add New Listing' (Create Content) Link on Local Tasks Menu

Add a forward slash at the beginning:

Add New Listing


My 960 grid system has wider columns that standard. 55px instead 40px for 16 columns

On wide screens, Omega (or in fact: its base theme 'Alpha') will switch to the wide lay-out. You will find the css for it in alpha/css/grid/alpha_default/wide/alpha-default-wide-16.css and alpha/css/grid/alpha_default/wide/alpha-default-wide-12.css.

This responsive behavior can be controlled from the Omega theme settings page.


How to remove duplicate terms in a vocabulary

The Term Merge module could help you.

  When using taxonomy for free tagging purposes, it's easy to end up with several terms having the same meaning. This may be due to spelling errors, or different users simply making up synonymous terms as they go.

  You, as an administrator, may then want to correct such errors or unify synonymous terms, thereby pruning the taxonomy to a more manageable set. This module allows you to merge multiple terms into one, while updating all fields referring to those terms to refer to the replacement term instead.


Disable registration on commerce checkout

Per Bojan's comments, leave "Allow guest checkout" checked and disable the "Guest registration after checkout" pane. We may need to update the documentation a little, but doing these things and then configuring your general Drupal settings to deny user account registration will leave you with a site that no one can ever register against and anonymous users can still checkout on.

(The fact that you don't see the checkbox to "Allow registration" in the "Login or continue as guest" checkout pane configuration is irrelevant, because it's disabled by default. You don't need access to it in order to disable the ability for guests to register prior to checkout.)

If you don't need this intermediate step at all, you can simply disable the checkout pane and the page will be skipped for all customers.


How do I make a theme require Jquery (for anonymous users)?

I ran in to this upgrading one of my contrib themes to Drupal 8 as I wanted jquery.once for anonymous users. Here is what I did which works great:

In herchel.libraries.yml

herchel-corescripts:
  version: VERSION
  js:
    js/scripts.js: {}
  dependencies:
    - core/jquery
    - core/drupal.ajax
    - core/drupal
    - core/drupalSettings
    - core/jquery.once

Then in your theme's herchel.theme file.

function herchel_preprocess_page(&$vars, $hook) {
  // Render the library as laid out in herchel.libraries.yml
  $libraries['#attached']['library'][] = 'herchel/herchel-corescripts';
  \Drupal::service('renderer')->renderRoot($libraries);
}

Pay mind to the indenting as well for the YML code. Though it's not really documented that well yet, you can have a look at this issue and its change log.

Replace hook_library_info() by *.libraries.yml file

Note that you also see a theoretical theme's "scripts.js" file in the code above but you may not need it. In my theme, that's what uses jquery to call custom code.

This code is probably a good reference too for the YML bits. Note that in both cases version is at the same level as dependencies.

I also made a list of Drupal 8 issues I encountered and took part in with my D8 upgrade.

Update:

I've fixed the code, we ran in to this issue: Replace #attached library array values with provider-namespaced strings

Note this:

 $libraries['#attached']['library'][] = array('herchel', 'herchel-corescripts');

vs.this

$libraries['#attached']['library'][] = 'herchel/herchel-corescripts';

I tested and the errors went away. :)


D7 - Rules System Page Redirect not working at all?

First things first: a page redirect from "current page" to "current page" is what seems to be your very last Rules Action, is that what you actually want? If that's not your issue, then read on about a possible approach to find out what else might be wrong.

Basic debugging

Rules is great, but sometimes also tough to debug if things don't work as you'd expect. There are some typical facilities to do such debugging, but my Keep-It-Super-Simple technique I often use is my BINGO-trick. A sample of such rule can be found in my answer to "Which Rules condition can be used to email a user when an admin updates their profile?". Stupid, but simple and efficient (I think).

Also, since you have 2 Rules Conditions in a single rule (both must be satisfied for your Rules Actions to execute), you should try to see what happens (if you get a "bingo") for each of the individual Rules Conditions. This by simply (temporary) removing 1 out of the 2 Rules Conditions you are using, and verify if they each result in the Rules Action you'd expect (also just a simple Bingo-message should be sufficient).

Advanced debugging

Something else that will help you find the answer to your question, is to have a look at Rules debugging ... Within the Rules settings, experiment a bit with the debugging facilities that come with the rules module. At least have a look at the "Rules Evaluation Log" (to check that the Rules logic being executed, actually matches what you expect that logic to be).

Depending on what the result of that type of debugging is, you may also want to (temporary) enable the Devel module, so that you can (temporary) add a Rules Action like "Display a value" (in your case of your node:comments).

For way more details about these 2 variations, refer to Rules debugging, as explained in the answer to "How can I display the value of a variable inside a condition?".


How can you allow an unregistered user to change languages?

If it's just the interface you'd like to translate, then I think you can get by with Locale (a core module). If you want content translation (and many other things) you can use i18n. The project page for i18n gives you plenty of links to follow for other projects and documentation.


How to hide certain fields to a user if they aren't referenced in a field on the node?

business logic never in tpl.

You could use hook_node_view($node, $view_mode, $langcode).

In my opinion the cleanest and the most drupal way would be to create a custom formatter (mymodule_field_formatter_info) in which you should pass
the returned value (1 or 0) of your business logic to the #access property of the field

Regards.


MathJax(LaTex) equation shows in the CKeditor body area but not on the final webpage?

Check Manage Display in your content type and ensure it's using the proper text format. I think Mathjax has to be at the bottom of the list as well in the format settings.


Using groupby in hook_views_query_alter()

"Group By" is not working on hook_views_query_alter and it is views module issue. that is reported at https://drupal.org/node/590534, http://drupal.org/node/1608742, http://drupal.org/node/389230#comment-2637200

So, You should use other hooks such as general hook_query_alter.

function hook_query_alter( &$query) {

  if($query->alterMetaData['view']->name == "your_views_name"){
     $query->groupBy("domain_source.domain_id");
     //also you can unset other group by critera by using, unset($query->getGroupBy());
  }
}


Custom template for content type, How to print a link field as a hyperlinked image

It's easier and more practical apply a preproccess hook:

Function YOUR_THEME_proprocces_node__artist(&$vars){

 // $vars contain the fields to be renderable in content attribute

}

I resolved a similar question a few days ago: change links read more and add comment

Inside of array tree $vars['content], you will have to change the title attribute adding the html mark you want.

If you have a problem to find the tree or change the array, print the array with the dpm($vars) in your code and capture an screenshot to publish here.


When using the workbench core module, how can one assign a node to a new author and it show up in their list of content?

Workbench uses Views to render it's data. The trick - whilst new user is now considered author of a node, last edit was not his. So it will not be seen in "my edits".

Go to http://example.com/admin/structure/views/view/workbench_edited/edit.
You will see:

This filters by revision's author. Not what you want. What you need is to filter by node's user.  But this view does not have a relationship to content author:

Add missing relationship:

Filter is still using wrong relationship:

Make it use proper one:

Done. Repeat for other views as needed.


Per entity settings storage (configuration / state / field)

Core provides a storage/API to store per-user information: the user.data service. It also provides a very simple example implementation in the Contact module: See contact_form_user_form_alter() and contact_user_profile_form_submit().

\Drupal::service('user.data')->set('contact', $account->id(), 'enabled', (int) $form_state->getValue('contact'));
$account_data = \Drupal::service('user.data')->get('contact', $account->id(), 'enabled');


Duplicate breadcrumbs but they're not in the $breadcrumb variable?

This was an easy one: turn off custom breadcrumb modules...


Field definition in custom field and varchar_ascii

The doc block of database.api.php/Schema API state:

  A special varchar_ascii type is also available for limiting machine name field to US ASCII characters.

You can see its implementation in Schema::createFieldSql() of the MySQL abstraction layer.

So yes, it changes the default UTF-8 character set/collation to ASCII.


How to force a JS library to be loaded via HTTPS?

That's a protocol relative include, meaning it will take the current protocol and use that. If you access via http, that's what you would get. Is the site being tested under https? Is something removing the protocols (advagg?)?
Modules like advanced aggregation have settings to remove protocol and make all links protocol relative. Disable settings like that and run the tests again.


Alter a custom block depending on custom block type

Try hook_ENTITY_TYPE_view()/hook_ENTITY_TYPE_view_alter(), that gives you the block_content $entity as an argument, just like hook_node_view().


Use "date_views_filter_handler" filter handler for custom table field

I will not say this answer the question I asked but must say this answer worked the way I want.

Instead of using "date_views_filter_handler" I used "date_views_filter_handler_simple" and it just worked like a charm.Here is what I did while exposing my custom table to views.

  $data['jh_report']['date_of_purchase'] = array(
    'title' => t('Date of purchase'),
    'help' => t('Date of last purchase for current month'),
    'field' => array(
      'handler' => 'views_handler_field_date',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort_date',
    ),
    'filter' => array(
      'handler' => 'date_views_filter_handler_simple',
    ),
  );


Installed Boost Caching, but now my dynamic blocks and webforms are also cached

It seems you  check Cache blocks(block caching) in config/development/performance.
Try to uncheck that. When you work with Boosts it is not require use that feature.


Fetching Views 3 implementation from code

There are quite some different ways to achieve this

Use the ctools bulk export module, this will provide you some example code to use
use the features module, which gives you a full module


is there a way to know witch module is responsible to programmatically alter a view's query?

Interesting question / challenge, not obvious to debug ...
Here is what I would do, in the order specified:

Scan the entire modules directory for a string containing '1 = 0'.

Scan the Drupal database (all tables) for a string containing '1 = 0'.

If none of both scans lead to any results, I'd consider using the X-ray module, to check if that would help me any further. Some details about this module (from its project page):

X-ray module gives a look at the skeletal structure of a site to help developers and site builders see how things work.
X-ray Features:

A technical summary is added to the help above the main administrative sections. For example, blocks, content types, and menus are summarized on Structure; themes on Appearance; etc.
A table of permission titles matched to their permission machine names.
A table of most* hooks which Drupal invokes (and when they are invoked) and that are available to be implemented.
The function and arguments producing each page you visit, displayed on that page.
The form ID of every form you see, displayed on the form.


Are 'safe_value' values generated dynamically from the 'value' value?

Yes. safe_value is derived from value; safe_value contains the results of _text_sanitize() after it applies all the filters you've set on your text field.

It isn't set after a node save; it's set on a field load; the field module loads it via hook_field_load() with its text_field_load() invocation.


There are several modules that can accomplish this, eg Superfish and Nice Menus.

If you want to roll your own, the basic steps are

Edit you menu items (admin/structure/menu/manage/menu-foo-menu) so that they are always expanded.  This will result in all menu items always being available, instead of only available in the active/sibling hierarchy.
Write some CSS and JS to get the menu behavior that you want.  With the way the nested menus are built in Drupal, you should be able to achieve a CSS only solution.  You can either do this with a custom module, or add it to your theme.

The CSS and JS involved with this is beyond the scope of this site, but there are lots of resources on the net to help you out.


On the Views UI tick the Create a label checkbox and enter in your element name in the Label textfield. The value of Label will be used for the element name.


site returns 404 on every request, except /

Check to make sure that the directory containing Drupal on your server can read the contents of your .htaccess files (the AllowOverride directive in your httpd.conf controls what will be processed). In my experience, AllowOverride None set for that directory or a parent directory is the most common culprit  (remember: directives are inherited).


Render variables printed by {{ dump(user) }} in a template?

You can just get the user ID and when the account was created respectively with {{ user.id }} and {{ user.created }}. With {{ user.created | date("d F Y") }} you print the timestamp with the date format you specify.

Consider user as an object. You can access all the values the same way.

See also the Twig documentation.


Pre-populate Commerce Shipping Cart using a link

You could use Rules for triggering an event on your link with Rules link event and maybe combine it with Rules Link to attach the link to your commerce order entities.

If you prefer to code, you'd need either to create a new menu using hook_menu or alter an existing one with hook_menu_alter and then use commerce_cart_product_add or commerce_cart_product_add_by_id to add the product to the cart user, you can retrieve the current cart from the user with commerce_cart_order_load


Problems like this occur when you rely on JavaScript to hide things. It can take some hundred ms before it happens making the items appear upon page load.

A way to solve this, would be to use CSS to hide the expanded menu when the page is loading and once the JavaScript has been run, remove the effect of the CSS.

The easiest way to do that is by adding a class on the HTML produced, that is required in the CSS rule, and remove the class with JavaScript on page load. You could add a class to the body in the preprocess_page hook and remove it again in one of your theme's JS files.


Keep URL the same after changing page title

You can set the default at /admin/config/search/path/settings. Under 'Update Action' choose 'Do nothing. Leave the old alias intact.'


user hook node update to attach files to a node?

The field data has already been committed by the time hook_node_update() is called, so you won't be able to make any persistent alterations to field data in there.

Instead you could use hook_node_presave(), which is run before any data is written to the backend.

function mymodule_node_presave($node) {
  // Build up file object

  // Then add it to the node.
  $node->field_files[$node->language][] = (array)$file;
}


Migrating a field collection with a field that has multiple values

The only way around the issue I could find was to remove the map of D6 node reference field to the D7 entity reference field.  Instead I set a default value to 1 so that it appears on the field collection in the prepare function, and I then repopulate it with a secondary query there.  This solution was not ideal for me, but due to time constraints I was forced to go with this way.  Hopefully someone can find a real solution to the issue.

One more issue I found while attempting to debug this behavior was that rolling back this field collection migration did not delete the field collections.  It only reset the map messages and numbers of processed rows.  To delete the field collections entirely I had to roll back the migration of the nodes they were on as well: drush migrate-rollback City && drush migrate-rollback FCMapList

class FCMapList extends myFieldCollectionMigration {
  public function __construct(array $arguments) {
    parent::__construct($arguments);

    $this->description = t('Field Collection: Map List Nodes');

    $dependencies = array(
      'VenueProfilePage',
      'City',
    );

    $this->dependencies = $dependencies;

    $query = Database::getConnection('mig_dest', 'legacy')
      ->select('content_type_map_list', 'ml')
      ->fields('ml', array('nid', 'field_link_title_value', 'field_link_subtitle_value'));
    $query->join('content_field_lists', 'l', 'l.field_lists_nid=ml.nid');
    $query->fields('l', array('nid'));
    $query->isNotNull('ml.nid');
    $query->isNotNull('l.field_lists_nid');

    $this->source = new MigrateSourceSQL($query);

    $this->destination = new MigrateDestinationFieldCollection('field_city_map_list', array('host_entity_type' => 'node'));

    $this->addFieldMapping('host_entity_id', 'l_nid')
         ->sourceMigration('City');
    $this->addFieldMapping('field_list_title', 'field_link_title_value');
    $this->addFieldMapping('field_venues')
     ->defaultValue(1);

    $source_key = array(
      'nid' => array(
        'type' => 'int',
        'description' => 'List content ID',
        'alias' => 'ml'
      )
    );

    $this->map = new MigrateSQLMap($this->machineName, $source_key, MigrateDestinationFieldCollection::getKeySchema());

     }

  public function prepare($field_collection, stdClass $row) {
    $legacy_list_nid = $row->nid;

    $venues_query = Database::getConnection('mig_dest', 'legacy')
      ->select('content_field_venues', 'v')
      ->fields('v', array('delta', 'field_venues_nid'))
      ->condition('v.nid', $legacy_list_nid, '=');
    $venues_query->orderBy('v.delta', 'ASC');
    $venues_query->orderBy('v.nid', 'ASC');
    $venues_query->isNotNull('v.field_venues_nid');
    $result = $venues_query->execute();

    while ($record = $result->fetchAssoc()) {
      $venue_delta = $record['delta'];
      $legacy_venue_nid = $record['field_venues_nid'];

      db_set_active();
      $venue_nid_query = Database::getConnection('mig_dest', 'default')
        ->select('migrate_map_venueprofilepage', 'mv')
        ->fields('mv', array('destid1'))
        ->condition('mv.sourceid1', $legacy_venue_nid, '=');
      $venue_result = $venue_nid_query->execute();
      $venue_nid = $venue_result->fetchField();

      if (is_array($venue_nid)) {
        $venue_nid = $venue_nid[0];
      }
      if (strlen($venue_nid) > 0) {
        $field_collection->field_venues['und'][$venue_delta]['target_id'] = (string)$venue_nid;
      }

    }

  }

}


Enable clean urls drupal 7.56 / nginx - check failed

You are missing some configuration for clean URLs. Try adding this snippet above the location @rewrite snippet.

 location / {
    try_files $uri /index.php?$query_string; # For Drupal >= 7
 }


Taxonomy in Contextual filters for Views

I cloned the existing default view for taxonomy/term/%, removed all the contextual filter already existing, and then:

I added a new relationship, "Content: Taxonomy terms on node."
I added a new context filter, "Taxonomy vocabulary: Machine name," for which I didn't change any setting. (The Views module already selected the relationship I defined before.)
I added a new context filter, "Taxonomy term: Term ID."

For the "Taxonomy term: Term ID" filter I used the following settings.

I changed the path for the view to "test-term/%" and removed the feed.

The setting page for the view, once done the changes I described, appears as in the following screenshot; I highlighted the parts that are different from the setting page for the view I cloned.

What I obtained is a view that shows the nodes containing the terms from the vocabulary for which I pass the machine name as first argument.

For http://tero.local/dr71/test-term/tags ("tags" is the machine name for a vocabulary I defined in my test site), I get the following result.

For http://tero.local/dr71/test-term/tags/tags (the second "tags" string is the name of a taxonomy term that the "tags" vocabulary has), I get the following.

I didn't find any way to filter out the duplicates that appear in the first case, though. This is would happen only for those vocabulary that allows the users to select more than one term per node.

The relationship with the taxonomy terms is necessary as the view is about nodes; without the relationship, it would not be possible to use "Taxonomy vocabulary: Machine name," and "Taxonomy term: Term ID" as contextual filters. You can check it: If you remove that relationship, you will not able to add them as contextual filters.


How do I alter a boolean value and display a string in views output?

Well, that was a lot easier than I thought. Basically took a gander into node.views.inc and got the answer.

function MYMODULE_views_data_alter(&$data) {
  $data['MYENTITY']['MYFIELD'] = array(
    'title' => t('MYFIELD'),
    'field' => array(
      'handler' => 'views_handler_field_boolean',
      'click sortable' => TRUE,
      'output formats' => array(
        'drunk-sober' => array(t('Drunk'), t('Sober')),
      ),
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_boolean_operator',
      'label' => t('MYFIELD'),
      'type' => 'yes-no',
      'use equal' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );
}


Unfortunately, MAMP (even the Pro version) basically provides no support for G-mail.  For evidence, look at the comments on the official guide on the MAMP blog.

Although I haven't tried it, one of the comments suggests this solution.

And here's another way to set up postfix on Lion without relying on MAMP.

I too use MAMP, and instead of working with mailhandler I use the SMTP module instead, which allows Drupal to send messages locally independent of the local mail configuration.


Display field's label only when any value added to it

almost you did , instead of content.FIELD_MACHINENAME use node.FIELD_MACHINENAME.value
I mean try something like

{% if node.field_tag.value %}
{{ content.field_tag }}
{% endif %}

for make sure that this solution work correctly(for debug) try {{ kint(node.field_tag }}.


how to block a user from publishing a node in drupal 7

There is workflow module which suits your requirement.

  The workflow module allows the creation and assignment of arbitrary workflows to Drupal node types. Workflows are made up of workflow states. For example, a workflow with the states Draft, Review, and Published could be assigned to the Story node type.


Disable the message shown when a node is created

It's node_form_submit that is creating those messages. You could pretty easily use hook_form_alter on the node form and use your own version of node_form_submit instead. All you would need to do, would be to copy the function and add an user_access('whatever') check before that message is created.

Alternatively, you could in preprocess_page function, check which messages is being served, and remove unwanted ones, but that would be a bit more tricky. Should be possible with some regex. On the other hand, this method would be a bit more upgrade friendly, since you could remain using the node_form_submit function and would get future changes if any.


How to get id of selected entity in an "entity_autocomplete" form element?

Seemingly I managed to find the solution.

The event for the autocomplete element should be "autocompleteclose" instead "autocompleteselect".
And in this case it's possible to get entity_id via

$entity_id = $form_state->getValue('autocomplete_places');

if the list of values was closed without selected element then $form_state->getValue('autocomplete_places') is null.


How can I find a list of fields output by a view block?

You're using the 'row style' type 'fields' here, correct? The field you are grouping on should also be added as a field in your 'fields' list in order for this to be showing correctly in your preview so all you need to do is find the name, which can be tricky to guess depending on the cck field type. One way you can do this is by hovering over the 'link' in the fields editor within views:

and get the name of the field from the url in your browser status bar, ex.

../view_name/display/field/<your field name>

and then you just print out the rendered view content of your field in your tpl with:

<?php print $fields['<your_field_name>']->content; ?>


duplicate search field appearing with just one block

It's probably a css problem.

My guess is the search bar is using a background image. The image contains both the inactive search background and the active search background. It's a good thing to avoid to load 2 different images.
If you want this to work, you need to ensure that the search box has a fixed height.

So in the css, you should have something like :

#edit-search-block-form--2 {
  height: 10px;   /* 10px => replace this with the real height */
}


Rules: Copying field from user's account to field in content type

I think you need to add some more stuff in that Rule; namely, following from your explanation, you need to:

"Create a new entity": Create a new node in an action, before the image-copying action. This new entity is a Gallery-type node.
Use the "entity_created" variable as the destination entity.

That should be enough to accomplish your goal, hope this helped some!

Appendix A: An export of such a Rule that worked.

{ "rules_196457" : {
    "LABEL" : "196457",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "file_rules" ],
    "ON" : { "user_update" : [] },
    "IF" : [
      { "NOT data_is_empty" : { "data" : [ "account:field-user-image:file" ] } },
      { "NOT data_is" : {
          "data" : [ "account:field-user-image:file" ],
          "value" : [ "account-unchanged:field-user-image:file" ]
        }
      }
    ],
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "node",
            "param_type" : "article",
            "param_title" : "New pic for [account:name] | [site:current-date]",
            "param_author" : [ "account" ]
          },
          "PROVIDE" : { "entity_created" : { "new_article" : "Created entity" } }
        }
      },
      { "file_rules_copy_file" : {
          "source_entity" : [ "account" ],
          "source_field" : "field_user_image",
          "destination_entity" : [ "new-article" ],
          "destination_field" : "field_image",
          "remove_source" : "0"
        }
      },
      { "drupal_message" : { "message" : "A new Article has been created with the new user\u0027s image" } }
    ]
  }
}

Appendix B: An screenshot of the Rules UI


How to show/hide fields based on visitor's country?

You can make use of Geo Ip to do this. Install Geo Ip by following the instruction mentioned in the link http://www.beginninglinux.com/home/php/ubuntu-php-5-geo-ip

Make use drupal ip_address() function to get user ip address.

function test() {
  $code = geoip_country_code_by_name($ip);
  if ($code == 'US') {
    //hide  field B
  }
  else {
    //hide field A
  }

}

geoip_country_code_by_name returns country code. I think this approach gives you solution.


Putting subsites outside of the sites directory

The location of subsites is hard-wired in function conf_path().


"Uncaught TypeError: Cannot read property 'getAttribute' of undefined"

The problem is in panels module, upgrade to latest version to fix the issue.
For more details see https://www.drupal.org/node/2713123


How to do a lookup of existing nodes in the input form?

R3: You don't need to write any code :-)

R1: The relations are managed with the field Reference by content (provided by core) take a look inside the Add a reference field to content type
section in How To Reference Nodes in Drupal 8 + Views Relationships Display

Then you can go to configure your content type display mode and form display mode to change the widget if you want another different from the default widget. See Exploring the New Drupal 8 Display Modes and How "form modes" work in Drupal 8 and how to add and edit them

R2: You can have 1000 books without problem, in this case I recomend to use the autocomplete widget.

If you want to add more functionalities to your relation you can use the following modules:

Entity Reference Views Select

  A module for those who need their Entity Reference Views fields to be
  displayed as a select list, checkboxes or radio buttons in forms.

Inline Entity Form

  Provides a widget for inline management (creation, modification,
  removal) of referenced entities. The primary use case is the parent ->
  children one (product display -> products, order -> line items, etc.),
  where the child entities are never managed outside the parent form.
  Existing entities can also be referenced.


Drush downloading to an old version of Drupal

Drush is path-sensitive and can be installed system-wide; no need to install a separate instance.

To run Drush commands in the context of a site, you need to be in the web root of that site.

cd /path/to/mamp/drupal_root;
drush cc all; // Clears cache for the current site only

If you run commands outside of a Drupal root, the effects will vary. Modules will be downloaded to the current folder, cache-clear will clear Drush's internal cache, and some commands simply won't work as they don't make sense without a Drupal boostrap.


How do I maintain aspect ratio of scaled image with max-width?

It's as simple as just adding height:auto;

img {
max-width:100%;
height:auto;
}


When to use a Webform vs. simply utilizing the Add Content page

I think Webforms is usually more appropriate when the entered data is intended to be used by the organization behind the website and never shown to the public.

Webforms is also useful to send the entered data by email to who should receive it. You could also do this with a content type but you would require some kind of Workflow or trigger and action which might end up being "heavier" to the server

If you intend visitors / end users  (authenticated or not)  to see the data entered by others users then you just make a content type and use the add content form.


What is the difference between t() and l()?

The l() function is primarily for links. It takes the parameters of $text, $path, array $options = array() to properly translate links. It also returns a HTML string containing a link to the given path.

It's use looks something like this:

<?php
  l(t('Link text'), 'about-us', array('attributes' => array('class' => array('about-link'))));
?>

Another note is it looks as though it's going away in D8, as it currently has no entry in the APIs for 8. Instead, Drupal 8 will use the class:link like so:

$link = Link::fromTextAndUrl($text, $url);

t() is much more general and is used to translate strings. It also takes a different set of arguments ($string, array $args = array(), array $options = array()).


saving JS settings in theme_settings.php file

I think you problem is this: drupal_add_js needs to be called at runtime. It's not some kind of registry function that adds your js file for every future page request. In other words, your code only adds the js when the form is being submitted.

Instead of calling drupal_add_js in your submit handler, store a variable using variable_set() to indicate that the js must be added. In your template.php file you can use the _preprocess_page function to retrieve the setting using variable_get() and call drupal_add_js if needed.


Hide single menu item from users without a specific role (without 3rd party module)

Use hook_menu_item_link to alter menu items. See below example:

function mytheme_menu_item_link( $link ) {
  if( $link[ 'title' ] == 'My Account') {
    return '';
  }
}


Granting access based on an entity reference field using rules

This should do the trick for you. You only have to write the code for extract_uid_from_audit(); if you don't know how we can help as well.

function mymodule_node_access($node, $op, $account) {
    if(!empty($node->type) && ($node->type == "non_conformance")
             && $op=='update') ){
        $uid = extract_uid_from_audit($node);
        if($uid = $account->uid)
             return NODE_ACCESS_ALLOW;
    }
}


How can I create a custom page with a different template?

You can use a different template for a page by suggesting a new template file that will be used.

This can be done in a theme, by writing its template_preprocess_page(), or in a module by implementing hook_preprocess_page().

function template_preprocess_page(&$variables) {
  if (arg(0) == "node" && arg(1) == "1") {
    array_unshift($variables['theme_hook_suggestions'], "page--custom-template");
  }
}

This code is for Drupal 7; for Drupal 6 you need to replace $variables['theme_hook_suggestions'] with $variables['template_files']. In the case you are using it in a module, template_preprocess_page() needs to be renamed mymodule_preprocess_page(), where "mymodule" is the short name of your module.
Instead of using arg() you can also use request_uri(), but the output returned from this function is similar to "/dr72/devel/php?render=overlay&render=overlay" when Drupal is installed in a subdirectory of the web server's root directory. request_uri() doesn't change an alias into the canonical path; supposing that example.com/node-1-title is an alias for example.com/node/1, in my test site, the function will return "/dr72/node-1-title" while arg(0) and arg(1) would return, respectively, "node" and "1" (the first two elements of the path).


You must disable ajax on both blocks, in the view advanced options.

In the pager settings of each block you must be sure that both blocks are using the same pager ID.

As both blocks are using the same pager ID, and the page is sent through the URL (not ajax), each block will asume that that is the page it has to show.


Apply a promition only on a product variation

You need to implement you own promotion condition plugin. Theres a condition plugin defined in commerce_product module in Commerce module since 2.0 release but I recommend you to use latest stable release. Check this class Drupal\commerce_product\Plugin\Commerce\Condition\OrderItemVariationType thus it only checks for variation type (aka bundle), you can easily write your own checking specific product variation instance. Also worth checking OrderItemProduct condition plugin I think you need a mix from both. This plugin is located in the same namespace than the first one.

Update

There's a feature request for that see this link. Thanks to @bojanz!


How to migrate core profile fields into the new profile fields in D7?

A good solution might be to use Feeds module (to import to fields) and Views Data Export Module (to export fields to the spreadsheet). The procedure would be:

  Setup a view that lists all of your users and displays all of the
  fields you want to migrate. Then add news display (data export) and
  choose CSV format.

  Use feeds to import the data to D7. Just map each exported field to a
  new field.

  This might seem complicated at first, but it's really simple and
  should work.

Thanks for your reply, take2. Thought it would be good to post it here.


You aren't required to make changes directly to your live site, it is bad practice to do this for things other than minor content additions/changes.

You should have at a minimum a dev and production environment.  Your local environment would be dev obviously and there are many ways to sync the changes between dev and live.

If you have ssh access to your server, the best way would probably be to use drush to sync your changes between environments.  There is a good explanation of this method here.

If you don't go the drush route, you could always do it manually by dumping your local db / files and updating the live site.

There is a lot of information on the subject on this site, a good bit of info can be found here.


Disable specific view display in drupal 8 via database or programmatically

In D8 views are configuration.

If you can use the admin ui, go to /admin/config/development/configuration/single/export, choose Configuration Type View and the view you want to change, modify it and paste in the single import section.

If you can't access the admin ui, you can use drush:

drush cedit views.view.newsletters


How do I tear out the existing menu in a theme and replace it with super-fish (v7.x)

Superfish will not override your theme's main menu. The only way is to make its block and place it on some region.

You can replace the theme's menu variable/function with a region variable in your page.tpl.php following a guide here.


Processing data sent from drupal 7 webform

I am not clear about your question. But here is the answer from what i understood.

Try creating a new module and use the hooks to process the data
http://api.drupalize.me/api/drupal/group/webform_hooks/7


Field Relation Between Content Types and Some Questions

(1) The only way of not writing a custom script I can think of would be to use the Display Suite module. Out of the blue I would try the following.

Create a new display mode (besides content and teaser) for the actor content type. Call it something like "just image" or "photo only". It should be set to only display the image field.
Create a new display mode for the movie content type, maybe called "actors". It should only display the field collection and the name (reference field) should use the previously created display mode "just image".
Create a (views) block that shows the original node (Contextual Filter: Nid, default parameter in URL). Display type of that view should be Node and use the "actors" display mode.

What I would expect is to get a block that shows the actors' photos along with their characters' names.

(2) An easier way (if you are able to program Drupal modules) would be to write custom scripts. Also, this would allow you to fine-tune your output. I would create a custom module which creates the block you want by using the _block hooks to define the available blocks and their contents.

(3) Another way of accomplishing what you want would be to restructure your website's architecture. This might not be suitable for you if you already have a lot of entries. Instead of field collections you would then use an additional content type (character). Character would then have relationships with both movies and actors.


Webform module issue - content type not displaying

Drupal can act funny when you start deleting things and then trying to reinstall them. Do you have access to your database?

If so uninstall webform and delete it - then head into your database and delete any webform tables that might still be hanging around.

Dont even try this without backing up your database first though incase you happen to delete anything important.

Then re-install webform.

This is a pretty drastic step and you will lose all data surrounding your webforms.

I have had to do this with other modules that have left tables behind when uninstalled and then they mess when reinstalling said modules.

Once again though if you take this route be careful what you delete.


a way to do something like you are talking about is creating one panel page with panels variants and showing each one depending on selection rules.

Regards.


How to disable Rich Text Editor in image field caption ?

You used to be able to configure CKEditor to appear on a per-textfield basis, but apparently that's no longer possible in the 7.x-1.x versions of the CKEditor module.

The following issue offers a JS workaround:

https://drupal.org/comment/5601364#comment-5601364


Views exposed sort handler with asc + desc + inactive

Things to learn:

If more than one sort option is exposed, then only one of them will be active at a time.
The first of all exposed sort option will be active by default, the others will be inactive by default.
The non-exposed sort options will always be active. But if you put them below the exposed sort options, they will have a lower priority, obviously, so you might not see the effect.
One field can be used multiple times. E.g. one time exposed, another time not exposed.
BEF can be used to re-label the options.
BEF can be used to hide some sort options, by leaving the label empty.

Example sort configuration:

stock, exposed, descending.
amount, exposed.
stock, descending. (not exposed)

Then in the BEF settings, "Advanced sort options", "Rewrite the text displayed":

Stock Desc|No sort
Stock Asc|
Price Asc|Cheapest first
Price Desc|Most expensive first


How do I vary PathAuto paths based on a field?

The easiest approach is to define a custom token using hook_token_info() and hook_tokens(). Based on the venue, you either return the country code or nothing. If the token has no value, pathauto will automatically clean it up and drop that part.

Pathauto tokens for taxonomy terms except root for example has some hints on how to implement custom tokens.


Mock a service while running a BrowserTest?

I could not quite get my mocked service to be used from the container as per the docs, so I resulted to doing this.

I don't really need a BrowserTest per se, as I just want to ensure the Response object contains what it should. I create a client mock and instantiate the controller object myself:

<?php

namespace Drupal\Tests\mymodule\Kernel;

use Drupal\KernelTests\KernelTestBase;
use Drupal\mymodule\Controller\AuthorizeController;
use Drupal\node\Entity\Node;
use Drupal\file\Entity\File;
use Drupal\Core\File\FileSystem;

/**
 * Tests the AuthorizeController controller.
 *
 * @group mymodule
 */
class AuthorizeControllerTest extends KernelTestBase {

  /**
   * @var array
   */
  public static $modules = ['system', 'node', 'field', 'mymodule', 'file', 'mymodule_authtest', 'user', 'text'];

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp();

    $this->installConfig(['node', 'user', 'mymodule_authtest', 'file']);
    $this->installSchema('file', ['file_usage']);
    $this->installEntitySchema('user');
    $this->installEntitySchema('node');
    $this->installEntitySchema('file');

    $module_path = drupal_get_path('module', 'mymodule_authtest');

    $uri = $this->container->get('file_system')->copy("$module_path/fixtures/pdf/foo.pdf", 'public://foo.pdf', FileSystem::EXISTS_REPLACE);

    $file = File::Create([
      'uri' => $uri,
    ]);
    $file->save();

    $node = Node::create(array(
      'title' => t('Test Paper'),
      'type' => 'working_paper',
      'language' => 'en',
      'field_id' => 'w12345',
      'field_paper_working_paper' => $file->id(),
    ));
    $node->save();
  }

  /**
   * Test different scenarios and responses from our controller.
   */
  public function testControllerResponse() {
    $node = $this->container->get('entity_type.manager')->getStorage('node')->load(1);

    $client = $this->getMockClient(1, 3, 3);
    $controller = $this->getAuthorizeController($client);
    $response = $controller->content($node);
    $this->assertContains('You’ve used 3 of your 3 allowed downloads for the year.', $response->getContent());
    $this->assertContains('Download Paper Anyway', $response->getContent());

    $client = $this->getMockClient(1, 3, 1);
    $controller = $this->getAuthorizeController($client);
    $response = $controller->content($node);
    $this->assertContains('You’ve used 1 of your 3 allowed downloads for the year.', $response->getContent());
    $this->assertContains('Download Paper Anyway', $response->getContent());

    $client = $this->getMockClient(1, 2, 1);
    $controller = $this->getAuthorizeController($client);
    $response = $controller->content($node);
    $this->assertContains('You’ve used 1 of your 2 allowed downloads for the year.', $response->getContent());

    $client = $this->getMockClient(0, 3, 3);
    $controller = $this->getAuthorizeController($client);
    $response = $controller->content($node);
    $this->assertNotContains('Download Paper Anyway', $response->getContent());
    $this->assertContains('Purchase Paper for $5', $response->getContent());
    $this->assertContains('Have Access? Login to Account', $response->getContent());
  }

  /**
   * Return a mocked client. Allow changing of some values to influence the
   * controllers response object.
   */
  protected function getMockClient(int $allow = 1, int $claims_max = 3, int $claims_used = 1) {
    $client = $this->getMockBuilder('\Drupal\mymodule\Client\AuthorizeClient')
      ->disableOriginalConstructor()
      ->getMock();
    $client->expects($this->any())
      ->method('request')
      ->with('w12345', FALSE)
      ->willReturn(
        [
          'allow' => $allow,
          'claims_max' => $claims_max,
          'claims_used' => $claims_used,
          'failed_reason' => NULL,
          'succeeded_reason' => NULL,
          'subscriber_id' => 12345,
          'subscriber_logo_url' => NULL,
          'subscriber_name' => "Test",
          'subscriber_type' => "SUBS",
        ]
      );

    return $client;
  }

  /**
   * Return a controller with a mocked client.
   */
  protected function getAuthorizeController($client) {
    return new AuthorizeController($client, $this->container->get('renderer'), $this->container->get('entity_type.manager'), $this->container->get('request_stack'), $this->container->get('logger.factory'));
  }

}

This seems like a valid approach and the cases are working, and executes much faster than browser tests. The mymodule_authtest contains a content type with a couple of field configuration files and example PDF file to use in this test.


How do I set up a site to use Redis as cache handler?

For Drupal 8, use this code in the settings.php file:

$settings['redis.connection']['host'] = 'localhost';
$settings['redis.connection']['port'] = NULL;
$settings['cache']['default'] = 'cache.backend.redis';
$settings['redis.connection']['base'] = 101;

You can check whether or not Redis is running by viewing the status report at: /admin/reports/status


Yes.  Go ahead and run update.php.  It will run the updates (which are usually but not necessarily schema updates) for the new modules.

There is no need to disable modules before updating them.  There is no need to update Core first.  You should, however, put the site into maintenance mode before updating the modules until after you run update.php.

You should run update.php every single time you update a module or the Core.


For example if your default image called default_img.png inside images folder inside your theme MyTheme.

You can try the following:

implement hook_preprocess_HOOK

/**
 2. Implements hook_preprocess_HOOK().
 */
function extended_url_preprocess_paragraph(&$variables) {
  $variables['theme_path'] = drupal_get_path('theme', 'MyTheme');
}

In your twig you can do something like:

{% if content.field_image|render = true %}
    {{ content.field_image }}
{% else %}
<img src="{{ theme_path ~ directory }}/images/default_img.png"/>
{% endif %}


How does the UserData plugin get the correct value?

The available fields for the user entity are defined in Drupal\user\UserViewsData::getViewsData():

$data['users']['data'] = [
  'title' => $this->t('Data'),
  'help' => $this->t('Provides access to the user data service.'),
  'real field' => 'uid',
  'field' => [
    'id' => 'user_data',
  ],
];

This attaches the field user_data to the user entity.


Drupal 7 aliases for a certain content type producing 404

Do you have any folder's in your root directory called "charities" or is there any rewrite rule in your.htaccess file? I know it's a long shot, but I had a very similar problem once and this turned out to be the cause.

Also, try putting "?q=" before the alias when you type in the url and see if that works (e.g., http://yourdomain.com/?q=alias/path). it will point to problems related to my other suggestions.


How to create drop down while the menu structure is in array type?

I have found some possible answers related to your solution.

SOLUTION 1:

The main menu in Bartik only displays the first level. Since it's hardcoded in page.tpl.php there's nothing you can do about it.

Here's how to get the menu to work properly:

In your theme settings (admin/appearance/settings/bartik) disable "Main menu".
Go to admin/structure/block and add the "Main Menu" block to the header region (or wherever you want it).

Alternatively, you can also check out the excellent Menu Block module, which generates extra customizable blocks (1st level, 2nd level, etc) for each menu.

SOLUTION 2:

There are some useful resources that may help you to solve your problem.

How to create a drop down menu in bartik theme
Drupal 7 + Bartik + Dropdown for Main Menu Children
Add drop down menu support to Bartik
Drupal Responsive Bartik Theme with Dropdown Menus


Close webform modal and redirect to entity

Yes you are so close!
just move the creation of the new entity from your postSave()
to right in the ajax call back

example:

_CUSTOM_MODULE_webform_submission_form_submit_ajax(array &$form, FormStateInterface $form_state) {
 // At this point we have all access to $form_state->getValues();
 // the webform submission is all ready saved so we can use the values here.

 // Get the entity storage.
 $entity_storage = \Drupal::entityTypeManager()->getStoage('ENITYNAME');

  // Create New entity.
  $new_entity = $entity_storage->create([
   'field_whatever' => $form_state->getValue('some_field');
  ]);
  // Save entity
  $new_entity->save();
  $new_entity_id = $new_entity->id();
  // set the url.
  $url = "/where-ever/" . $new_entity_id;

  $response = new AjaxResponse();
  $response->addCommand(new CloseModalDialogCommand());
  $response->addCommand(new RedirectCommand($url);
  // Party.
 return $response;
}


Create custom variables for a template file inside a menu callback function

I don't believe you can do this without using hook_theme, but this is exactly what it's for and it's quite simple. (This code is for Drupal 6.)

/**
 * Implements hook_menu().
 */
function example_menu() {
  $items['example/page1'] = array(
    'page callback'     => 'example_page1_callback',
    'access callback'   => TRUE,
    'type'              => MENU_CALLBACK,
  );
  return $items;
}

/**
 * Page callback function
 */
function example_page1_callback() {
  $variable_to_print1 = 'Foo';
  $variable_to_print2 = 'Bar';
  return theme('example_contents', $variable_to_print1, $variable_to_print2);
}

/**
 * Implements hook_theme().
 */
function example_theme() {
  return array(
    'example_contents' => array(
      'arguments' => array('variable_to_print1' => null, 'variable_to_print2' => null),
      'template' => 'example-contents',
    ),
  );
}

$variable_to_print1 and $variable_to_print2 are now available in example-contents.tpl.php.


Archiving forums on time basis in drupal 7

You could use the Rules module.

Create a rule to set the node status to "unpublished" when the node is older than 6 months and make it execute every time the cron runs.

Also, make sure you allow only the admin to see the unpublished content


Database updates after pulling in code updates for modules

What makes you think that, for any of the updated modules, part of the actual updates included some database update to be performed? In other words: there are (plenty) of cases where, if you update some module, there are no related database updates that are included in such module update.

From "Writing .install files (Drupal 7.x)", within the parg "Module updates using hook_update_N":

  Updating your module, for example updating your schema, can be done using hook_update_N functions. The API page for this is at: function hook_update_N.

  Suppose you add a new column called 'newcol' to mytable1. First, be sure to update your schema structure in mymodule_schema() so that newly created tables get the new column. Then, add an update function to mymodule.install ...

Have a look at this part of an .install file about an update of the database for the Rules module, and which looks like so:

/**
 * Creates a flag that enables a permission for using components.
 */
function rules_update_7209() {
  // Create a access exposed flag column.
  db_add_field('rules_config', 'access_exposed', array(
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
    'size' => 'tiny',
    'description' => 'Whether to use a permission to control access for using components.',
  ));
}

PS: It's fair to say that database updates are not required unless a change is made to the schema.


Display node through panels but limit/deny access directly

By

  Edit: I'd also like to avoid adding code into template files etc.

do you mean that you want a existing module / UI only solution?  If so, I can't help you with that.

If you don't mind doing a small custom module, this is a somewhat common task that has been answered a few times on this site, and the main SO site, under slightly different titles.

Essentially, you want to redirect a node page to another page or you want to not have a node every viewable on its own.

Two questions worth reading are

Redirect node type to a view

How to prevent access to Views-only content?

Those two solutions can be adapted to your needs.


Drupal custom page with wildcards in url not working

By using the named wildcards %id and %name as wildcards, Drupal will look for functions named id_load() and name_load(). It will pass the values of these wildcards to those functions, and use the return values as the arguments passed to the page callback. If the _load functions are not found, or if a FALSE value is returned, or no value is returned, you will get the error you are seeing.

I'm suspecting you want your path to be:

course-details/%/%


Search multiple fields from one text box in a View

You achieve it by using  Global: combine field filter.
For details and get familiar with it take a look at

https://swsblog.stanford.edu/blog/views-exposed-filters-multiple-field-search


When restoring, you first need to drop your old database (or all tables within). The restore can only replace the tables that existed when you created the export, it doesn't know about any tables that you created later on.


How do I use a different structure of a theme on different pages?

Theme block regions are just empty placeholders that mark up certain points within your HTML. Regions don't affect your site on their own, it is only when you put Blocks inside them that they show up.

Most (if not all) themes first check that a region isn't empty before printing the region container into the HTML. So regions don't appear in your HTML if there are no Blocks inside them.

What you should be focused on instead is Block Visibility, not regions. It makes more sense to control where each piece of content should appear, instead of controlling the containers/regions.

And you can control for each Block on which pages it should appear, so that is how you achieve the different structure of the pages. Some Blocks you set to display for example in sidebars regions but only on the front page. Some Blocks you put in the sidebar but only on node pages.

If there is a page that doesn't have any blocks set to appear in sidebars, then this page will not show any "sidebar area". It will be up to your theme CSS to style what the page without sidebars looks like. Most likely it will just be a simple one column area for your content.

There are modules that allow you for more control over the Blocks placement (Context for example), that do something that could be described as turning regions on or off, but that is a slightly different approach and I think you should play with the original Blocks arrangement first if you're new to Drupal. It is much easier to understand and setup Blocks to be visible on only sections of your website.

In Drupal 8 you can place the same Block more than once, in another region, or even the same region. You can then adjust the Visibility to different conditions, so for example you can have your Main navigation displayed in Header region on the front page, but displayed in the sidebar on all other pages.

BTW the above example isn't the best one, navigation should be always in the same place for accessibility and other reasons. But I hope you understand the concept of placing Blocks in regions, but then using Visibility to make them appear on only certain pages, and not others.


Authenticate user being selected won't make a difference as the expiry date is on your other role of impact protection user.

Every user by default is an authenticated user, of which you can't make expire.


How to group all custom modules under one menu using hook_menu?

Thanks to kalabro for the answer. For those who are new to module development and need the same functionality, I've posted the code below :

  function hook_menu() {
  $items['admin/settings/custom'] = array();
  $items['admin/settings/custom/module-name'] = array(
  //other code here
  );
}

You can use the "$items['admin/settings/custom'] = array();" in a separate module also.

Note :
Be sure to flush the cache. Sometimes you might need to disable and then enable the modules again for this to work...


Is there a way to set block visibility programmatically without using the PHP Filter module?

Yes. Setting the blocks content to false will hide it from the display and will hide the region if there are no other blocks present. I'd imagine you would need a setup similar to the following:

$block['content'] = _my_module_custom_block();

...

function _my_module_custom_block(){
    if( HIDE_CONDITION )
        return false;
}


Drupal Registration Form In Lightbox With Ajax

If I recall correctly, instead of calling render() for your drupal_get_form(), call drupal_render() instead.

<?php

function ajax_register_mypage($form){
  print 'Hello World';
  print drupal_render(drupal_get_form($form));
}

?>

Hope this ends up solving your issue on this one.


Benefit of processing multiple entities at once?

buildMultiple() exists, but it was done before we introduced render caching to entities and with that, lazy entity rendering/building. Now we don't really need multiple processing.

See https://www.drupal.org/node/2843565 for a discussion about that and the conclusion that we don't really need buildMultiple() anymore.

The idea is that if we render a page with 20 articles, then rendering them all separately is slightly slower on the first request. However, if you save one of those articles, or create a new one, then when accessing that page again, only one needs to be rendered (again), the others can be returned from the cache.

Whether or not a multiple API makes sense for you depends on how it will be called, if you expect it to be called on multiple entities, then can make sense, if not, then probably not.


Relationships are the way Views expresses SQL joins. For example, when viewing a node, you can add a relationship to it's author, pulling in even more data.

Arguments have been renamed "Contextual Filters" in Views 7.x-3.x, which is a better name. Basically, it's a filter that gets its input from the the page, either by the page's URL or the node or user being viewed, etc.


Generating hierarchic URI's based on taxonomy

From the comments, this is one way how I would do this:

create a taxonomy vocabulary called gallery type.
create a taxonomy vocabulary called year.
populate them with the appropriate terms.

Then I'd create a view:

filter it on gallery type (or whatever content types are tagged by the above vocabs)
also filter it on all nodes that are published

In arguments (d6) or contextual filters (d7) I'd put in two arguments.  They would be taxonomy terms and you can select them from the dropdown list from taxonomy:

For the first, select taxonomy term and then in validation, select taxonomy and term again and restrict it to the gallery type vocabulary.
For the second select taxonomy term and then in validation, select taxonomy and term again restrict it to the year vocabulary.

Then, in the Fields, select whatever fields you want displayed.  For ease here, just select node title, but once in production I'd imagine they'd be title, a picture or image or two, a description, etc.

Now, create a page display in the view, and in the path enter

myfirstview/%/%

Change myfirstview to whatever makes sense on your website's hierachy.  What the two %'s do is substitute in the taxonomy terms above.

Save everything.

Now you have created a View that does all that hierarchy for you.  So, if someone goes to...

www.yourhost.com/myfirstview/movies/2009

...Views will create the page for you and display the title of whatever content has been tagged with both movies and 2009 (views takes the hardcoded myfirstview and substitutes in the movies and 2009 and then matches them against what content is tagged with those terms) and if they went to...

www.yourhost.com/myfirstview/pictures/2012

...Views would create a page of all pictures from 2012 doing the same logic.

What is nice is that you can then create a views that filter on only one of the vocabularies, eg,

www.yourhost.com/mysecondview/pictures

that would list all pictures

or

www.yourshost.com/mythirdview/2012

that would list all content from 2012

As you get more comfortable with Views you can then add all kinds of different sortings, eg, sort by posting or last edit date, sort alphabetically by title, etc, but this should get you on your way.  Just play around with the settings and hit Preview a lot.  You'd be amazed how simple it is once you get past the up front daunting nature of all the various options you have.


Call to undefined function drupal_execute()

drupal_execute hasn't existed since Drupal 6.

In Drupal 8 you can submit a form programatically like this augmented example from ProgrammaticTest::submitForm:

$values = ['foo' => 'bar'];

// Programmatically submit the given values.
$form_state = (new FormState())->setValues($values);
\Drupal::formBuilder()->submitForm('\Drupal\form_test\Form\FormTestProgrammaticForm', $form_state);


I think the first code snippet on this post is what you are looking for:

<?php

function mymodule_user($op,&$edit,&$account,$category = NULL){
    if($op == 'login'){
        if($account->login == 0){ // check the last login
        //do stuff here
        }
    }
}

?>

It uses hook_user() to check the user's last login time. If it's 0, meaning she haven't logged in before, you can redirect the user with a function like drupal_goto.

You'll have to create a simple custom module and place your code in mymodule.module file.

If you are not comfortable writing a module for this, you can try creating a rule with the Rules module, I haven't been able to test this approach, but here are the basics:

Create a new rule:

Event: 'User has logged in'
Condition: 'Data comparison' - check the data called
'site:current-user:last-login' or 'account:last-login' for last login information.
Action:'Page redirect'


You can add extra field instance settings as part of you custom module using hook_form_FORM_ID_alter, e.g.

/**
 * Implements hook_form_FORM_ID_alter().
 */
function FOO_form_field_ui_field_edit_form_alter(&$form, $form_state, $form_id) {
  $field = $form['#field'];

  // @todo: Consider adding extra condition.

  // Inject setting form element to an instance settings form.
  $form['instance']['settings']['pre_on'] = array(
    '#type' => 'checkbox',
    '#title' => t('Render Prefix as Prepend'),
    '#description' => t('Some description'),
    '#default_value' => isset($form['#instance']['settings']['pre_on']) ? $form['#instance']['settings']['pre_on'] : NULL,
  );
}

If you don't want to create new module for a single checkbox, consider adding this hook into your template.php file as part of your theme.


2 servers with 2 local memcached: flush both

I suggest you to use Drush aliases.

Here is the quote from the documentation http://drush.org/en/master/usage/#site-aliases

  Drush lets you run commands on a remote server, or even on a set of remote servers. Once defined, aliases can be references with the @ nomenclature

Also from here https://raw.githubusercontent.com/drush-ops/drush/master/examples/example.aliases.drushrc.php

  Alias groups (aliases stored together in files called GROUPNAME.aliases.drushrc.php, as mentioned above) also create an implicit namespace that is named after the group name.

Finally, these are few simple steps to achieve what you want:

Create production.aliases.drushrc.php file
Put in this file aliases for both Drupal 1 and 2
Then you can clear cache on all site at once with drush @production cc all


Difference between calling a service method in drupal 8

Dependency Injection has several advantages when you try to create test for your code, and follow the Single Responsibility Principle.

Really, the second reason is a consequence than the first: "The code is testeable because follow the SRP"

Furthermore, IDEs can recognize better the class type (and create autocompletes, f.e.) if the class is defined using DI. In a normal IDE, $service defined in $service = \Drupal::service('myservice.method'); has a unknown class.

In some places you cannot use DI (fe. in a .module) and you need to use the static load.


Is it okay to edit the webform content type?

I don't think you've necessarily done anything wrong by adding fields to the Webform content type, but if you're interested in strictly keeping your code separate from core code, you can create a new content type,  and enable Webforms to be used on this content type under "Webform-enabled content types" on /admin/config/content/webform.

Then you'll be able to add your own image field to your own content type without problems.  This will then leave you free to export the content type configuration to code with the features module, without really interfering with the Webform content type provided by the Webform module.


Remove all markup from user registration field

function tweakform_field_widget_form_alter(&$element, &$form_state, $context) {
  $element['#theme_wrappers'] = '';
  $element['#prefix'] => '
';
  $element['#suffix'] => '
';
}


Generate slideshow of images present in a folder

You could try something along the lines of the following:

function mymodule_get_folder_images() {
$directory = "path/to/your/images";
//Check this...my regex is crap
$mask = "(jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF)";
$options = array(
'recursive' => TRUE
);

//This should return an array of images
$images = file_scan_directory($directory, $mask, $options);

//Loop through the array once to get an array of paths.
foreach ($images as $k => $v) {
$imagearray[] = $v->uri;
}

//This should probably be passed to a theme function to be more Drupally.

$output = '
';

foreach ($imagearray as $k => $imagepath) {
if ($k == '0') {
$output .= '';
}
else {
$output .= '';
}

$output .= '
';

return $output;
}

This will give you an unordered list of images that you can use to create your slideshow.  Then just hook the jQuery Cycle plugin (or any other slideshow plugin) into your site and you're off.  I can't really help with the slideshow integration as it's going to be pretty custom for your needs, but it becomes much easier when you already have the image urls formatted nicely.  Obviously, if you need a list instead then you just re-format the last foreach loop.


How can a poster of a comment notify selected users about a new comment?

When I write a comment on a node, I want to be able to select the users that will get a notification about that new comment.

1) Download Rules and Entity Reference Modules.
2) Enable Rules, Rules UI (User Interface, we need this), and Entity Reference
3) In your comment fields

Add a field with Entity Reference and a widget of Auto complete (tag style)

For example: I named mine lalala (click picture below to enlarge)

4) In your field settings:

Select User as your target type

After you click save field settings you are taken to another screen, scroll down and find Number of values and change it to Unlimited and Save Changes.

5) Add a new rule by going to /admin/config/workflow/rules/reaction/add

React on Event: After Saving New Comment
Restrict by Type: Select your content type (In this example it's Article Comments, since in Articles Comments is where I put my lalala field.)

6) Click on Add a Loop

Data selector: comment:field-lalala (remember I named my entity reference field lalala)

7) Click Add Action, but the one from the loop!

8) Select Fetch Entity by Property

Entity Type: User
Property: Email
Data Selector: list-item:mail
Limit Result Count: put a large number here in case it has an effect. (since we are looping, I don't believe so, but I am not 100% sure)

9) Add another action to the loop, this time add Send Mail
Click on switch to data selection button.

To: list-item:mail

The end result should look like this

Now add a new comment.
On your entity reference field since we are using Autocomplete (tag style) you start to type a user name and select the user. Then add a comma , to add more users
Ex:
After posting the comment, all referenced users should receive an e-mail.


How to create a custom text input filter?

Take a look at the Custom Filter module.

  This module allows you to create content filter using regular expressions. Instead of creating a new module for each filter you need, now you can easily create and organize your own filters. Your filter will appear in the input format configuration page.

If you want to do it yourself in a custom module, you can implement hook_filter_info


I want to place my business page linkedin feed onto our Drupal website. Is it possible?

Take a look at these links:

https://www.drupal.org/docs/8/modules/get-linkedin-posts

https://www.drupal.org/docs/8/modules/get-linkedin-posts/how-to-setup-get-linkedin-posts-module

I haven't played with Linkedin or with this module, but that's what you need if I understand right.

It's up to you if you install it or not.


Drupal 8 blocks content is not being translated

You need to navigate to admin/config/regional/translate. Try to search for "Test NL" in the input field. It will give you the string on the left side along with a text-field to the right. Enter the translation for the "Test NL" in the text field. and click save translations.

You are done. Clear the cache and check the interface.


Use AJAX on a form with multiple buttons

Just two problem with your form:

Remove #value element from 'input' element
replace return $return['output']; with return $form['output'];

The problem with #value is that the element gets re-initialised on form render.

Here is the working version(copy button) of your code:

<?php

function playground_menu() {
  $items['playground/form'] = array(
    'title' => 'Form',
    'description' => '',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('playground_demo_form'),
    'access arguments' => array('access content'),
  );
  return $items;
}

function playground_demo_form($form, $form_state) {

  $form['input'] = array(
    '#type' => 'textarea',
    '#title' => t('Input text'),
    '#prefix' => '
',
    '#attributes' => array(
      'placeholder' => t('Enter some text here... '),
    ),
    '#suffix' => '
',
  );

  $form['buttons'] = array(
    '#type' => 'fieldset',
    '#title_display' => 'invisible',
    '#attributes' => array(
      'style' => 'border: 0px; text-align: right',
      'class' => array('container-inline'),
    ),
  );

  $form['buttons']['copy'] = array(
    '#type' => 'button',
    '#value' => 'Copy text',
    '#ajax' => array(
      'callback' => 'copy_text',
      'wrapper' => 'out-text',
//          'method' => 'replace',
//          'effect' => 'fade',
    ),
  );

  $form['buttons']['reverse'] = array(
    '#type' => 'button',
    '#value' => t('Reverse text'),
  );

  $form['buttons']['clear'] = array(
    '#type' => 'button',
    '#value' => t('Clear text'),
  );

  $form['output'] = array(
    '#type' => 'textarea',
    '#title' => t('Output text:'),
    '#prefix' => '
',
    '#value' => '',
    '#attributes' => array(
      'placeholder' => t('Your text will appear here...'),
    ),
    '#suffix' => '
',
  );

  return $form;
}

function copy_text($form, $form_state){
  $form['output']['#value'] = $form_state['values']['input'];
  return $form['output'];
}


How do I alter a template file in a multishared child-site?

This is a bit tricky since normally template files are located in the Theme's folder and not in a module's folder.

You could create a /modules folder under yourchildsite.com folder and copy the parent site module and paste it there. Then modify what you need.

I am not 100% sure this will work, but I hope it does.


Next/Prev buttons for nodes based on nodereference field

I don't know if you managed to get your pager working yet, but I've just modified a piece of code to create a pager based on node reference. You're free to use it as you see fit. You can go to my blog to see it:

http://www.visionarymedia.nl/blog/drupal-pager-based-node-reference


After forced login, return to first entered login

I believe the correct way to do this is:
drupal_goto('user/login', array('query' => drupal_get_destination()));

The documentation for drupal_get_destination() states:

Prepares a 'destination' URL query parameter for use with drupal_goto().
Used to direct the user back to the referring page after completing a form. By default the current URL is returned. If a destination exists in the previous request, that destination is returned. As such, a destination can persist across multiple pages.

Update: You could try putting the URL in directly:
$path = 'path-to-redirect-to'; // or $GET['q']
drupal_goto('user/login', 'query' => array('destination' => $path)));


If the image doesn't really vary by variation, I would put it on the product. This will save you disk space / database space in the long run. Alternately, you may be able to use the Media module to upload the image once and reference it from all of the variations. This would let you use a single product type to handle product pages whether their variations required different images or not.

At the end of the day, there is no single best option here.