I think it can depend a little on what your goal for the "clone" is.

When we want to make clones of a live site for development or testing or whatever very little works as well as just making an image of the whole server, spinning it up somewhere else and modifying the allowed domains to account for the new IP address.

If you want specific help about some part of the cloning process then perhaps we need more information about what s going wrong; error messages, WOD etc. I notice in your post you mention making the database but not importing the old database, was that step taken?


How can I make this with the Views module?

How to show only oldest and newest node in Drupal views?

Check this out, I believe you will definately get answer with views, contextual filters.
and with the content type = Article and display only 2 with help of PAGER..

Extended answer

And when select that option, you will get another pop like below image

After making up a selection, write how many items you want to display.

And if you want to add see the month, why you just add fields to display.
also add a content posted date field below image will help out


Way to Configure IP Geolocation Views & Maps Module via Script

You can use the drush variable-set command for this:

~$ drush help variable-set
Set a variable.

Examples:
 drush vset --yes preprocess_css TRUE      Set the preprocess_css variable to
                                           true. Skip confirmation if variable
                                           already exists.
 drush vset --exact maintenance_mode 1     Take the site offline; skips
                                           confirmation even if
                                           maintenance_mode variable does not
                                           exist. Variable is rewritten to
                                           site_offline for Drupal 6.
 drush vset pr TRUE                        Choose from a list of variables
                                           beginning with "pr" to set to
                                           (bool)true.
 php -r "print                             Set a variable to a complex value
 json_encode(array('drupal',               (e.g. array)
 'simpletest'));"  | drush vset
 --format=json
 project_dependency_excluded_dependencies
 -

Arguments:
 name                                      The name of a variable or the first
                                           few letters of its name.
 value                                     The value to assign to the variable.
                                           Use '-' to read the object from
                                           STDIN.

Options:
 --exact                                   The exact name of the variable to
                                           set has been provided; do not prompt
                                           for similarly-named variables.
 --format=<boolean>                        Format to parse the object. Use
                                           "auto" to detect format from value
                                           (default), "string", "integer" or
                                           "boolean" for corresponding
                                           primitive type, and "json" for JSON.
 --yes                                     Skip confirmation if only one
                                           variable name matches.

To use this, you need to figure out the machine name for the variable.  On system settings forms, this will be the $form key in the builder function.  You can also poke through the variable list from the Devel module, and look for the variable name there.  If you use Inspect Element (or whatever it is called in your browser), it will be the name attribute on the input or select element.


How do I change the date format of a single result?

You can create a template file and in that you can have and the template files you can get that in

if($view->row_index == 1){
   // do your stuff
}

and put your own condition


Use the following function in template.php of your theme.

function MYTHEME_preprocess_page(&$vars, $hook) {
  $path = drupal_get_path('theme', 'MYTHEME');
     // Render the main scripts file.
  $local_js = array(
    '#attached' => array(
      'js' => array(
        $path . '/js/scripts.js' => array(
          'group' => JS_THEME,
          'weight' => 9999),
      ),
    ),
  );
  \Drupal::service('renderer')->renderRoot($local_js);
}


How do I jump to a specific place on a page?

The problem is that you have the #, called fragment, in the path, Drupal escapes it for you, and what you need to do is tell Drupal specifically that you want a fragment in the url.

Example:

l('linktext', 'node/1', array('fragment' => 'placetojumpto'));

Documentation here: http://api.drupal.org/api/drupal/includes--common.inc/function/l/7


Menu Attributes is another great module that allows you to set class, id, rel and other attributes on either the a or li element.


How can I override a module-defined view and export to code?

Using hook_views_default_views_alter(). There's a page on this on drupal.org. As far as I know there's no way to have features automatically export an overridden view and put it in a hook_views_default_views_alter(), and it looks like there's actually an issue with using features together with this hook.


How to add a CSS class to an render array?

I believe it would be:

$content['field_image'][0]['#attributes']['class'][] = 'my-class';

Or to assign it to every element,

foreach (element_children($content['field_image'] as $key) {
  $content['field_image'][$key]['#attributes']['class'][] = 'my-class';
}


For D7 its

$account = user_load($uid);
$group = group_load($group_id);
$group->addMember($account->uid, array('joined_on' => REQUEST_TIME));

To delete

$group->removeMember($account->uid);

To request

$group->addMember($account->uid, array('status' => 'requested', 'requested_on' => REQUEST_TIME));

To block:

foreach (group_membership_load_by_user($account->uid) as $group_membership) {
  $block_gid = // some code to get the Group ID that you want the ...
               // ... the block to take place in.
  $gid = $group_membership->gid;
  if ($gid == $block_gid) {
    global $user;
    if ($group_membership->status != 'blocked') {
      $group_membership->blocked_status = $group_membership->status;
      $group_membership->status = 'blocked';
      $group_membership->blocked_on = REQUEST_TIME;
      $group_membership->blocked_by = $user->uid;
      $group_membership->save();
    }
}

To Unblock:

foreach (group_membership_load_by_user($account->uid) as $group_membership) {
    $unblock_gid = // some code to get the Group ID that you want the ...
                  // ... the unblock to take place in.
    $gid = $group_membership->gid;
    if ($gid == $unblock_gid) {
      if ($group_membership->status == 'blocked') {
        $group_membership->status = $group_membership->blocked_status;
        $group_membership->blocked_status = '';
        $group_membership->blocked_on = NULL;
        $group_membership->blocked_by = NULL;
        $group_membership->save();
      }
    }
}


My admin panel view fancy box not working

I also faced the same problem. This is due to jquery problem. Let me tell you that jquery contains default support to jquery. It uses older version of jquery in its core. So, if u want to use that module, then, what u can do is:

Download jquery update module and enable the moudle,
Then you open the project code, moudles folder and find the jquery update moulde, there you will find replace folder. You, will find various version of jquery there. You can include or replace the latest version of jquery.
However the drupal core works in older version, so what you can do is open the jquery_update.module file and find the line that says.

// Replace files for jQuery 1.7 and up
      if (version_compare($version, '1.7', '>=')) {
        $javascript['drupal.states']['js']['misc/states.js']['data'] = $path . '/replace/misc/1.7/states.js';
  }
Now what you need to do is. You need to check, if the user is logged in then replace the jquery with core old jquery and if user is not logged in then, use the latest your fancybox jquery.


How to avoid clearing the cache after every CSS change?

On the admin/config/development/performance page under 'Bandwidth optimization' uncheck "Aggregate and compress CSS files.".

If you're looking for more control https://www.drupal.org/project/advagg/ is what you're looking for. Using the development setting in AdvAgg will detect the changes and push them out automatically.


Drupal::config to access Site default timezone

Inspect the system.date configuration

You can navigate to the /admin/config/development/configuration/single/export path and inspect the configuration types and values. The default timezone is of type simple configuration and system.date is the cofiguration name.

Inspect all the configuration values

Go to /admin/config/development/configuration/full/export, here you can export all the active configuration, you can download and extract the bundle and then inspect the individual files. If you have the drush command line tool, you could use the command drush config:export.

Official Documentation

You should read the official documentation to better understand the logic behind the Configuration API. These are some links:

Simple Configuration API | Drupal 8 guide on Drupal.org

Configuration API | Drupal 8 guide on Drupal.org

Configuration API overview | Drupal 8 guide on Drupal.org


This is due to the internal page cache and Internal dynamic page cache, Drupal will heavily cache all GET requests, so what you are missing is

$settings['cache']['bins']['page'] = 'cache.backend.null';

as the 3rd bin to clear but this won't work due to dynamic cache, so can you either manually purge the entire Drupal cache or set a timestamp into your URL so you can bypass caching for development.

node/1?_format=json&time=123456789


Composer update still shows an older version of a module

The h5p module has 2 dependencies and must therefore be updated like this:

composer update drupal/h5p --with-dependencies


Am I able to call functions in my custom module from other modules?

There are two issues:

Is the function you're going to call intended to be an API function? In general, functions that are not intended to be called by other modules are prefixed by an underscore as in _mymodule_private_function().
Is the function in a file that is guaranteed to be loaded when you need it to be.  If it's in a .module file and the module is enabled, then it will be available. If it's in a class that's declared in a file listed in a files[] declaration of an enabled module's .info file, it will also be available. If it's a regular function in a .inc file, you may have to force it to be loaded with module_load_include() or require_once() or similar techniques.

How do you do it? Just call the function the same way as that module calls the function, the same way as you call any Drupal core function.

Don't forget to make the module a dependency of your module.


You should better start debugging the query.Things that might be help you debugging the query.

Install devel module. Having logged in as admin visit "yoursitename.com/devel/php" here you can execute any php code.
Put your query there and add this dpm($result); single line of code in the last of query. Execute the query, see what you get as result.
If the query execution is throwing error visit "yoursitename/admin/reports/dblog" and try to figure out the reason for the error.

You can also cross check if the query returned with drupal wrapper functions is same as your original query by stringyfying the query object, to do that add

`dpm((string) $query);`

just before $result = $query->execute(); and also remember to comment $result = $query->execute(); as execution of query may cause error in your case.


different colors for different order statuses

Here's a possible Drupal-only solution that can get you there. You're going to need access to your theme css file to add a class for each of your order statuses, ex something like this:

.order-status-pending { color: yellow; }
.order-status-closed { color: green; }
.order-status-problem { color: red; }

Now go to views and edit the 'orders' view that is added by Ubercart and then select the field for 'order statuses' from the Fields display section. Next, select 'Style Settings', 'customize field HTML', 'Create a CSS class' and then use the tokens to add your custom class there, ex:

order-status-[status]

You could also rewrite the output of the field using the replacement tokens to something like this:

[status]

This won't work on multiple word order statuses, but you could use jquery instead to do this kind of conditional styling, using their much more powerful selectors.


How to use Interface Translation for specific text on specific pages only

Drupal has very advanced Multi-lingual capabilities, so it's safe to assume that you can configure your site according to your needs. You just have to learn a bit about Drupal multilingual fundamentals and see how your needs fit in there.

It seems your question is about how languages are selected and displayed, and not about Interface translation. You probably already understand the difference between content and interface, and that the strings you put into the templates are part of the interface. And you probably want to be able to view content in different languages while keeping the interface language the same.

Under Configuration > Regional and language > Languages > Detection and selection you can choose to set that your Content language selection should work differently from the Interface language selection.

Enable that option Customize Content language detection to differ from Interface text language detection settings and then also enable the Content language Detection method (Determines the content language from a request parameter.) and it should be ordered to be your first enabled method.

This way you will be able to view Spanish nodes while keeping the English interface. This is happening through the parameter that is being added to the URL. Instead of:

/es/node/50

you will have:

/node/50?language_content_entity=es

With interface language kept as English, your menus and other links will lead to the English side of things, but you will be able to view translated content.


Your first two items are settings that can be configured on the Fivestar CCK field's display options. You should read through the Fivestar Documentation thoroughly for instructions on how to set up a rating system.

If you want to use star icons of your own, you can simply override the styling of the Fivestar widget in your theme using CSS. However, if you want to create a star set that can be easily reused across sites, you can follow the instructions for creating a fivestar widget set


The return value of Query::execute,

  int|array Returns an integer for count queries or an array of ids. The
  values of the array are always entity ids. The keys will be revision
  ids if the entity supports revision and entity ids if not.

Nodes support revisions so the keys will be revision ids and not entity ids.

$nodes = \Drupal\node\Entity\Node::loadMultiple(array_values($result));


How to change Stars in Webform-star module?

The webform-fivestar module currently doesn't have the option to select which star widget to use, however there is a patch you can apply at https://www.drupal.org/project/webform_fivestar/issues/2071161

There is information regarding how to apply patches at https://www.drupal.org/patch/apply

You can then select the widget per component, when editing the component, in the display settings (see screenshot).


Is there a way to track text-bytes changes Drupal nodes?

Yes, all one needs to do is look at the field_data_body table and compare the byte count of body_value between revisions to get this information.

In fact, this would probably make a good patch for the Diff module which alters the node Revisions tab to an interface pretty similar to MediaWiki. The only thing missing is the core of your question, a comparison of byte count between revisions.


Need Ability to Override Default text field

You can change the field default text in the field settings page of the content type, for example:

admin/structure/types/manage/[your-content-type]/fields/[your-field]

You need to change [your-content-type] and [your-field] by the real values on your drupal website.


How to prevent a block from being cached?

Got the solution via https://stefvanlooveren.me/blog/disable-block-caching-drupal-8

Add below function to your block

https://stefvanlooveren.me/blog/disable-block-caching-drupal-8

public function getCacheMaxAge() {
    return 0;
}

https://www.drupal.org/docs/8/api/cache-api/cache-max-age


Setting a field collection default value for a field using form

This is how I resolved this.

$language = $form['field_fielc_collection_group']["#language"];
                    $iterates = $form['field_fielc_collection_group'][$language];

                foreach($iterates as $multi__key => $iterate){
                            if (is_integer($multi__key)){
                                        if(is_array($iterate)){
                                            $delt = $form['field_fielc_collection_group'][$language][$multi__key]["#delta"];
$form["field_fielc_collection_group"][$language][$multi__key]["field_to_set_default"][$language]["#default_value"][$delt] = 'default_value' ;
                                        }
                            }
                }


Which hook is invoked when a user's roles are changed?

There isn't any other hook to use, as it is evident from the code used from user_multiple_role_edit().

  // The role name is not necessary as user_save() will reload the user
  // object, but some modules' hook_user() may look at this first.
  $role_name = db_result(db_query('SELECT name FROM {role} WHERE rid = %d', $rid));

  switch ($operation) {
    case 'add_role':
      foreach ($accounts as $uid) {
        $account = user_load(array('uid' => (int) $uid));
        // Skip adding the role to the user if they already have it.
        if ($account !== FALSE && !isset($account->roles[$rid])) {
          $roles = $account->roles + array($rid => $role_name);
          user_save($account, array('roles' => $roles));
        }
      }
      break;
    case 'remove_role':
      foreach ($accounts as $uid) {
        $account = user_load(array('uid' => (int) $uid));
        // Skip removing the role from the user if they already don't have it.
        if ($account !== FALSE && isset($account->roles[$rid])) {
          $roles = array_diff($account->roles, array($rid => $role_name));
          user_save($account, array('roles' => $roles));
        }
      }
      break;
  }

The only invoked hooks are the ones used by user_save().


How to edit a field--field-xxx.tpl file when the content is rendered with Display Suite?

I am a little bit ashamed, but if the issue occurs to someone else, it is not even necessary to write code. There is a dedicated field in the manage display interface.


How to choose the default (or any) CKEditor toolbar?

I finally figured this out: See http://drupal.org/node/1434814#comment-5583354 for the solution.  The most important bits are:

If you're just using the basic CKEditor module, ckeditor.config.js is completely irrelevant to getting your toolbar set up. Ignore it.
CKEditor toolbars are associated with text formats, like "Filtered HTML" or "Full HTML" (or, presumably, other text formats you might define). Each text format can be connected to exactly one toolbar; when a textbox with that text format appears, its toolbar will be presented.


Which module allows for tracking recently viewed content per user?

The Recently Read module does not allow you out of the box to be configure per content type, but it seems to me that the views you create to show the content can easily be filtered by content type. See comments #3 and #5 of this thread.

Also a quick scan of the modules source code tells me, that there is still support for relationships in views. So you should be able to follow the configuration guidelines in the linked comments to achieve what you want.


User password reset - redirect one time login to another page

Use hook_form_alter, then add a  $form['#redirect'] parameter with value as your custom user profile page.

OR
 append a destination query to the default form action url.

<default_action_url>?destination=<your_custom_user_profile_url>

I recommend the first option. It's the Drupal way.


Filter menu parent dropdown by language for multilingual site?

This seems to be the issue page for this problem: https://www.drupal.org/node/1242288. There are patches but as Jose Reyero points out, it would be only a partial solution.

There is a https://www.drupal.org/project/content_menu which enables you to first deal with the menu and then with the content instead of vice versa. Haven't tried but seems nice. This combined with Fixed language menus (provided by Menu Translation at admin/structure/menu/manage/menu-mymenu/edit, Multilingual options - Translation mode) could clean up the menu interface nicely.

Personally, I usually just don't bother dealing with the Parent item, I just head to the menu interface after creating a node, and drag my item, which will be at the bottom, to its place.


Is it possible to change the _alt_ text wording for images in one place?

If the images are all inline (i.e. part of the body content of the node) then there is no easy way to change the alt text in one place because these images have not been abstracted into the Drupal system. If these were fields or part of the files table, it might be possible to quickly update these using PhpMyAdmin or some other database solution but at this point your best options are

brute force (just what it sounds like, a painful node-by-node fixin' of the alt text).
try a search and replace option of the body text. I've used the scanner module for this kind of operation and recommend it as it has robust regex support and (most importantly) a rollback option.

Neither of these are great options but they're the best you can do given the circumstances. Which to choose depends on a). how many nodes you have to deal with, and what kind of alt text you have to add. If you're adding the same alt text to every image, scanner is your answer but if you have to evaluate and update each image with appropriate alt text (ex for 508 compliance), brute force is the way to go.


Showing the date of the latest edit, instead of node's posting date

I would tackle this in a template_preprocess_node, either in a module or in your theme.

function mytheme_preprocess_node (&$variables)
{
   $variables['date'] = format_date($variables['node']->changed);
}

Depending on your node template, you may also want to do something like

function mytheme_preprocess_node (&$variables)
{
   $variables['date'] = format_date($variables['node']->changed);

   if (variable_get('node_submitted_' . $variables['node']->type, TRUE)) {
     $variables['display_submitted'] = TRUE;
     $variables['submitted'] = t('Edited by !username on !datetime', array('!username' => $variables['name'], '!datetime' => $variables['date']));
     $variables['user_picture'] = theme_get_setting('toggle_node_user_picture') ? theme('user_picture', array('account' => $node)) : '';
   } else {
     $variables['display_submitted'] = FALSE;
     $variables['submitted'] = '';
     $variables['user_picture'] = '';
   }
}

so that your new $date gets used in $submitted, due to the preproccess/process order.

You can also play around with variants.  For example, you could have both created and last edited dates; you would juust need to set up the variables in the preprocess function, and then use them in your node.tpl.php.


Invalid Argument Exception when saving a view using a custom filter handler

The problem here is that there is no schema definition defined for the new custom filter.

You need to create a file in config/schema/YOUR_MODULE.views.filter.yml

With the following definitions with the machine names to match your specific setup.

views.filter.YOUR_VARIABLE:
  type: views_filter
  label: 'Example'

views.filter_value.YOUR_VARIABLE:
  type: views.filter_value.in_operator
  label: 'Example'


How do I store large volumes or data points using Drupal ( temperature and humidity points )

This is a large topic, so I will just mention some points and you can make the rest.

You will need a module, so you must have a .info, .module and in your case a .install file.

In the .module file:

Implement hook_field_info to tell Drupal about your custom field. Here is an example of how to use hook_field_info.
You must also introduce a widget and a formatter for your field. The widget is what appears in forms when you want to get data from user, and the formatter outputs data in proper way in view modes.
You need to notify Drupal about these items existence, hook_field_widget_info and hook_field_formatter_info will do the job for you.
After that you must make your widget, hook_field_widget_form is the proper hook here and hook_field_formatter_view will handle your field view.
Another thing is a zero function for your field - this function tells Drupal if the user has not filled or passed any data to your widget, hook_field_is_empty is implemented for that and it is required, else after form submission your users will face an error.
hook_field_validate can also be used to validate the data which is entered.

At this point we are done with the .module file,  but we still have on more step to go: the .install file.

Here we define a place for data to be stored in DB, hook_field_schema will do the job for you.

After this point you are all done.


Is there a clear separation between user data and Drupal data in the database?

You might want to look at the Deploy and UUID modules together.


How to use Exposed Filter criteria form for Advanced forum

This is not a solution, but might help toward writing one.

I found that the redirected page url had appended something like this:

?sid[]=6

which, when I appended to the forum page url, worked as desired - filtering as desired. So the url is created without the forum page part, just appending the above to the main site url part.


Adding a webform to a different content type

Your webform is empty. You need add some fields to the webform.
You can add webform to any "event" node.
Try this: go to your_host/node/node_id/webform and you can see wizard for webform elements!


The use of $username in the path looks a bit suspect. You should use .bash_profile for mac as as .bashrc seems not to be auto loaded.
There usually isn't a /username/ directory, its usually /home/username/ so your path should probably be:

export PATH="$HOME/.composer/vendor/bin:$PATH"

then execute this to load the file:

source .bash_profile

or open a new terminal


You'll want to use the strongarm module. That will expose the variables that logintoboggan stores it's settings in to features. When building your feature it will add an option for "strongarm: variables" to the edit components section.
You will need to know the actual internal variable name. You can get that by either looking at logintoboggan's code or from the field names in the settings page's html source.


How can I overwrite uploaded file via Filefield?

As a technical exercise...programatically speaking, you would need to replace the element's #value_callback, currently file_managed_file_value(), with a custom one.

Your custom callback would invoke another custom function, a rewritten version of file_managed_file_save_upload(), which would then invoke file_save_upload() with FILE_EXISTS_REPLACE as the 4th parameter, as opposed to the current value of FILE_EXISTS_RENAME.

Real-world, you don't want to do this. As soon as someone uploads an image to a different node, it will obviously overwrite the existing one called image.jpg, and that new image will be used in place of the existing one for all other nodes.

That's why the renaming functionality exists in the first place; to avoid global collisions.


I am not aware of a contrib module to achieve this, but you can always use jQuery in your theme or custom module.

Something like this might work (not tested, but that's the main idea - out of scope for Drupal Answers):

jQuery(document).ready(function() {
  // on link click (jQuery 1.4)
  jQuery('#my-link').click(function(e) {
    // preventDefault otherwise browser will go to link
    e.preventDefault();
    // show the pop-up layer which is assumed hidden with css or sth.
    jQuery('#my-popup-layer').fadeIn();
    // here you can possibly chain up more actions in order to
    // update the contents of the pop-up
    // now delay 3sec
    jQuery(this)
      .delay(3000)
      .queue(function(next) {
        // redirect
        window.location.href = jQuery(this).attr('href');
        next(); // prob redundant
      });
  });
});


Can't change my custom logo for Bartik-theme. How to fix this?

Silly me. There exists global settings / bartik settings etc. I was convinced i used global settings all the time but nope, and if you specify a bartik logo, it overrides the global one. Thank you for trying to help me.


Call preprocess_node (or get variables) from Twig template?

You're pretty close. I think there are a couple of approaches to this. This is what I would do

preprocess the lessons entity reference field for the courses bundle, iterate through the values, check the access, set a variable with the access value for each item. Then in field--field-lessons.twig.html, render the field if the access value is true.

<?php
//the name of your lessons entity reference field on courses
function THEME_preprocess_field__field_lessons(&$variables) {

  if($variables['element']['#bundle'] == 'courses') {
    $account = \Drupal::currentUser();
    $ent_refs = $variables['element']['#items']->referencedEntities();

    foreach ($ent_refs as $key => $ent_ref) {
      $check = $ent_ref->access('view', $account);
      $variables['items'][$key]['my_access'] = FALSE;

      if ($check) {
        $variables['items'][$key]['my_access'] = TRUE;
      }
    }

  }
}

then in field--field-lessons.twig.html

...
{% for item in items %}
    {% if item.my_access == TRUE %}
      I'm Unlocked: {{ item.content }}
    {% else %}
      I'm locked :(
    {% endif %}
  {% endfor %}
...


drush - which folder for install on VPS / root server (newbie)

You didn't say much about the distribution you're using. but i would suggest searching for a package for your Linux distribution. Installing it that way usually is the safest and easiest. There is one for Debian/Ubuntu and Gentoo as far as i know.


Traditionally that's what hook_requirements() is for

  Check installation requirements and do status reporting.

Emphasis mine.

It's how modules declare that they are missing a required Javascript library, for example.

It hooks your module into the status report at /admin/reports/status.

Drupal doesn't have a mechanism for displaying messages in response to a requirement failure; so if you need to show something to the user, hook_node_view() makes as much sense as anything else IMO.

Actually that's not strictly true (I didn't read the docs properly)...hook_requirements() does already handle that in one way or another. From the docs relating to the 'runtime' phase:

  any requirement with a severity of REQUIREMENT_ERROR severity will result in a notice on the administration configuration page.

So if your users have access to the admin config page you can use this hook to automatically display them a message. But if the message needs to be on a different page, you'll have to take a different route with the advice in @FreeRadical's answer.


Display content type images using taxnomy

I would try removing your Content: Related Products filter criteria.

Make sure your contextual Content: Nid filter is setting the default from the content ID in the url, and under "More" this filter is set to exclude.

Add another contextual filter for Content: Has Taxonomy Term ID. Select "Provide default value" and use type PHP Code:

$node = menu_get_object();
$terms = array();
if (empty($node->field_related_products)) return;
foreach ($node->field_related_products[LANGUAGE_NONE] as $term) {
  $terms[] = $term['tid'];
}

return implode('+', $terms);

Under "More" for this filter, enable "Allow multiple values"

Under "Other > Query Settings" select "Distinct"


Is it possible to create a pre-filled select list field with Drush?

You can create select field also from drush command. Just type the command from drupal root directory drush field-create content_type_name and hit enter key and follow the instruction. Please see the attached screenshot.

Copy the last output which is edit url of your field where you can  refinement your field.


Minimum entity properties for field_attach_update()?

EDIT - Actually, it turns out that the core team have decided that passing in anything less than the whole entity to field_attach_update() is officially Wrong and not to be done. See http://drupal.org/node/1483736, if there is a file field (therefore, also media fields, image fields), and you update using field_attach_update() without including all the file field data, the file fields will be wiped.

So the correct answer in terms of the thinking of the core team is actually, all of them. As far as I know, it's only file fields that break like this, so you theoretically, in cases where passing in the whole entity object breaks, you could pass in entity id and bundle as below plus any previous file fields, but there's no guarentee nothing else would break.

Original answer -  Actually after more testing and debugging, that first article seemed to have it spot on. The entity needs:

The entity id (as above)
The bundle (as above)
The field data, keyed with language (even if not applicable) and delta

(basically, so there's enough data to identify the entity and field instance)

...so my example above should have had:

$lightweight_entity->field_some_field[LANGUAGE_NONE][] = array(
      'some_key' => 'some_data'
      'another_key' => 'more_data'
      );

And if the field name is dynamic, needs curly braces:

$lightweight_entity->{$field_name}[LANGUAGE_NONE][] = array(
      'some_key' => 'some_data'
      'another_key' => 'more_data'
      );

Another relevant thing to note is, on a multi-item field, it replaces all items with what is entered here, regardless of what you put for the delta. E.g. if you have 5 items already, and try to add a sixth like this:

$lightweight_entity->{$field_name}[LANGUAGE_NONE][6] = ...

...it'll wipe the other 5. So, for multi-item fields which can already have data, you need to populate the mini-entity with all the items for that field before saving, for example:

if (!empty( $entity->{$field_name}[LANGUAGE_NONE])) {
  $lightweight_entity->{$field_name}[LANGUAGE_NONE] = $entity->{$field_name}[LANGUAGE_NONE];
}
$lightweight_entity->{$field_name}[LANGUAGE_NONE][] = ...


How to include js library from /sites/all/libraries in twig template with attach_library?

There was likely a module that required the files in question to be added to the sites/all/libraries folder.  You could review that module on how it adds those files as libraries.  Check that module for a .libraries.yml file or check to see if the module implements hook_library_info_build().  Once you know the how to reference the library, you should be able to use the same reference in your twig template.

As an example, the Easychart module (https://www.drupal.org/project/easychart) has both a .libraries.yml and implements the hook in it's .module file.  To reference one of those libraries you would use "easychart/easychart.render" or "easychart/lib.highcharts"


Since fetchAllKeyed() internally uses foreach loop to sort the data, the answer given by  Suranga Panagamuwa Gamage to use fetchAssoc() and then a loop seems the most efficient way.


How to set views configurations settings on custom module install?

It is not possible to change or override configuration from other modules like that, you can only provide new, not yet existing configuration in config/install. The only exception to that rule are install profiles.

Instead, you need to implement hook_install() and alter the configuration there. See locale_install() for example:

\Drupal::configFactory()
  ->getEditable('views_ui.settings')
  ->set('ui.show.master_display', TRUE)
  ->save();


One option is you can user php function in tpl file before print.

strip_tags($user_profile['field_nom']);

Refer http://php.net/manual/en/function.strip-tags.php


REST GET ResourceResponse returns encoded json

Kevin was on to it.  It was being double encoded.  I have to return a response, so I decode the results from the first api, then return it as a json response:

return new JsonResponse( json_decode($file_contents) );


execute drush command from devel/php drupal

Someone tried to create a module to provide shell access from within a Drupal site, but it was never fully debugged. See the Drupal Terminal project.  Perhaps there have been advances in the jQuery terminal that might make it easier to get this working if someone revisited it.

If you want to exec Drush from within php, it is generally better to use drush_invoke_process() rather than exec("drush ...").

$values = drush_invoke_process("@site", "cc", array("all"), array("verbose"));

If you are just running a one-off command and you don't care about the command results, then exec("drush ...") is fine, though.


You can implement template_preprocess_comment() in your module file or theme's template.php file. And check if comment has Parent Comment ID (pid), if yes then remove reply link.

/**
 * Implements template_preprocess_comment().
 */
function [MODULE/THEME_NAME]_preprocess_comment(&$variables) {
  $comment = $variables['elements']['#comment'];
  if (!empty($comment->pid)) {
    unset($variables['content']['links']['comment']['#links']['comment-reply']);
  }
}


How to use ip to visit AcquiaDevDesktop's site?

Ok, i get it. I installed Acquia Dev Desktop and tried it out. This is what I think is what has happened and what the problem is:

You installed Acquia Dev Desktop and entered parameters about the default site that comes with Acquia (this is required during installation - so this must have happened). This site is what you reach when you from another computer enter 192.168.0.1

You created the daxuebao site via Acquia Dev Desktop application and entered "Sitename" as daxueabao and you did not enter a "URL Path" so the result is that "Site Path" then becomes "daxuebao.localhost:8083". This means that the Apache software in Acquia Dev Desktop will examine every request it receives and determine if it should go to (a) the default site or (b) the daxuebao site.

The problem is that the daxuebao site is local and that your client computers on the LAN does not know where "daxuebao.localhost:8083" points... the have no knowledge of what IP number that corresponds to and if you enter just 192.168.0.1 the Apache software will determine that to be a request for the default site. The only site that is not local is the default site.

There are basically 3 different ways of solving this problem (which one depends on your need):

Solution 1: add a DNS record to the local DNS if you have one (I don't think you do) or

Solution 2:  add a DNS record to the hosts file of all of your client computers (see more at www.howtogeek.com/howto/27350/beginner-geek-how-to-edit-your-hosts-file/ ) or

Solution 3: move site duxuebao to the default site so that Apache servers that codebase and data instead. Make sure you backup files and database before you do it. I can tell you exactly how to do it if you tell me what operating system you are using.

Added in response to comments:
I would do it like this:

Oh, by the way. Acquia Dev Desktop works out of the box on port 8082 and not 8083, just to be sure here, you're not working with multiple installations of Acquia Dev Desktop? If not then:

1 Backup the daxuebao site:

1.1 Open the Acquia Dev Desktop control panel

1.2 Click the Settings button

1.3 Click the Sites tab

1.4 Highlight the daxuebao site

1.5 Click Export button, select "to file"-option to download a copy to your Desktop.

1.6 Backup done (files and data)

2 Backup the default site:

Note: Do this just to be sure.

2.1 Open the Acquia Dev Desktop control panel

2.2 Click the Settings button

2.3 Click the Sites tab

2.4 Highlight the localhost site

2.5 Click Export button, select "to file"-option to download the export to somewhere.

3 Replace the default site FILES with the daxuebao site FILES:

We cannot use the Acquia Dev Desktop import feature here unfortunately because the default site is reserverd/protected. We need to do the copying manually of files (step 3) and data (step 4):

3.1 Stop servers in Acquia Dev Desktop from it's control panel

3.2 Delete all files in /Users/YOUR-COMPUTER-USER-NAME/Sites/acquia-drupal/sites/default

3.3 Copy all files in /Users/YOUR-COMPUTER-USER-NAME/Sites/acquia-drupal/sites/daxuebao.localhost to /Users/YOUR-COMPUTER-USER-NAME/Sites/acquia-drupal/sites/default

3.4 Start servers in Acquia Dev Desktop from it's control panel

3.5 File copy complete.

4 Replace the default site DATA with the daxuebao site DATA:

Both sites default site and daxuebao are now using the same database. That's not good because if you delete the daxuebao site then the data will disappear. So we need to copy the data from database daxuebao to the acquia default database.

4.1 Extract the files downloaded int step 1.5 on the desktop ( it will extract to /Users/YOUR-COMPUTER-USER-NAME/Desktop/daxuebao.localhost ). This folder contains data and files.

4.2 Go to the In the Acquia Dev Desktop controlpanel click button "Manage my database" and a browserwindows with phpMyAdmin will appear.

4.3 Select the database acquia_drupal in left part of the window. In the right part of the window all tables in the database will appear.

4.4 Go to the bottom of the page in the right part of the window and select "check all" and

4.5 delete the tables by using the dropdown to the immediate right labeled "With selected:" and select "Drop".

4.6 Confirm deletion.

4.7 Now, we're going to import the data from the daxuebao site

4.8 Click on the tab "Import" at the top of the right hand window.

4.9 Click button "Choose file".

4.10 Navigate and select the datafile daxuebao.sql thats in the /Users/YOUR-COMPUTER-USER-NAME/Desktop/daxuebao.localhost directory.

4.11 Click button "Go"

4.12 Data copy complete.

5 Change settings-file for default site to look at correct database table

5.1 Open settings.php in /Users/YOUR-COMPUTER-USER-NAME/Sites/acquia-drupal/sites/default directory

5.2 Change
    $base_url = 'http://daxuebao.localhost:8082';
to
    $base_url = 'http://localhost:8082';

5.3 Change
    $db_url = 'mysqli://drupaluser@127.0.0.1:33066/daxuebao';
to
    $db_url = 'mysqli://drupaluser@127.0.0.1:33066/acquia_drupal';

5.4 Change
'database' => 'daxuebao',
to
'database' => 'acquia_drupal',

5.5 Verify by going to the site from your local computer

5.6 Verify by going to 192.168.0.1:8083 from another computer within the LAN

5.7 If all looks fine then your default site in Acquia Dev Desktop is now using it's own database "acquia_drupal". You can now safeley delete the daxuebao site from your Acquia Dev Desktop controlpanel.

BR / Fredrik


The instructions on how to apply a patch are given, for that module, on http://drupal.org/project/fb/git-instructions.

First off, git patches can be applied to a git repository you need to locally clone, which means you need to execute the following command:

git clone --recursive --branch master http://git.drupal.org/project/fb.git

Then you copy the patch in the fb directory created from the previous command, and execute the following one:

cd fb
git apply -v fb_stream.admin_.inc_.patch

Once the patch is applied, you delete it.

rm  fb_stream.admin_.inc_.patch

This assume the patch is applied to the development snapshot. If this is not the case, then somebody needs to provide a patch for the development snapshot.

Anyway, the patch doesn't apply. If you try applying it, you will get the following error:

  Checking patch Users/johnrobens/Downloads/fb/fb_stream.admin.inc...
  error: Users/johnrobens/Downloads/fb/fb_stream.admin.inc: No such file or directory

You need to change the patch to the following one, to avoid that error.

--- fb_stream.admin.inc
+++ fb_stream.admin.inc
@@ -1,5 +1,6 @@
 <?php

+
 /**
  * Form callback for general settings.
  */
@@ -19,7 +20,8 @@
             '%user_name' => $from['name'],
             '%token' => $token,
           )));
-    } catch (Exception $e) {
+    }
+    catch (Exception $e) {
       fb_log_exception($e, t('Unable to query graph with fb_stream token.'));
       drupal_set_message(t('There was an error using the current access token, %token.  Consider generating a new token.', array(
             '%token' => $token,
@@ -29,7 +31,7 @@

   if (!empty($_REQUEST['code']) && empty($_POST)) {
     // Send user to this URL after token is generated.
-    $redirect_uri = url(request_path(), array(
+    $redirect_uri = url($_REQUEST['q'], array(
       'absolute' => TRUE,
       'query' => array(
         'client_id' => $_REQUEST['client_id'],
@@ -59,7 +61,7 @@
   );
   foreach (fb_get_all_apps() as $fb_app) {
     // Send user to this URL after token is generated.
-    $redirect_uri = url(request_path(), array(
+    $redirect_uri = url($_REQUEST['q'], array(
       'absolute' => TRUE,
       'query' => array(
         'client_id' => $fb_app->id,
@@ -92,7 +94,7 @@
       'client_id' => $app_id,
       'client_secret' => $fb_app->secret,
       'code' => $code,
-      'redirect_uri' => $redirect_uri,
+                  'redirect_uri' =>$redirect_uri,
     ),
       ));
   $http = drupal_http_request($path);

Even if you do that, you would get the error, "patch doesn't apply." I tried applying it to the development snapshot 7.x-3.x (the master branch for git).


CSS is the right solution if you have a fixed set of icons you want to use. If you need full control over the images for each node, you can add an image field and use the rewrite results settings to insert the image before your field. In this case, you would hide the label altogether.


How to remove 'Main Menu' from my mobile view (using Superfish)?

Go to admin/structure/block and look for Main Menu (should be in the Superfish region).

Click configure and set the title to not display. As the instructions for the Block title field say:

  Override the default title for the block. Use <none> to display no title, or leave blank to use the default block title. This field supports tokens.


Yes, having hundreds of pages also results in hundreds of caches. Not just for your cache, but also for any block that varies per URL.

That's how it is, no way around it. Except not caching at all.

Note that with remote content, you need to think about cache invalidation (Well, you need to think about that anyway, but it's different with reomote content). You have two options:

Use a short cache expiration time. That also helps with the amount of cache entries, as they will get deleted when they are expired
Or you need to find a way to get notified when changes happen in the remote system or check for changes in a background process to invalidate your cache entries.


Have you tried going to the blocks administration page and checking which blocks/menus are being shown where?  This will allow you to locate the one that you don't want displayed; if it's a menu, you can then go to the menu administration page, find the menu in question, and delete the home page link from it.

Make sure you visit the administration page for the theme that is causing the problem; block placement is configured separately for each theme.


Tweet a published content on twitter from Drupal 7

Have you created the Twitter app with the correct permissions? By default apps are only created with read-only permissions


custom entityreference widget not saving field

For one, in your hook_field_widget_form, the $element should be built with a Union (like $element += array(...)) and not replaced. Refer this example at the api page.


Some content is not displaying on one of my Drupal 7 pages

I figured it out. The new field was initially set to hidden inside the manage display tab of the "full content" (instead of the default).


How to trigger an email to someone who opens an account but never signs in?

Yes there is a way to use the Rules module for this (as the tagging of your question seems to indicate), as detailed below ...

Step 1 : Create a Rules Component to send an eMail

Create a Rules Component  (say "Rule1") for sending an eMail that corresponds to the eMail you have in mind "... for letting him know about your products and services ...". This Rules Component itself will not do anything on its own. Instead it will be used in a subsequent step.

Have a look at "Step 2" of my answer to "How to send an email to an author on a specific date using date field specified in a node?" for an example of such Rules Component.

If you have multiple types of eMails in mind, then create 1 such Rules Component for each of them.

Step 2 : Schedule an eMail reminder

Create a rule (say "Rule2") which uses Rules Event "After saving a new user account" to schedule the execution of the Rules Component created in Step 1, e.g. X days after the new account was created.

Have a look at "Step 3" of my answer to "How can I set a reminder for a specific user to be triggered on a specific date?" for an example of how to schedule the execution of a Rules Component. More specifically the part in the Rules Action that starts with "schedule" (for this ignore the part with "schedule_delete").

If you have multiple types of eMails in mind (e.g. 1st eMail after X days,  2nd eMail after Y days, 3rd eMail after Z days) then schedule the execution of all these Rules Components right away. Or create a chain whereas the 1st Rule Component (for after X days), will schedule the 2nd Rule, etc.

Attention: if you're planning for multiple eMails, you should use some 'convention' to identify the scheduled eMails. E.g. by using an "identifier" (within "schedule") that is not just "[account:name]", but instead something like (e.g.) "[account:name]-1", "[account:name]-2" and  "[account:name]-3".

If nothing happens (i.e. if such newly created user never logs in, you have your desired eMails in place for being sent after X (and or Y, and or Z) days.

Step 3: Cancel eMail reminders when user logs in

Create a rule (say "Rule3") like so:

Use Rules Event "User has logged in".
Add a Rules Condition using "Data value is empty" to check if account:last-login is actually empty. If that's the case, it implies this user logs in for the very first time, which is exactly what you are interested in. Because from then on, you don't want to send the scheduled eMails anymore.
Add a Rules Action to delete (cancel) the scheduled eMails. Have a look at "Step 3" of my answer to "How can I set a reminder for a specific user to be triggered on a specific date?" for an example of how to delete (cancel) the planned execution of a scheduled Rules Component. More specifically the part in the Rules Action that starts with "schedule_delete" (for this ignore the part with "schedule").

Attention: if you're planning for multiple eMails, you should use some 'convention' to identify the scheduled eMails to be deleted (cancelled). E.g. by using an "identifier" (within "schedule") that is not just "[account:name]", but instead something like (e.g.) "[account:name]-1", "[account:name]-2" and  "[account:name]-3". And of course make sure these identifiers match with the convention you've used in Step 2 (to schedule those eMails).


Adding a 'search tips' link next to the search button in a views-based search

You need to:

Find the specific view exposed form by using the #id array key.
Find for the search button array key.
Use the #suffix form key to append your link.

A helpful tool to look into the array structure is by using the dsm() function from Devel module.

Additional information for best practice is that use the l() function to structure your link.

So it would look something like:

if ($form['#id'] == 'views-exposed-form-test-page') {
  $form['submit']['#suffix'] = l(t('Search tips'), 'link-to-basic-page');
}


Devel's dpm needs two refreshes to display message from (pre)process

This is a common issue people encounter when themeing Drupal (it used to drive me crazy).

In basic terms what's happening is that the messages held in the $_SESSION super global have already been committed to the page by the time the template file containing your call to dpm() is invoked.

This means that the messages are added to the $_SESSION but aren't dumped out to the messages area until the next page...as $messages has already been set up for/printed in page.tpl.php.

The normal way to get around this is to invoke the dpm() at an earlier stage of the process, like in hook_page_alter() as you mention, or hook_node_view(), etc.

Also I think if you implement your preprocess hook at the module level, rather than the theme level, that your calls to dpm() will happen in time for the messages to be displayed in that particular page request.


I don't know where $nodeids comes from, but I expect it's an array of nids from a database query? If so, you're effectively running a view with a view and can probably get away without writing any code for hooks.

Therefore, you can either:

Sort the $nodeids yourself with uasort() which will mean probably returning more fields to sort with and maybe writing your own comparison function.
Let Views handle all of this, thus gaining access to the UI and all it's powers.

The latter 'view within a view' approach is better for sustainability and sanity because it uses the Views UI and theme layers more consistently. A good approach that's worked for me is:

Make a view that can either:

return the properly sorted $nodeids, or;
get it to take an argument of a comma-separated list of nids you can pass implode(',', $nodeids) to.

use Views PHP to add a field that can contain your views_embed_view($view, block_1, $nid), probably with $nid replaced by $row->nid but will depend on your setup.
Add any sorting or sorting code to the view you want.


How to show a block on user/uid but not on user/login and user/registration?

Enable the PHP module, and use this for block visibility settings:

<?php
return (bool) menu_get_object('user');
?>


Same drupal webform is showing error messages in two different way, on different palces in the same website

Try to use Webform Validation module. I hope through this you can solve your issue.

  This module adds an extra tab to each webform node, allowing you to
  specify validation rules for your webform components. You can create
  one or more of the predefined validation rules, and select which
  webform component(s) should be validated against those. By using the
  hooks provided by this module, you can also define your own validation
  rules in your own modules.


CCK Select List widget with "Add another item" functionality?

Try one of these modules

Select (or other)
CCK Select Other


Search API: sorting with Scandinavian alphabet

I believe your question is more tailored to Solr rather than Drupal persay.

I'm using Solr, but not with any special language semantics for Sorting required.

It appears as though solr can be configured to support the kind of alphabetical sorting you requested via a Plugin and a special field type. See the section entitled Unicode Collation on this reference page:
https://cwiki.apache.org/confluence/display/solr/Language+Analysis

Once your Solr instance is configured to support the ICUCollationField field type. You then need to tell Drupal to make use of that field for analysis/sorting. So either in D8 you need to implement some of the below modifications:

alter the Solr Field type that fulltext searches are indexed with to use the ICUCollationField instead of the default fulltext field supplied by Search API using the Search API hooks.
OR, use the copyfield technique described in the Solr reference page under Sorting Text for Multiple Languages, and use the Search API copy field functionality to clone the default fulltext into this collation aware field.

then alter every search performed by your site using Search API hooks to override the Sort parameter to use the collation field.

Your request will likely require a full Solr re-index of all your Nodes, and if you use copyfield be aware the index may be much bigger.

These are some general approaches you can attempt using Search API and Solr. I'm not 100% sure they'll work, but they're the 2 approaches I'd try if I was setting this up.

Any feedback, success or failure is welcome to your original post once you've figured it out.


if you don't want to disable the feed, but just remove the icon.

According to FiNeX comment in Disable RSS icon in Drupal 8 via Views > Frontpage

  A better way to remove the icon leaving the RSS feed active is to
  simply disable the feed attachment option.

  1) Structure > Views > Frontpage Edit

  2) Click on "Feed" tab display

  3) Click on "Page" next to "Attach"

  4) Uncheck "Page"

  5) Save

Now if you want to disable RSS, then

According to couturier in Disable RSS icon in Drupal 8 via Views > Frontpage

  Go to Structure > Views > Frontpage > Edit

  Then click on "Feed" at the top. In the second drop-down box, select
  "Disable Feed." Then "Save" the change.


One option is to have a multidomain setup where forum.yourdomain is your forum installation and www.yourdomain is your main portal. Then you could have a single sign on for both domains.


Inject variables from Controller to Blocks?

You can't inject variables from a controller to a block.

Generally it would help to put the repository in a service, so that you don't have to instantiate it multiple times and are able to cache product objects queried before.

In this case you don't even need to call the repository in each controller/block, because Drupal upcasts entities to objects in routes and you can get the object directly from the route match, as long as the product entity is using the standard way to generate entity routes with param converter.


Do you have the devel themer enable? I have the problem with some filters lately..it was not displaying the filter. The problem was that I have the devel themer enable..
Are you using ubercart or commerce? if you are using commerce make sure to have associate the taxonomy with the display..here it is a little reference, that video helped me with my taxonomy and give me the right path Building a Drupal commerce catalog


Including Part Template within a Custom Module

There should be a change to the theming documentation in this case. Namespace for twig is always set to MYTHEME/templates or MYMODULE/templates.

The directory variable is to ACTIVETHEME/templates.

So if you look at how the Symphony folks have been do things, you will find out they have their template parts in a subdirectory named parts rather then a sibling directory named includes. Use the subdirectory will fixed your problem. BONUS you can use @ to call the namespace of your module or theme like this:

<header>
  {% include '@MYMODULE/parts/header.html.twig' %}
</header>

Remember to keep your template part name(s) unique from the templates in use by your Drupal install to avoid them being used as a full template item that overrides something provided by core or another module.


Is it possible to enable the title field for the module views slideshow?

Consider looking at Views Slide show Content title and description modification, which details the steps to do this, such as:

Set the title field to "exclude from display".
Check the option "Rewrite the output of this field".
Put the token in a DIV, and style with CSS as needed.


I had to re-install to get it to work, AFAIK.
The data_table is initially empty, but gets filled up as soon as you start creating a few of your custom entities. But the table itself should be there.

What exactly the data_table is for, I'm clueless as well, as pretty much everything worked without declaring it.

I couldn't however get the Entity Autocomplete ( see here for more info/example ) form element to work without declaring the data_table.
As soon as I added the annotation, the autocomplete element worked by declaring #target_type => 'my_custom_entity'


How to get the distinct number of the nodes?

If you want to retrieve distinct number of the nodes of content type $type.
Try this.

use Drupal\Core\Database\Database;

//- Retrieves a \Drupal\Core\Database\Connection which is a PDO instance
  $connection = Database::getConnection();
    $query = $connection->select('node', 'node')
        ->fields('node', array('nid'))
        ->condition('node.type', $type, '=')
        //- Force filtering of duplicate records in the result set.
         ->distinct()
        ->countQuery()
        ->execute();

    $count = $query->fetch(\PDO::FETCH_NUM);

Ps: you still have to add Your desired innerJoin to the query take a look to Select::innerJoin .


Symlinked folder not recognized by file_exists?

I kept digging and found it was related to Drupal's stream wrapper implementation, specifically the getLocalPath method. There's already a large Drupal issue for this, which I wouldn't have found with my previous search terms.


Another approach would be to create a Gift Wrap product class.    Create a node of this custom type with the price of your gift wrap option.     Then create a view of the custom Gift Wrap entity and display it prominently as a block on your cart and checkout pages.


Multiple instances of a field, differently formatted - how?

I would use Panels. You can add each field as many times as you want and pick a different formatter every time.

Install the Chaos tool suite (ctools) module, and Panels.
Enable the Page Manager and Panels.
Enable the node template
Create a variant of type "Panel".
Pick a suitable layout.
Go to the "Selection rules" settings and add a "Node:type" setting so this is used for a single node type.
Add your fields and select your formatters.
Save

Using Panels requires a bit of understanding of the tools it provides. There are a few videos here.


Is it possible to backup created block as a module?

Exporting and importing blocks in Drupal 8 are quite easy (thanks to new configuration system). You don't need to create a module for this. In Drupal 8 configuration is stored in yml files. You can export and import it on the following page:

Administration >> Configuration >> Development >> Synchronize >> (import / export) >> Single item

It works for all kind of blocks except "Custom blocks" because they are actually not a configuration but content like nodes, comments etc. As a workaround you can use Simple block module mentioned above.

Note, that in some cases you also need to export block configuration dependency in a separate yml file. For instance for a block that shows five recent content titles you need to export underlying view and all its dependencies. You may also checkout Features module for some advanced configuration package tools.


Ubercart - how to get order information from order ID?

Using the Ubercart API at api.ubercart.me, it is

$orders = uc_order_load($orderId);

$orders is an array, so $order = $orders[0];

See:
http://api.ubercart.me/api/drupal/ubercart!uc_order!uc_order.module/function/uc_order_load/7


According to the View, to add more people into this display you need to adhere to the filter criteria the View is filtering on.

So, it looks like you need to:

Create a new node of Leadership Team
Fill out the fields
Set the 'Role' field to Leadership Team
Set the node to to published

You should now see it show up in the list.


Background Process Module Limitations and Efficiency?

Background Process uses set_time_limit() to control the timeout of the subrequest. It defaults to 0 (php script does not time out, i.e. runs indefinitely).

background_process_start_locked('dontrunconcurrently', 'mymodule_dosomething', $myvar1, $myvar2);

This should be used when you want to ensure that your background process wont run concurrently with itself. In reality the "dontrunconcurrently" is used as a key for a lock.

Background Process has no internal mechanism per se to control serial execution of background processes.

For serial execution of background processes you could take a look at Background Batch, which allows you to run standard Drupal batch jobs as background processes, or you could maintain a state within your background process function.


I would comment this, but I do not have the reputation. If you are using jQuery Update module, make sure it is set to 1.5 for the admin pages.


This was likely a file-naming conflict of sorts. ImageCache (the module responsible for generating the image styles) generates a file name for each image style, and then checks for the presence of that file. If the file exists, it is served to the browser, otherwise it is generated and then served.

If you had a file called fruit.jpg that resulted in an image style of /files/styles/some/folder/fruit.jpg, and then deleted the source file, it is possible that the derivative style file wasn't removed (keep in mind, this a theory). If you then uploaded a different image with the same fruit.jpg filename and tried to generate the same image style again, ImageCache would find the previous /files/styles/somes/folder/fruit.jpg and serve that, resulting in the confusion you're seeing.

That said, I do believe derivative image styles get deleted when the source image is deleted, but I'm not sure of the specifics (ex. timing - it may happen during a cron run which wasn't ran).

For the most part, I wouldn't worry about it. Sounds like a onece in a million edge-case.


The simplest way of get an emerging modal window

You can check one of the module:

Splashify
Pop-up announcement
Popup On Load


Send email after term is selected in checkbox in a node form with rules

You need:

An "Entity has field" condition to check for the existence of the taxonomy field, and then
A "Data comparison" condition to match the value of the taxonomy field to the one of the three terms on which you want the rule to operate.

You have two Events in your rule. It seems if you put the Field Collection condition first, then the node fields aren't available in Rules, and vice-versa. So list the "After updating existing content of type Online Application Form" event first so that you can access the taxonomy field in the conditions.


Set view's filter to show nodes of entity refference field of current node

What you want is views' right column.

You need to use a contextual filter of Content: nid, choose to provide a default value Content id from url. If you want to suppress the current product (eg. for a related products display use the Exclude option in the More fieldset at the bottom.)

Then add a relationship and select your entity reference field.

Finally you can add the field Content: rendered node and at the top choose your newly created relationship. This should give you a list of referenced products.

Update: I guess the exclude option takes no effect in this case, since you'll be only listing the referenced products.


From managed file ID to end-user link - neat and clean way?

I'd personally prefer something like this:

// Extract file IDs so we only run one file_load().
$fids = array_map($mystructure['files'], function($x) { return $x['fid']; });
$files = file_load_multiple($fids);

$build = array();
foreach ($mystructure['files'] as $file) {
  // Update the description
  $files[$file['fid']]->description = $file['name'];

  // Add to the build
  $build[] = array(
    '#theme' => 'file_link',
    '#file' => $files[$file['fid']],
  );
}

return $build;

A bit cleaner/more performant, and using as much core API as possible.


PDO expecption error while adding class to the block with sql server

Instead of install one module for this, you can just use the ID for that block and create your custom css.

Example:

div#block-block-10{
    background-color: blue;
}

I think that could solve your problem


Installation profile similar to openatrium but focusing on projects

Not an install profile, but there is a good module for that (6 only), called Storm.


Colorbox plugin installed but status report is not recognizing it

Sometimes what happens with these libraries is that the download you get from the library site (colorbox in this case) packages its code in a folder itself. For the master download of colorbox, for example, the code comes in a folder called colorbox-master. If you unpack it into

sites/all/libraries/colorbox

then the code ends up in

sites/all/libraries/colorbox/colorbox-master

What you may need to do is unpack it into

sites/all/libraries

and then rename

sites/all/libraries/colorbox-master

to be

sites/all/libraries/colorbox


Database 4 byte UTF-8 support not properly checking

I fixed it by manual setting the drupal_all_databases_are_utf8mb4 variable to true. You can do this by using drush or setting it in the database and then clear all caches.


Why would my hosting account user name show up in page not found errors in my logs?

Something is obviously refering "http://domainname.com/user/https://domainname.com/user" so I would search for the log entry for that access and follow the referrer further. I'm guessing something is generating a bad link somewhere. And something else follows that link (could be GoogleBot).


How do I programmatically create a view whose structure is defined at runtime?

Ok - no answers and I've figured out two ways to do this.

1. hook_views_default_views()

One way is to define the view in hook_views_default_views() and then to rest the cache for instance with views_invalidate_cache(). These views end up being 'in code' but not actually set.  This didn't seem like the most desirable method for my use - but might be better for some applications.

2. save the $view

Create the view e.g. $view = new view(); and fill all the fields, and then $view->save() saves it to the views database. Keeping a record of the name of the view allows you to delete it later if necessary etc.


Code for getting node created date.

$date = $variables['node']->getCreatedTime();
  // Here you can use drupal's format_date() function, or some custom PHP date formatting.
  $variables['date'] = \Drupal::service('date.formatter')->format($date, '$format');// enter date format in $format.


Show node only to node author and author that is referenced by node

You could use Node Access User Reference for this task:

Gives content access permissions to users for content that references the users with User reference or Entity reference.
This is great if you want your content authors to be able to choose additional authors, or choose who can view their content, as well as being able to display the list of authors or viewers within your content, or in views displays.

Or you could use OG groups for something like this as well: https://www.drupal.org/project/og It may be a little harder to setup at first but certainly more a more flexible option.


If you're comfortable with the views module, I would recommend adding a view that displays the user profile the way you want it and using that as the right part of the panel.  In the view, just add the fields you want displayed-- if you don't want the user profile picture, simply don't add it.


I figured this out by making decisions in the settings.php file.  I have a switch statement that gets the url and then sets a table prefix variable and then that determines the db name, the db password and the prefix.  The default is to share everything if something is not found.


It's been a little while for me and it was tricky at the time, but enabling these modules should help:

Multiple Forms
Media Multiselect (provides a "Media Multiselect" widget instead of the standard Media Browser)

There was an additional patch to Media and a plethora of other issues (mostly related to permissions and editing files) that I noted as resolved as of 2014-Sep.

As you point out in the comments, a patch to the Media Multiselect module was still required to get the most recent dev versions of Plupload and Media 2.x working together by changing the widget type to that provided by Media Multiselect:

Patch (required for now but under review): Issue #2216273: Latest media changes break the multiselect (Comment #52)

Cheers -


How to fetch fields related to node in view templates?

In my opinion it's better to write a template preprocess for your view in yourtheme.theme file. hook_preprocess_views_view()

function yourtheme_preprocess_views_view(array &$variables) {
  if($variables['view']->id() == "your_view_id") {
    if (isset($variables['rows'][0]['#rows'])) {
      $nodeValues = [];
      foreach ($variables['rows'][0]['#rows'] as $value) {
        $nodeValue['taxonomyValues'] = $value['#row']->_entity->field_taxonomy->entity;
          :
          :
        $nodeValues[] = $nodeValue;
      }
      $variables['node_values'] = $nodeValues;
    }
  }
}

Above, is a sample code for fetching a taxonomy reference field. Fetch required fields and pass it in your own variable to views-view.html.twig file

To further give template suggestion for views-view.html.twig use

function yourtheme_theme_suggestions_views_view_alter(array &$suggestions, array $variables)

In your views-view.html.twig

{% for value in node_values %}
   {{value.taxonomyValues}}
{% endfor %}


Here is the full solution that allowed me to separate the content into a traditional calendar mock-up on a node--events--html.twig:

{% if node.field_date_range.value %}

  {{ node.field_date_range.value|date(format='l')  ~ ' thru ' ~ node.field_date_end_range_value|date(format='l') }}
{% else %}
  {{ node.field_date.value|date(format='l') }}

{% endif %}

{% if node.field_date_range.value %}

  {{ node.field_date_range.value|date(format='M')  ~ ' thru ' ~ node.field_date_end_range_value|date(format='M') }}
 {% else %}
  {{ node.field_date.value|date(format='M') }}

 {% endif %}

 {% if node.field_date_range.value %}

   {{ node.field_date_range.value|date(format='j')  ~ ' thru ' ~ node.field_date_end_range_value|date(format='j') }}
 {% else %}
   {{ node.field_date.value|date(format='j') }}

 {% endif %}


You might want to use token_replace.

You can use it like this:

$token = token_replace('[order:products:0:node:author:uid]', array('order' => $order));

So $order is your order.


It is definitely possible, and some of the functionality you need already exists.

I would go the route of creating a new field widget for a standard user reference field that tackles limiting the possible list to current friends.

Have a look at user_relationship_views hook_menu implementation for an example of how you would do the user lookup (in this case we're looking up relationship types but you can get the idea). I think the code for doing this with standard user fields in views is pretty straightforward as well if my memory serves me correctly. To find all the relationships with the current user look at the api docs for user_relationships_load().

User relationships already comes with invite module integration (invite user x with y relationship attached to the invitation). The ui isn't that stellar but I'm guessing you could squeeze it into a node form with a little work.


I'm not saying this is the best or correct way to do it, but I think you could use hook_file_url_alter to change the url for your script and stylesheets:

 function hook_file_url_alter(&$original_uri) {
      // rewrite url for your javascript files
      if(strstr($original_url, 'sites/default/files/your-script.js')) {
          $original_url = 'http://example.com/js/your-script.js';
      }
 }


Call to undefined function node_load_multiple()

If you call node_load_multiple() from hook_boot(), then the function is not found because at the time hook_boot() is invoked, only the modules implementing it are loaded. Once Drupal completes the bootstrap, all the enabled modules are loaded, and you can call every function implemented by those modules.

The same is true when you call node_load_multiple() from your own PHP file that doesn't bootstrap Drupal before to call any Drupal functions.

Suppose that you have a example.php file that is invoked as http://example.com/example.php; if the file doesn't contain the following code, then Drupal will not bootstrap, and every Drupal function is not available.

define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

In other cases, you should not get the error you are getting. The only possibility is that the node.module file got corrupted when it was copied, but at that point I would expect something else to not work too; for example, if the content of node.module is corrupted, and  node_load_multiple() is read as ode_load_multiple(), then you would get the same error when you are looking at a node page (e.g., http://example.com/node/1).

As side note, hook_boot() has been removed from Drupal 8; if you are using that hook in Drupal 7, you will need to change your code, since it would not work anymore with Drupal 8.


I think this is the answer I was looking for:

function hook_entity_info_alter(&$entity_info) {
  $entity_info['entity_type']['view modes']['custom mode'] = array(
    'label' => t('Custom view mode'),
    'custom settings' => FALSE
  );
}


How to programmatically alter feed item values before saving

Thanks to No Sssweat, I managed to use an EventSubscriber using afterParse event to do this job.

File 1: mycustommodule/mycustommodule.services.yml

services:
 mycustommodule.feeds_subscriber:
   class: Drupal\mycustommodule\EventSubscriber\FeedsSubscriber
   tags:
     - {name: event_subscriber}

File 2: mycustommodule/src/EventSubscriber/FeedsSubscriber.php

<?php

namespace Drupal\mycustommodule\EventSubscriber;

use Drupal\feeds\Event\FeedsEvents;
use Drupal\feeds\Event\ParseEvent;
use Drupal\feeds\Feeds\Item\ItemInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
 * Subscriber to Feeds events.
 *
 * This happens after parsing and before going
 * into processing.
 */
class FeedsSubscriber implements EventSubscriberInterface {

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[FeedsEvents::PARSE][] = ['afterParse', FeedsEvents::AFTER];
    return $events;
  }

  /**
   * Acts on parser result.
   */
  public function afterParse(ParseEvent $event) {

    /** @var \Drupal\feeds\FeedInterface $feed */
    $feed = $event->getFeed();
    $feed_bundle_name = $feed->bundle();

    // Only alter a particular feed
    if ($feed_bundle_name == "MY_FEED_IMPORTER_MACHINE_NAME") {

      /** @var \Drupal\feeds\Result\ParserResultInterface $result */
      $result = $event->getParserResult();

      for ($i = 0; $i < $result->count(); $i++) {
        if (!$result->offsetExists($i)) {
          break;
        }

        /** @var \Drupal\feeds\Feeds\Item\ItemInterface $item */
        $item = $result->offsetGet($i);

        /**
         *
         * My custom code here using $item->get() and $item->set()
         * to alter whatever values I want.
         *
         */
      }
    }
  }
}


I found this article:

http://ykyuen.wordpress.com/2011/09/13/drupal-customized-user-registrationloginforgot-password-page-with-panel/

Which describes how to workaround this issue with Panels.

This worked well for me, didnt take long at all, but it seems a little hackish. If anybody knows a better way please let me know.


How to migrate a real real messy Drupal setup to a fresh, new, well structured and totally new stable environment

I think the Migrate module will help you a lot


You could try a modification of this: found it here.

<?php
function theme_form_comment_form_alter(&$form, &$form_state, &$form_id) {

  $form['actions']['submit']['#type'] = 'image_button';
  $form['actions']['submit']['#src'] = base_path() . path_to_theme() . '/img/button-off.gif';
  $form['actions']['submit']['#attributes']['title'] = t('Create Comment');
  $form['actions']['submit']['#attributes']['onmouseover'] = "this.src='" . base_path() . path_to_theme() . "/img/button-on.gif'";
  $form['actions']['submit']['#attributes']['onmouseout'] = "this.src='" . base_path() . path_to_theme() . "/img/button-off.gif'";

}
?>


Override comment.tpl.php file with theme

You should be able to override Drupal's default comment.tpl.php file by copying it from /modules/comment into your theme directory. From there, edit the file as needed. Then clear the cache (on the Admin > Site configuration > Performance), so that the theme cache will get rebuilt and your new theme file will get recognized.

You would only need to rename comment.tpl.php to comment-[type].tpl.php, if you wanted to override comment theming differently for different node types.


Migrating existing groups from Commons 2.x to Commons 3

Commons maintainer japerry is in a team that created
Commons Migration module exactly for your task.

Posted by nateswart on March 18, 2013 at 9:46pm
Provide a migration path from Commons 2.x to 3.x

It uses Migrate with Drupal-to-Drupal data migration to get the job done. Sadly, it's still in early development, and according to this feature request not quite finished yet. But at the very least you can see in code what approach original developers use.


How do I set the height and width for images that use a responsive images style?

The code for this is actually pretty simple.
There are a few important points.

For this to work, all of the responsive images in a single responsive image style must have the same aspect ratio. They can have different heights and widths, but the aspect ratio must be the same.
You have to set the height and width to be the maximum possible (the height and width of the largest image in the responsive image style).

Assuming your responsive image style has a machine name of hero, here's some example code:
/**
 * Implements hook_preprocess_responsive_image() for MYMODULE.
 *
 * {@inheritDoc}
 */
function MYMODULE_preprocess_responsive_image(&$variables) {
  $style_id = $variables['responsive_image_style_id'];
  if ($style_id === 'hero') {
    // Set the height + width to the aspect ratio for all images.
    // Use the largest possible height + width that may be displayed.
    $variables['img_element']['#attributes']['height'] = 450;
    $variables['img_element']['#attributes']['width'] = 800;
  }
}


How to create search indexes by path in Drupal 8?

I was able to resolve the issue by using the Views, not through the search indexes as I initially thought was the path for a solution.

Created a required field for the content-types that would be searched against. Let's call it Section for now, with the values of Employers and Employees. This will be used in the view to filter content by section. (Taxonomy terms can be used for this as well.)

Then created a view page for each section.

In the view, used Content for the row style with Search result highlighting input option, and sorted content by Search: Score (asc).

The real trick for this to work is enabling Search result highlighting input display mode and configuring it with the fields we want to be searched within.

Hope this helps who needs a similar solution in their projects.


Changing node values directly to database exhibits erratic behaviour

The safest way would be adding field data and saving it with node_save. If you write it to the database, you have to also duplicate the record to the revision table of that field and keep track of vids. The API will just do this for you. You do not (should not) write field data via db_insert or other functions like it. Doing so may irreparably harm your database.

To apply the data retroactively, I would advise that you create a batch op via Batch API. Query up all nodes, create batch operations, and in your batch callback, process the node and save it with node_save.

There is a docs page on getting started with the Batch API.

Here is a blog post that demonstrates a basic batch job that is close to what you'd want to start out with. You'd want to populate the $operations array with node ids, and every time the batch callback is called, the node id is passed. Then you load the node with it, set the field, then save the node.

edit: tutorial author also provides a Drupal 8 version.


how to theme content type based on context

Here is a complete solution

Installing context module we can create a context which comprise of conditions which if they are met they do the specified reactions
Installing entity_field_condition will let as set the desired condition
Add context (lets name alternative theme section)
Add Node Field (entity_field_condition) and select category name and choose the specific value that corresponds to the desired category (tid since we are talking about term reference).
Add reaction theme and choose the theme that you want to be activated on above conditions

NOTES:
At the time of writing this entity_field_condition needs a patch to work properly with entity reference (as is the case of category field).  The patch can be found here

term condition was not working at the moment (buggy was not able to add the condition it was giving WSOD)

Alternatives would be to write my own custom condition or debug the term condition module or write my own theme negotiator


Are you using any Drupal performance optimizations on the site that's the source of your imported database? This article suggests turning them off and gives a query to accomplish that.

Once you've got your local site up and running, I also suggest trying the Backup and Migrate module to manage your data migration. You can create a backup profile that omits your live server's cache data, which makes for a smaller backup file and may mitigate the problem you're having now.


Translation has duplicate admin content listings

Yes, that's expected - until filters are applied, that page is designed to list all content on the site, and separate translations are considered separate content.
Assuming you had 10 translations for each piece of content, yes, you'd see 10 times the number of listings as you would if you didn't have the translations.
That page is powered by a View. You can edit that View and do what you want with it - there's a language filter, maybe you want to set the default for that to the default language, thus allowing people to still browse the other translations using the filters if they want, but keeping things to the default language for most cases. Maybe you want to leave it as-is, but add a "Language" column, to make it easier for admin users to distinguish. There are a lot of options so you can probably get it configured in a way that makes sense for you.
No, there's no other way to translate content.


how to show all alphabates in glossary block in drupal 7?

Did you check this module?

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

It provides exact same functionality.


REST Web Services - Return all fields from Content entity association

RESTws will retrieve your content using an Entity Metadata Wrapper. By default, this won't retrieve the referenced node. To get the nested content you'd need to write your own resource class in a custom module.

The new resource class is registered with hook_restws_resource_info().
 In your resource class, extend RestWSEntityResourceController or just implement RestWSQueryResourceControllerInterface (You can see the default implementation here.)

Your new resource class would look something like this:

class MyCustomResourceController extends RestWSEntityResourceController {

  /**
   * Override the wrapper method.
   */
  public function wrapper($id) {
    $wrapper = entity_metadata_wrapper($this->entityType, $id);
    /**Add something here to add the referenced node */
    return $wrapper;
  }

}


How to get menu title inside menu--main.html.twig file

You could try using the Simplify Menu module (which extends twig to support direct access to Drupal's menus for overriding markup).

See the example in this related thread: https://drupal.stackexchange.com/a/228982/79832


Adding "Create New Node" link in views pages

It's possible without writing any PHP etc. and you'll need one of the modules mentioned Entityreference prepopulate, Prepopulate, etc.

Add Global: Custom text to your fields, in the Text field enter Apply Now!
Under Rewrite results, check Output this field as a link
In the Link path field enter node/add/candidate (this will get passed through the l() function and correctly deal with subfolders, etc.)
Add Global: Unfiltered text to your header/footer, etc. in the Text field enter [nothing], check Display even if view has no result and check Use replacement tokens from the first row
Test this is working correctly and Exclude from display the Global: Custom text in your fields
Play around with the Link path field to correctly pass the correct variables so your fields are populated correctly - this will probably require trial and error to get this correct which is why this is the last step.


If all you are trying is to add a menu item in main menu, you can implement hook_menu, code something as below.

function my_module_name_menu() {
  $items['test'] = array(
    'title'           => 'Tes Page',
    'description'     => t('Test'),
    'menu_name'       => 'main-menu',
    'weight'          => 8,
    'access callback' => TRUE,
    'page callback'   => '_my_module_name_test_page',
    'type' => MENU_NORMAL_ITEM,
  );

  return $items;
}

function _my_module_name_test_page() {
  return "hi";
}

Key is to have 'menu_name' => 'main-menu', in menu item declaration.


Drupal adding some sort of hash on end of clean URL?

This seems very similar to this topic in Wordpress:

http://wordpress.org/support/topic/random-hashtag-strings-added-to-url-in-firefox

Did you had the "Share this" module installed?


Add preview button on Taxonomy add/edit term form

Preview button added by node module in NodeForm as action in actions method:

$element['preview'] = [
      '#type' => 'submit',
      '#access' => $preview_mode != DRUPAL_DISABLED && ($node->access('create') || $node->access('update')),
      '#value' => t('Preview'),
      '#weight' => 20,
      '#submit' => ['::submitForm', '::preview'],
    ];

The Taxonomy entity form created by TermForm.php so i think you should:

Extends TermForm.php in another Class.
Add actions method.
Create a preview method like the node preview method but for the term.
Add a route subscriber to tell drupal to load your form not the default.


Link pages from a child term to it's parent

Node will have relation with the child term but there is no direct relation between the node and parent term.
So i think there are two ways to do it..
ONE : use node api and attached the parent term with the node.
TWO : while displaying the node fetch the parent term of the term and show them as well.


How to use the value of a field in a filter criterion?

You could write a custom Views filter plugin to handle your use case, I have found WebOmelette's tutorials invaluable over the years, and he has a great one for D8 Views filters: https://www.webomelette.com/creating-custom-views-filter-drupal-8. This will allow you to fine tune the query to your needs and do any kind of filtering that isn't available out of the box.


You can't really have dynamic menus that point to different things. You can write a deriver and so on, but that will be persisted and not updated until you tell it to. You can trigger the necessary updates also without a full cache clear, see how MenuLinkContent does it, but it's still persisted.

Another approach would be to not make the route/output dynamic and not the menu. Point to a custom controller, and there you either dynamically display the latest node (can easily be done with a view, for example) or you redirect to the latest content, to avoid duplicate content.


How to determine if user X has access to operation Y on node Z

This was easier than it seemed:

$current_user_has_access = $node->access();

This function has an optional parameter where you can pass an arbitrary user account, which defaults to the logged in user (suits my purpose).


Composite elements do not support file uploads. If there is a finite amount of documents you could manually build a table. The Table element was recently hidden because it was impossible to document. Here is an example of table layout within a Webform.


The best way to update existing Paragraphs in Production with newField = TRUE

For a no custom code solution, Use Views Bulk Operations with Views Update Fields
Or with Views Bulk Edit, although it's crashing with Paragraphs, so maybe in the future for this particular  case.
PS: Do first a dry run on dev/local before doing it on live.


How can I add a custom "Date" field as a field in a view?

I'm not sure why you're having trouble.  I just did this and it worked.  Here's what I did.

Add a "Date" field (widget: select list) to Content Type A.
Create a view that shows items of Content Type A.
Click Add next to Fields and search for the label for my "Date" field.

You should try looking through/searching your list of fields again.  It should be there.  (Even when a view is filtered to a specific content type, the Views module will often allow you to select fields that are not associated with that content type.)


Problem drupal with domain and redirection

The problem could be in several areas, depending on your deployment method.

First of all, have you cleared your caches?  This fixes most issues, especially after importing a database.

It could be a server configuration issue, did you set it up or did someone else?  There could be version differences between the installed software on the dev and prod servers.

Lastly, have you tried setting the $base_url in your settings.php?


How do you pass more than one node to a route?

You can specify the upcast type for parameters manually:

wlh_decision.solution:
  path: '/solution/{solution_node}/{species_node}/{problem_node}'
  defaults:
    _content: '\Drupal\wlh_decision\Controller\SolutionController::displaySolution'
    _title: 'Solution:'
    _title_callback: '\Drupal\wlh_decision\Controller\SolutionController::solutionTitle'
  requirements:
    _permission: 'access content'
  options:
    parameters:
      solution_node:
        type: entity:node
      species_node:
        type: entity:node
      problem_node:
        type: entity:node

See Using parameters in routes for a slightly more in-depth explanation.


Custom field for Search API with multi values

You can add this:
foreach ($fields as $field) {
    $field->addValue($custom_field);
    $field->addValue($custom_field);
}


function act_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'the_id_of_your_form') {
    unset($form['submitted']['#attributes']['alt']);
    $form['submitted']['#attributes']['data-alt'] = 'abc';
  }
}

Won't this work?


How to remove some comments from a node?

Apparently, the comment metadata populated after node_load comes from comment_node_load(). But indeed the comments themselves aren't added until view time at comment_node_view(), which calls comment_node_page_additions() which adds the renderable comments, which calls comment_get_thread() to load the cids.

So perhaps it would take adding vid column to the comment table, and then adding vid condition in comment_get_thread...hmmm.


Region with block shows up in admin preview, but not on site

You've to allow anonymous use to access the search form, to add this permission, you've to go People > Permission and search "Search" and check the box "Search content".


First of all, instead of using taxonomy, I would recommend a module like Entity Reference or References to create links between 'download' and 'product' nodes. I think Entity reference is your best bet in this case, because the module page explicitly says it supports "Integration with Views (for both forward and backward references)".

Once you have defined the download-product relations, you can build your view. The key to your solution is the concept of "contextual filters". A contextual filter is a filter with a variable filter value. You will find the settings for it in the right column when editing a view. I can't give you detailed instructions because I don't have a test site with entity reference here, but you'll need to take the following steps:

create a view, listing nodes of type 'download' in a block
add a contextual filter on the entity reference field in your download nodes
when configuring the contextual filter, under "When the filter value is NOT available" choose "Provide default value" -> "Content ID from URL".

So what does this all mean? You now have created a view that will only display download-nodes where the entity reference value is equal to the content ID detected in the URL.

Now, try if it works by enabling the block on product pages. Good luck - I hope this helps.


How to configure trusted patterns for localhost:8082/d8multisite.com?

The trusted_host_patterns settings is only for the domain name used to access the site. The regular expression you use must not include neither the port used to access the site, nor any path. If you access the site using as localhost, then the setting you should use is the following one.
$settings['trusted_host_patterns'] = array(
  '^localhost$',
);

If the site is accessible either as localhost or d8multisite.com, and you want to be able to access the site using both of them, then you should use the following setting.
$settings['trusted_host_patterns'] = array(
  '^localhost$',
  '^d8multisite\.com$',
);

Since the dot has a special meaning in a regular expression (it matches any single character), you need to escape it, so it is considered a normal character. To do so, you need to use . not /..