Drupal Content Access and if anomynous show login block

This depends what method is used to create the page. Pages that  are created by the Views module define the permission settings in the "Access" configuration, as does page manager. But it sounds this is just a typical node page. Content Access should do the trick, but if not, you may want to try the Node Access module instead. Be sure to read the README on these modules, as they usually require you to rebuild permissions after enabling and configuring them. The permissions of the node should be understood by the menu system, so restricted pages will not appear to un-authorized users, which should satisfy the need to hide the menu item. If un-authorized users do land on the page somehow (such as yourself, after clicking a bookmark after your session has expired), then you can try something like the "Redirect 403 to User Login" module Although, in my opinion, the more sensible option might be to simply define your default 403 (Access denied) page as the login page. The only reason not to do this might be if you are trying to obscure the login process from anonymous users for some reason.


List options without typing on autocomplete

A possible solution is to show the field as a select list and then use the chosen module to get the functionality of searching through the options.

From the module's description:

  You can force enable/disable Chosen for certain field widgets: Select list (for both list and date fields), and Select (or other) list. If you have a field using one of these widgets, in the field settings, you will find a Apply Chosen to the select fields in this widget? option with three values: Apply, Do not apply, or No preference (which will fall back to using the automatic application).


hook_field_views_data() not picked up in mymodule.views.inc

That appears to be the correct behaviour.

If you look at the code for field_views_data():

function field_views_data() {
  $data = array();
  foreach (field_info_fields() as $field) {
    if ($field['storage']['type'] != 'field_sql_storage') {
      continue;
    }

    $module = $field['module'];
    $result = (array) module_invoke($module, 'field_views_data', $field);

    if (empty($result)) {
      $result = field_views_field_default_views_data($field);
    }
    drupal_alter('field_views_data', $result, $field, $module);

    if (is_array($result)) {
      $data = drupal_array_merge_deep($result, $data);
    }
  }

  return $data;
}

You can see it only invokes hook_field_views_data() for the module that defines the field. So in the case of (what looks like) an addressfield, the function Views will call has to be called addressfield_field_views_data().

It's more likely you're looking for hook_field_views_data_alter() which will allow you to alter existing definitions.

But if that doesn't do what you need, you might have to actually define the addressfield_field_views_data() function yourself on behalf of addressfield (if it's not already implemented somewhere). Should be a pretty quick test to find out.


How to show tooltips using a bootstrap sub-theme in a views filter?

form['title'] needed to be replaced with the fieldname without "filter-".

function customisations_form_views_exposed_form_alter(&$form) {
  //drupal_set_message("setting exposed filter tooltips", 'status');
  //dpm($form);
  $allFilter = array();
  $filtersList = array_keys($form['#info']);

for ($i =0; $i<count($filtersList); $i++) {
    //drupal_set_message("filter " . $filtersList[$i], 'status');
    array_push($allFilter,$filtersList[$i]);
  }

  foreach ($allFilter as $field_name) {
    $fieldTitle = substr($field_name,7); //removes the filter-
    $form[$fieldTitle]['#attributes'] = array(
    'data-toggle' => 'tooltip',
    'data-original-title' => $form['#info'][$field_name]['description']
  );
  $form['#info'][$field_name]['description'] = '';
}
}


There is no such default functionality in drupal commerce.

Commerce Cart Ajax

This module will ajaxify your cart page. If you need this in product detail page then you can build a custom module for that with Ajax Api in Drupal 7


The "easiest" way to do this in Drupals admin panel is to set the menu titles as parent menu items and use "Show as expanded" settings (admin/structure/menu/item/yourmenuname/edit) and hide the menu-names with the block name settings (set to <none>)


How to sort/delete comments by a particular user?

Using Views Bulk Operations, you can create a view for all the comments written by a user, which allows you to delete all the comments written by a user without the limitation of deleting them in groups of 50 at time. When you click on the button to select the comments shown in the pager's page, you are asked if you want to select all the comments; in that way you can delete all the comments with a single click. As the view can be set to use batch operations, it is able to delete a great number of comments without any timeout.

You can create a view that is shown in the user profile page (as done on Drupal.org), or you can create a view that replaces the page shown in admin/content/comment. Being a view, you can filter the comments listed using different criteria, such as the content type of the node for which the comments have been created, the author of the comment, the author of the node to which the comment is attached, etc.

Views Bulk Operation doesn't come with a custom view to show the comments made from a user; it comes with a view that can be used to replace the page shown at admin/content/node. Using that view as example, you can easily build the view you need for the comments.


How do I control if an ajax webform has errors?

I when I normally have to debug this I use

Debugging ajax with FIREPHP

  Explaines how you can debug ajax with FIREPHP


site slogan in h6 following h2 site name not matching WCAG 2.0 requirements

Hooks won't help you with this - the markup for the slogan is in the region--branding.tpl.php template file:

<h6 class="site-slogan<?php print $class; ?>"><?php print $site_slogan; ?>

To fix, you can just create your own region--branding.tpl.php file in your sub-theme, and alter the markup to your needs.


the module services_views will help you expose the view as a resource in two different ways

It has currently two features:

Create view based resource creating Services display in a view
Execute any view of the system via views resource call


views_row_selector module - capturing a form submission

When using this module you need to write custom code to include a submit handler and use the results. See my inline Issue Queue links where the module maintainer describes this. This is code from a toy example i have sitting around:

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  // As per this issue responded to by the module author, we need to add our
  // own submit button and handler to make use of the data
  // selected in views row selector.
  //
  // https://www.drupal.org/node/1898842#comment-6984976
  if ($form_id === 'views_form_identity_search_page') {

    $search_had_results =
            count($form_state['build_info']['args'][0]->result) > 0;
    if ($search_had_results) {
      // some custom tasks I make up that could use the results as
      // arguments. Ideally these paths are Rules, Views or hook_menu stuff.
      $my_tasks = array(
        '/foo/bar' => 'report 1',
        '/foo/baz' => 'report 2',
        '/foo/bak' => 'report 3',
      );

      #$form['views_row_selector']['#required'] = TRUE;

      // Some magic to make horizontal form elements.
      // http://drupal.stackexchange.com/questions/7954/horizontal-form-elements
      $form['actions']['#attributes']['class'][] = 'container-inline';
      $form['actions']['my-task'] = array(
        '#type' => 'select',
        '#title' => t('Task to Perform'),
        '#options' => $my_tasks,
        '#weight' => -5,
        '#required' => TRUE,
      );

      $form['actions']['submit']['#value'] = t('Perform Action');
      $form['actions']['submit']['#submit'][] = 'ucsb_identity_selection_form_submit';
    } else {
      $form['actions']['#access'] = FALSE;
    }
  }
}

function MY_FORM_ID_form_submit($form, &$form_state) {
#  dpm($form_state, __FUNCTION__);
  $ids = array_filter($form_state['values']['views_row_selector']);
  // take the results, compact them as "1,2,3" for example and perhaps
  // redirect to a new Views page setup to use Contextual Filters
  // with arguments.
  $ids = @implode(',', $ids);
  $options = array('query' => array('identity_results' => $ids));
  drupal_goto('custom-user-diagnostics', $options);
}

good luck!


Using function of views_embed_view may caused high CPU loading

The function itself has not much to do with this, it is a wrapper for creating and displaying a view. The view you are displaying is a block - if you should have chosen to enable the block instead my guess is that the result would have been the same.

The most probable cause is the view you are displaying. Tools like views and panels are great at handling displaying stuff, but it comes at a price. They are usually a lot more ineffective than if you had done it with your own code, but they are also a lot faster to use. I would recommend that you review the view and try to find a way to reduce the workload by simplifying it, or if it's really important to you, do it yourself and skip a lot of the abstractions that Views bring.


When is a module shown as 'Unsupported' in the list of available updates?

In Drupal 8, that string is output from UpdateManagerUpdate::buildForm(), which contains the following code.

  case UPDATE_NOT_SUPPORTED:
    $type = 'unsupported';
    $entry['title'] .= ' ' . $this->t('(Unsupported)');
    $entry['#weight'] = -1;
    break;

The UpdateManagerInterface::NOT_SUPPORTED constant simply means the current release is no longer supported by the project maintainer. The maintainer doesn't intend to further develop the module code, not even to fix security issues. If you look at the project page, you will notice the following note, given under the Project information section.

  Unsupported
  Not supported (i.e. abandoned), and no longer being developed. Learn more about dealing with unsupported (abandoned) projects

As such, the update page is suggesting to find another module with the same, or similar, features because, in case of security issues, chances are nobody is going to fix them, and the module would need to be uninstalled, to avoid site issues.

In Drupal 7, a similar string is output from theme_update_status_label(), which contains the following code.

case UPDATE_NOT_SUPPORTED:
  return '' . t('Not supported!') . '';

The UPDATE_NOT_SUPPORTED constant has the same meaning saw for Drupal 8, and it was introduced in Drupal 6.


Multilingual views hide if no translation

The problem was that I was doing condition in views with field that wasn't translatable and views are adding join on langcode, thanks to user 4k4 that linked to this issue that can be found here.

I fixed this by removing untranslated field from view and hooking into hook_views_query_alter and adding relationship myself :

<?php

use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\query\QueryPluginBase;

function hook_views_query_alter(ViewExecutable $view,
QueryPluginBase $query)
{
    if ($view->id() == 'blog') {
        $definition = [
            'table' => 'node__field_content_type',
            'field' => 'entity_id',
            'left_table' => 'node_field_data',
            'left_field' => 'nid',
        ];
        $join = Drupal::service('plugin.manager.views.join')->createInstance('standard', $definition);
        $query->addRelationship('node__field_content_type', $join, 'node__field_content_type');
        $query->addWhere('1', 'node__field_content_type.field_content_type_value', 1, '=');
    }
}

Also this hook has to be in MODULE.views_execution.inc file


What's the default workflow for layouts in Drupal Bootstrap theme?

I see your concern with the "unsupported" classification, just because that's an immediate red flag when looking for a module to provide some sort of core-like functionality. Since Bootstrap is really a frontend tool, I'm less concerned, since I'm generally just using it for its responsive behavior. In the past, I've simply used templates and preprocess functions to wrap or 'bootstrap' my content. Also, I've always used Display Suite Bootstrap layouts, which has been helpful in previous projects that are handed off to clients. Since it's a theme of choice, I'm interested to hear other comments.

EDIT

Before anything, you'll need to reference the Bootstrap CDN in your header OR install a Bootstrap Starter theme. Then, you'll need to install Display Suite and the Bootstrap layouts (linked above). You can then manage the display of a content type and choose a Bootstrap grid layout to add responsive behavior to your content type. If you prefer to use a template file e.g., you can copy the page.tpl.php from the core systems folder to your theme's template folder and add Bootstrap classes and elements to the markup. For more specific elements, such as menus and images, use preprocess functions in your template.php file to alter the markup. See the example below:

Bootstrap a menu:

function THEMENAME_menu_tree__MENU_MACHINE_NAME($variables) {
    return '
' . $variables['tree'] . '
';
}

Bootstrap a block:

function THEMENAME_preprocess_block(&$variables) {
    $elements = $variables['elements'];
    $classes = &$variables['classes_array'];
    if ($elements['#block']->subject == 'BLOCKNAME') {
         $classes[] = 'col-sm-6' . ' ' . 'col-md-3';
    }
}

Hope that's helpful.


CKEditor/TinyMCE does not apper or show up at text fields

just a shot in the dark, but have you checked to make sure your text profiles are still correct? You may have to go in and reselect wysiwyg tools for your profiles.


Get the first instance of a field where it's not null from rows

Solved it, makes sense now!

public function get_first_instance($field, $rows) {

  foreach($rows[0]['#rows'] as $row) {
    $entity = $row['#row']->_entity;

    if($entity->hasField($field)) {
      $value = $entity->get($field)->getValue();

      if(! empty($value)) {
        return $value;
      }
    }
  }

  return dump('Field not found: '.$field);
}


Give permission to non-admin user to view and edit list of orders

After comparing the query being executed for the admin user and the non-admin user I found that 1=0 is being added to the commerce_orders view's query.

Further checking out the code, it seems that in the commerce.module file, the code expects either shipping or billing permission being granted to the user.

After adding one of them, the list was visible. I don't know why it's like this, List of orders must not expect that permission right?

TLDR; Adding the billing/shipping permission fixed the issue.


The Elements module provides an HTML5 number field element to the FAPI. You can use it like this:

$form['foo'] = array(
  'type' => 'numberfield'.
  'title' => t('Bar'),
  ...
);


Follow the procedure in the linked answer, which is, install the module Configuration Translation and add a translation to your view. Then you'll find these translation options:

EXPOSED FORM

FILTERS


How to clear CSS and Javascript with a bookmark?

In a custom module add a menu item (Using hook_menu) to function with this code:

drupal_clear_css_cache();
drupal_clear_js_cache();

Then you can just bookmark your custom page url. Or set a cron job to call that page at regular intervals if thats what you're after


There are a number of issues with your code. First, you are setting status as false, then activating. You don't need to set the status as false first. Just create the user, and set activate() on it.

Next, you are trying to set properties directly, like the created. You cannot do that in Drupal 8. You need to use the methods on the user object. So you would use set(). Other properties have methods for setting the property, such as setEmail(). You can view all the methods on the User object here: https://api.drupal.org/api/drupal/core%21modules%21user%21src%21Entity%21User.php/class/User/8.3.x

One other issue is that you are setting the UID. I don't believe you can do this, as the user ID is determined by the auto-increment value in the database, and trying to manually set it, if you can get it to work, will only cause you issues.


Pulling Breadcrumb items from the Menu Link text instead of Title field (D7)

It's been a while since we came to a resolution on this issue, so I hope I get everything right.

It seems that I was a bit confused w.r.t. what fields data was being pulled from for these areas (menu item, title, & breadcrumb item). Here's what we found:

Menu item text gets pulled from the "Menu link title" field in the "Menu settings" section of a page's editing interface.
The text in the "Title" field of a type is used for the breadcrumb item text and will be used as the page's title as well (i.e. the title displayed in the browser window's/tab's chrome) if no other title is specified.
The "Page title" field in the "Page title settings" section will override the "Title" field so far as the browser chrome title is concerned, but won't affect the breadcrumb.

IIRC, the "Page title" field was not active for the pages we were having trouble with, which was the cause of the confusion I was having.

It would be nice if instead of defaulting to "Title" for the name of this field, "Name" were used instead, as that's a bit more descriptive and would not lead to the confusion we had. The name of this field is changeable -- I'd recommend changing it to "Name".


How to validate links before moving to different location

You can achieve this using a client side validation. Like below,

Add an ID attribute to the external link

$form['new_user'] = array(
  '#type' => 'item',
  '#markup' => l('Add New User','http://www.google.com', array('attributes' => array('id' => 'external-link'))),
);

Add a JavaScript code to validate and preventi the click.

jQuery(document).ready(function() {
  jQuery('#external-link').click(function(event) {
    // Perform your validation. If the validation fails prevent events default behavior.
    validated = false;
    if (!validated) {
      event.preventDefault(); // You can also use return false instead of prevent default.
    }
  });
});

Hope this helps :)


Error in Submit handler for custom node add form

Found the solution. Needed to add print drupal_render_children($form); to the end of stories-node-form.tpl.php


To install gd library in ubuntu:

  $ sudo apt-get install php5-gd

Above command will install PHP gd library in Ubuntu.

Refer this question from Server Fault to install mysql-pdo driver in ubuntu


How to set the classes used in Drupal commerce buttons with Bootstrap theme

I'm having the same type of issue (which I will post elsewhere). I'm not sure I have the best answer, but from what I read in the Bootstrap API documentation, I believe your code should read as follows.

function [my-sub-theme]_colorize_text_alter(array &$texts) {
  // Let's try a dummy change for a test
  $texts['contains'][t('Update cart')] = 'success';
}

The preceding "hook" needs to be entirely replaced by your [my-sub-theme] name.
From what I read, that should be what is needed for this to work. However, I'm having trouble getting it to work myself.


PluginNotFoundException: "The "iframe" plugin does not exist." at core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php line 52"

removing manually the module and deleting the %iframe% entry in config table should do

it happens when  there's no definitition of the plugin

   /*protected function doGetDefinition(array $definitions, $plugin_id, $exception_on_invalid) {
// Avoid using a ternary that would create a copy of the array.
if (isset($definitions[$plugin_id])) {
    return $definitions[$plugin_id];
}
elseif (!$exception_on_invalid) {
    return NULL;
}

throw new PluginNotFoundException($plugin_id, sprintf('The "%s" plugin does not exist.', $plugin_id));

so what i understand is my custom module dont have a valid plugin manager !?

https://www.drupal.org/docs/8/api/plugin-api/d8-plugin-discovery


Create node link in views header and open in popup

I think you are looking for hook_menu_local_tasks_alter to create the 'add node' link.  As for the popup... perhaps you are speaking of the administrative overlay?  If that is the case and you have the overlay enabled, the 'add node' task should open in the overlay automatically.

You're probably looking for something like this (taken from this post):

function YOURMODULENAME_menu_local_tasks_alter(&$data, $router_item, $root_path) {
  switch($root_path){
    case 'path_of_your_page' : // for example 'page/view/news'
      $item = menu_get_item('node/add');
      if ($item['access']) {
        $data['actions']['output'][] = array(
          '#theme' => 'menu_local_action',
          '#link' => $item,
        );
      }
    break;
  }
}


In your view, under advanced there is a link called "Theme Information". If you open that up, there will be a list of all the different parts of the view that can be themed and a list of all the theme suggestions for each listed in order of broad to narrow.

You can create a theme file and naming it appropriately from the list of files in the theme information section. Once you've created the file, click on the "Rescan template files" button and the file you've created should be bold in the list.

Save the view and clear the cache.


It looks like hook_theme_registry_alter() is only executed when the theme cache is rebuilt. This means that what you need to do is use one of the theme_suggestion_alter hooks, such as hook_theme_suggestions_alter() or hook_theme_suggestions_node_alter(). These get run for each page before it is cached, I believe, instead of only once on cache rebuild.

So, what you want to do in your module is create a theme implementation using hook_theme(). That would look something like this:

function MYMODULE_theme($existing, $type, $theme, $path) {
  return array(
    'my_theme_implementation' => array(
      'path' => drupal_get_path('module', 'reveal_js') . '/templates',
      'template' => 'my_theme_implementation',
    ),
  );
}

And then your hook_theme_suggestions_node_alter() would be something like

function MYMODULE_theme_suggestions_node_alter(&$suggestions, $variables) {
  $is_admin = Drupal::service('router.admin_context')->isAdminRoute();
  $node = $variables['elements']['#node']
  if ($node->getType() == 'MY_CONTENT_TYPE' && $is_admin == 0) {
    $suggestions[] = 'my_theme_implementation';
  }
}

Does that all make sense?


How to set the behavior for Pathauto when a duplicate exists?

You could create a module and use the hook_pathauto_alias_alter function to override the path alias before saving it.

function mymodule_pathauto_alias_alter(&$alias, &$context) {

  $temp = $alias;
  $newalias = pathauto_alias_uniquify($temp, $context['source'], $context['language']);
  if ($newalias !=$alias)
  {
    $alias .= $context['data']['node']->field_city[$context['data']['node']->language][0]['value'];
  }

}

The pathauto_alias_uniquify function checks if there is an alias already existing and if it does then would return the updated alias and if not return the same alias. now the one you get it different from the one we already have then we would could append the city name to the alias.

I have created a field called city with a field machine name field_city you will have to change your values accordingly.


Time localisation - "@count hour" (ago) instead of "1 hour"?

The change you have made should work until you download and install an update to the drupal core language file.

The Drupal Localize site would allow you to download an check the latest versions of the  core language files to see if the bug also exists latest versions of 6, 7 and 8.

https://localize.drupal.org/translate/languages/cs

Perhaps you could sign up and posting a message into the Czech language forum on the localize site.  You can also find out more about contributing on the localize website.

https://localize.drupal.org


Error 500 (Internal Server Error) After Clearing Cache

Somehow your site has entered a broken state since the Views module depends on ctools but it's not enabled.

What you need to do to fix it is to:

Enable the ctools module in the database, by running the following SQL UPDATE system SET status = 1 WHERE name = 'ctools';
Truncate all the cache tables in your database.
(Might not be needed) run $ drush rr, requires drush and the registry rebuild extension.
Run $ drush cc all requires drush.

Going through the above list should fix your site. Messing with your sites cache table can be a bit dangerous if you don't know what you are doing since drupal caches what modules it needs to load for performance.

You can read more about and download drush and registry rebuild on drupal.org.


cannot enable module after DB migration, only in one environment

The system module builds this form in the function system_modules(). It disables a module in the UI under 3 conditions:

The module is required by your Drupal distribution.
The module is missing a dependency.
The module (or one of its dependencies) has version incompatibility with Drupal core.

In any of these cases, you can click the Description fieldset which shows the dependencies required and highlights the ones that are missing.

Another direct method is to utilize the Drush command:

drush en module_a

Drush will attempt to enable the module and alert you if module_a doesn't exist or it has unmet dependencies (which should help you track down what is missing).


I would not use a multisite for this.  Instead, I would do Option B (mysite.com/moto).

Then I would use the Themekey module to set up different themes.  If you want the two parts of the site to basically look the same, you can make the motorcycle part a subtheme of the theme you are using for the car part.

If you do this, then you don't have to worry about integrating the data; you will have two parts of the website that look different, but on the backend all the data will be kept together.


How can I display an element only if any value has been selected from an entity select field?

Got it! You need to check for a value greater than 0.
user:
  '#type': webform_entity_select
  '#title': User
  '#multiple': true
  '#target_type': user
  '#selection_handler': 'default:user'
  '#selection_settings':
    include_anonymous: false
    filter:
      type: _none
text:
  '#type': textfield
  '#title': Text
  '#states':
    visible:
      ':input[name="user[]"]':
        value:
          greater: '0'

I guess in PHP that must be:
$form['text']['#states'] = [
  'visible' => [
    ':input[name="user[]"]' => [
      'value' => [
        'greater' => "0",
      ]
    ]
  ]
];


There is. When a user's saves draft a token gets generated. You need to get their token value.

$webform_submission = \Drupal\webform\Entity\WebformSubmission\WebformSubmission::load($sid);
$token = $webform_submission->getToken();

Then, you need to generate a URL like this

$draft_url = '/form/webform-name?token=' . $token

and on login redirect them to that url.


8 - How to programmatically add terms to an existing Node

This is the correct long form, as in the comment of mradcliffe:

$node->get('abc')->appendItem(['target_id' => 123]);

You don't need to load the term, use the term id.

You can use shorter versions:

$node->abc->appendItem(['target_id' => 123]);
$node->abc[] = ['target_id' => 123];
$node->abc[] = '123';


How to change end date automatically after changing start date?

I did it the way pretty much mentioned in question with some corrections.

My code with javascript file is

// Change the end date value to same as that of start date.
Drupal.behaviors.form_modif = {
  attach: function (context, settings) {
        $('input#edit-field-event-date-und-0-value-datepicker-popup-0').change(function(){
        var field_date1 = $('input#edit-field-event-date-und-0-value-datepicker-popup-0').val();
        $('input#edit-field-event-date-und-0-value2-datepicker-popup-0').val(field_date1);
    });
  }
};

}(jQuery));


Why timestamp format was chosen for users.created field

Date/time types vary widely among different DB types. The purpose of the Schema API is to achieve some compatibility at the data definition level.

If you see this http://drupal.org/node/159605 the date/time is not supported in some database type.

So I would prefer to go the way the date module does it and use int if you want to make it compatible across multiple database types.


responsive tabs (tab to accordion on small screen width)

Short way : download Easy Responsive Tabs to Accordion Jquery plugin, add it to your theme and call the easyResponsiveTabs function for your HTML tabs markup.

Drupal Solution with Panels : use Panels responsive tabs to accordion, a sandbox project which provides a Responsive Tabs to Accordion Panel style.

Install Panels module.
Install the sandbox project. This was a quick done project (no time to develop the admin options) so you may have to modify a few lines in responsive_tabs.inc to set up the paths to css or js files and/or HTML markup in responsive_tabstoaccordion_panels.js.
Go to  your region Panel style and choose the new style Responsive Tabs to Accordion


How to correctly install PHPMailer + Messaging on Drupal 6

I have chosen to not use the messaging_phpmailer module and only rely on the PHPMailer module. It works now, but notification/messaging is a mess on Drupal (at least with the beta-versions I'm running). Users email addresses are copied from table users to table notifications(.destination) and table messaging_destination(.address), and sometimes it is not. Maybe it happened during update, but I had to manually update the two via SQL updates, before notification works,. Until I did, the log was filling up with PHPMailer errors 'Invalid Address'.
What's worse, when a user changes his e-mail, the subscriptions copies are not updated, so notifications are still send to the first email address.
You have to tell your users to unsubscribe before changing email, and then subscribe again...

Kind regards
The Roadrunner


How to create my own custom simple action in D8?

Action plugin yaml definitions need to be prefixed with the name system.action.action_name.yml, and not mymodule.action_name.yml.

For reference, check the provided action plugins for node and user module in core in their config/install and config/schema folders.

Uninstall the module, rename the files, and install the module again so the changes are picked up. You should then see your custom action.

So:

config/install/system.action.resolve_news_migration_flag.yml


How to show logout link at the top right corner for non admin user

Yo have to create a block to list all page. Then use code.

if (!in_array("administrator", $roles)) {
use logout link here(user/logout)...........
}

First you have to check whether the user is anonymous.


What is the proper way of retrieving and handling sessions when making multiple calls to the API?

Apparently the Services module submits a form in order to log a user in.  I expected /login to purely go through the backend.

Having said that, I disabled a module which hooked into my login form and now I am getting the expected results.


Update node revision time in hook_entity_presave

Make sure you don't call $node->save() in your presave, just update the time, the save will happen automatically.


Install Drupal in a subfolder of an existing website

Drupal and Magento both use .htaccess rules for functionality.   One slight quirk with Apache is that .htaccess is processed from a directory up through all of the parents.  This means that if your Drupal install is inside your Magento install, Magento's .htaccess may interfere with Drupal (a Magento directive may be applied after a Drupal one).  This is going to totally depend on your setup.  At very least, you will likely need to set RewriteBase in the Drupal .htaccess for things to work properly.  I have seen similar situations work perfecty fine, but others fail in bizarre ways.


How to modify ds_bootstrap_layouts templates to add more layouts?

Implement the following hook

function MODULENAME_ctools_plugin_directory($module, $plugin) {
  return 'plugins/' . $plugin;
}

You can change the name of the 'plugins' directory, but cannot change the following.

Next you create a folder inside the 'plugins' directory and call it 'layouts' <--don't change. Then place your custom layouts in that directory.
Your .inc file will look something like this

$plugin = array(
    'title' => t('LAYOUT TITLE'),
    'icon' => 'ICON.png',
    'css' => 'CSS_FILE.css',
    'theme' => 'NAME OF TEMPLATE FILE W/O .tpl.php'
    'panels' => array(
      'top' => t('Top'),
      'top_left' => t('Top Left Column'),
      'top_right' => t('Top Right Column'),
      'middle' => t('Middle'),
      'bottom' => t('Bottom')
  ),
);

Panels will automatically scan your layouts folder for new layouts. DONT FORGET TO CLEAR THE CACHE. Your new layout will appear in the 'Miscellaneous' section when selecting a layout for your panel.


You can use hook_field_widget_info().

Here you can give the widget settings.


How to manipulate some fields using Views PHP?

You'll want to put that code into a view template. Go into your admin, where you can edit that View, click on Advanced, and then Theme: Information. That will give you suggestions on the file naming conventions for the row style output for your view.

But as for your PHP code, Drupal uses a lot of nested multi-dimensional arrays, so it's not as simple as $row->field_authors being an array of strings of author names (unless you're doing some preprocessing). If field_authors is a term reference, you'll need to load the taxonomy term in order to get the actual author name.

This should get you the $names array:

$names = [];
foreach($row->field_field_authors as $author_tid){
   $term = taxonomy_term_load($author_tid[0]['tid']);
   $names[] = $term->name;
}
(... the rest of your code...)


Why does drupal set a menu link which redirects to a node as the active trail rather than the node's menu link?

The only working solution so far is to create a new node and add a global redirect from that node/nid plus url alias to "lorem/ipsum". This is really awkward...


More efficient use of function by storing the result?

Seeing as how the data is not really an item that is cachable sitewide, you could quite easily use the $_SESSION variable.

Example:

function my_expensive_function($foo, $bar) {
  if (isset($_SESSION['my_really_cool_stuff'])) {
    return $_SESSION['my_really_cool_stuff'];
  }
  else {
    //Do what you would normally do to get everything you need
    //and put it in a $my_really_cool_stuff variable
    $_SESSION['my_really_cool_stuff'] = $my_really_cool_stuff;
    return $my_really_cool_stuff;
  }
}

This way, if the data already exists in the user session, it'll return that.  If not, then it'll generate it, put it in the session, and then return it.

You can put the $_SESSION data into a theme function and make it available to templates as well if you wish, but that's probably a separate question (and you'd have to make sure you had a fallback in case the session data had not been set).


Embedded field collection not saving with node using conditional fields

I think, it's because field collection is not part of the node, field collection is a separate entity, which needs to be saved separately.

I once had to add up some number fields and save the value in a field collection field on hook_node_presave

/**
 * Implements hook_node_presave().
 */
function MYMODULE_node_presave($node)
{
  foreach ($node->field_collection_field[LANGUAGE_NONE] as $key => $value) {
    $fc_id = $node->field_collection_field[LANGUAGE_NONE][$key]['value'];
    $field_collection_item = entity_load_single('field_collection_item', $fc_id);
    $field_collection_item->save(TRUE);
  }
}


What are Text Filters and Input Formats?

These are called 'text filters', and a text filter is made up of 'input formats'. Input formats are defined in hook_filter_info().

You can read more about text filters here: https://www.drupal.org/node/213156


Show 1 random node out of the 5 most recent in views

I wasn't able to get this working within views proper, so I added a subquery instead.
There are three relevant things that need to be set up in your initial view to get this to work:

Filter Criteria: Content: Type = 'my content type' (blog post in
the attached image)
Sort Criteria: Global: Random
Pager: Use Pager: Display a specified number of items: 1

As it is, that will get you a view that will pull in 1 random result from among all content of type "my content type".
But the question is asking you to pull in 1 item from the last 5 created posts, not from all posts.
To do that, you need to add an additional where condition. That can be accomplished with this snippet:
/**
 * Implements hook_views_query_alter().
 *
 * Limits results to the most 3 recent blog posts.
 */
function MY_MODULE_views_query_alter(&$view, &$query) {
  if ($view->name == 'MY_VIEW_NAME' && $view->current_display == 'MY_CURRENT_DISPLAY') {
    $query->add_where_expression('AND', "node.created > (SELECT node.created AS created
      FROM
      node node
      WHERE  (type = 'MY_CONTENT_TYPE')
      ORDER BY created DESC
      LIMIT 1 OFFSET 5)");
  }
}

That snippet says:
"Find me the creation timestamp of the node that is the fifth-newest. Then filter my final result by nodes with creation timestamps greater than that."
There might be a better way, but this works for me.


How can I collect data through a drupal form?

I'd let users login first to prevent spam. However you could simplify the registration&login process by having users authenticate with OpenID (Google, facebook ect.) Similar as what stackexchange offers.

This should get you started: https://drupal.org/project/openid_connect


You can create all of the code yourself, but you could also use the menu block module instead and save yourself a lot of work.


Change and check

SMTP server: smtp.gmail.com
SMTP port: 587
Use Encrypted Protocol : Use TLS

Username: Your Email Id
Password: Your Password

For default email settings check

  /admin/config/system/mailsystem


go to:

/admin/config/content/ckeditor/edit/Advanced (for Filter HTML)

/admin/config/content/ckeditor/edit/Full (for Full HTML)

Then under Advanced Content Filter, select disabled.

If the above does not do it, depending on which one you are using (filter or full html) You need to go to

/admin/config/content/formats/filtered_html

OR

/admin/config/content/formats/full_html

try unchecking the correct faulty and chopped off html box.


How to login to an external website after drupal-login?

Yes, the login form has a redirection(see the \Drupal\user\Form\UserLoginForm::submitForm()), so you need to remove that redirection with $this->getRequest()->query->remove('destination').


Multilingual websites - Hiding site till ready

As long as you do not add se.www.mywebsite.com to the DNS nobody will find it.
You locally can add se.www.mywebsite.com to your hosts file and point it to a IP (maybe your localhost). When ready to be launched you can add a pointer from se.www.mywebsite.com to the IP of the production server.


How to redirect user when new node save by ajax in advance form block drupal 7?

A form[#redirect] will not work in an AJAX form.

You can use an AJAX redirect command from CTools: ctools_ajax_command_redirect

To do this, you should probably have to alter the form and use your own callback function returning the ajax command (along other needed data). I don't know advanced form block module so I can't say how difficult it is.

Example from http://dropbucket.org/node/1236:

  ctools_include('ajax');
  ctools_add_js('ajax-responder');
  $commands[] = ctools_ajax_command_redirect($path);
  print ajax_render($commands);


Why do my main menu tabs show up on two lines instead of one?

This is happening because of the CSS technique/code being used. Both <li> and <a> have been floated.

The first WOW item actually contains all the other WOW items as children, and it's reflected in the HTML structure, there is an <ul> inside the WOW <li>. Since <li> is floated but it hasn't been given a specific width, there are some cases that can happen, like this one, that seem a bit odd, but they're just following the code.

I guess the authors of that theme didn't anticipate the menu might be used in this way, to display two levels of menu hierarchy on one line.

Usually one level of the menu is displayed in one region, and deeper levels are displayed elsewhere or in a drop-down.

You could add two Main menu blocks to that region, and set one Block to display Initial visibility level and Number of levels to display to 1 and 1, and the other Block to 2 and 1. This way you'd get WOW and About in one row, but when you visit WOW a second row would appear with all the WOW-subitems.

If they are meant to always be displayed maybe it makes sense not to have two levels in hierarchy?

But in the end you can always adjust the CSS to make them display all on one row (you can use CSS edit module to override CSS if you don't have a subtheme):

.region-primary-menu .menu-item,
body:not(:target) .region-primary-menu .menu-item {
  float: none;
}

This will make them show on one row since now only anchors are floated. But the margin won't have affect so you'll need to add margin to the anchor elements instead, if you want them separate a bit like before.


Show cached pages with boost for logged in users

No, because it will break your site for logged in users. Try Authcache module instead.


Show specific field(s) from created content-type

You can configure this as a per content type level, not for each node in particular.

Edit the content type, go to Node Block settings and under Default view mode select a convenient value. Then, click on Manage presentation tab and select the same value you set previously under Default view mode, and finally configure the fields and positions you want to be rendered.


How to use Drush's concurrent execution capability?

This worked for me:

drush @site1,@site2,@site3,@site4 cc all --concurrency=4

I'm not sure how concurrent it actually was; the last message about site1 came immediately after the first message for site2, and all other messages were printed sequentially.  I did not measure to what extent each cc operation happened concurrently, or to what extent the system might have just been cpu or i/o bound, but it did seem to be nominally working.


Multiple menu locations in taxonomy menu

You can manually add menu items that link to the taxonomy terms as many times as you want - but that Taxonomy Menu option will only manage a single one.

You could potentially write a custom module that automatically inserts the same item into other menus at the same time - but that might be more complicated than you want.


Following Jeremy French reply, I must say that you can do it like this :

if(function_exists('views_get_page_view') && views_get_page_view()){...YOUR CODE HERE...}

Taken from here:

  views_get_page_view() finds out what, if any, page view is currently
  in use. If it returns NULL, then the current page is not a views'
  page.


EntityFieldQuery fieldCondition Date not working as expected

So it looks like the final issue I was having was the operators I was using. Had to go <= on value and >= value2. I had it the other way around before. Here is the code that worked.

$myDate = date('Y-m-d H:i:s');
$query = new EntityFieldQuery;
$query->entityCondition('entity_type', 'node')
      ->entityCondition('bundle', 'caregiver_db')
      ->propertyCondition('status', 1)
      ->fieldCondition('field_available_dates', 'value', $myDate, '<=', 0)
      ->fieldCondition('field_available_dates', 'value2', $myDate, '>=', 0);

$results = $query->execute();


How do you add a PDF attachment to an email?

FINALLY! 4 weeks later...

So the following code ended up working for me:

    $attachment = array(
        'filepath' => 'sites/default/files/MyFormsOfAssistance.pdf',
        'filename' => 'MyFormsOfAssistance.pdf',
        'filemime' => 'application/pdf'
    );

BUT, the key was that in the MailSystem Configuration I had to set the Formatter and Sender to "SMTP Mailer". MimeMail's config automatically pulled it's values from my SMTP's configuration.


Sounds to me like you're trying to call the drupal_add_js() function from within a node edit form (or maybe the body of a form).  Instead of that, just change the body's input filter to HTML (or whatever filter you have that allows <script> tags) and call the external JavaScript there as you would in any HTML page.  You don't need to use PHP for that.

I would add that that probably isn't best practice.  Using drupal_add_js() is, but you should use drupal_add_js() in page templates (e.g., node.tpl.php) or in preprocessor functions (e.g., hook_preprocess_node()).

As an aside: be very careful of the PHP input filter, it has major security implications.


How can I make a condition for currently viewed language on a template file?

In your template file global variable $language is avaible,with below properties

'language' => 'en',
'name' => 'English',
'native' => 'English',
'direction' => 0,
'enabled' => 1,
'plurals' => 0,
'formula' => '',
'domain' => '',
'prefix' => '',
'weight' => 0,
'javascript' => ''

You can achieve your jobs with something like this
// if global variable $language  not avaible uncomment first line

 //    global $language;
if ($language->language == 'en') {
   // do your desires
  }


How do I set the active menu item dynamically for a view?

You could use Context and set condition to be your view and reaction to be menu link.


Select fields from two tables using db_select()

Easy, just call fields() twice.

$query = db_select('table', 't');
$query->join('node', 'n', 'n.nid = t.nid');
$result = $query
  ->fields('t', array('tid', 'field1', 'field2'))
  ->fields('n', array('nid', 'field1', 'field2'))
  ->execute();

foreach ($result as $row) {
  // Do something with $row.
}

You can call most methods multiple times (multiple fields, multiple conditions, multiple sort orders, multiple joins, ...).

Note that, as shown in my example, the call to join() needs to be separate and can not be "chained" (that's the technical term for having multiple method calls in a row) because it does not return the query object but the name for the table alias.


How can I stop the full HTML editor from deleting my  paragraph?

Could be related to the auto paragraph funcitonality of CKEditor, which is used by default and can be disabled with this !deprecated setting:
"autoParagraph = false"

This can be easily disabled using the ckeditor_config module, see https://www.drupal.org/project/drupal/issues/3131055 for more information.
The whole paragraph wrapping in CKEditor is kind of buggy, you could also try these patches: https://www.drupal.org/project/drupal/issues/2876094 (but there the problem is an added p after an img)

I had some troubles when using linkit: https://www.drupal.org/project/linkit/issues/3162596 and made this core issue https://www.drupal.org/project/drupal/issues/3162605 (this is not related to your problem as your using the align and caption filters - but you see where the magic happens - on Drupal side).


How can we do open a popup for login facebook and after complete it will close?

You should try ulogin...
I hope this will solve your whole problem.
:)

Description:-
uLogin service allows your users to login using their accounts at:

Facebook,
Twitter,
Google,
Windows Live ID,
LinkedIn and various open id.


How to reset a site to its profile installation? D7

Yep. You can also check out Demo as it is very very much helpful during testing and playing around in local development. You can create a snapshot of a clean website with your settings and then do whatever you want; if necessary with a click you can roll back to the initial settings without reinstalling the whole site.

Keep in mind though that you can use and setup Demo only before you start playing around - it will save the current site in a snapshot.


Programmatically set Panelizer View Template on Node

It turned out the output of $node->panelizer->getValue(); was giving me a clue that I missed.

I had forgotten that there were different panelizer templates for different view modes.

I was able to accomplish what I needed with

    $panelizer_arr = $node->panelizer->getValue();
    for ($i = 0; $i < count($panelizer_arr); $i++) {
        if ($panelizer_arr[$i]['view_mode'] == 'full') {
            $panelizer_arr[$i]['default'] = 'test_display';
        }
    }
    $node->panelizer = $panelizer_arr;
    $node->save();


How to get the user entered input value to do calculation?

Store the loan amount in session when user submit the form1, and when rendering the form take that session value and display a suggestion field.

The code will be like below,

function form1_submit($form, &$form_state) {
  $_SESSION['loan_search_amount_field_value'] = $form_state['values']['loan_search_amount_field_name'];
}

function form2() {
  $form = array();
  $loan_amount = $_SESSION['loan_search_amount_field_value'];
  //db_query using $loan_amount
  //$db_result_array = db_query();
  $form['load_options'] = array(
    '#description' => t('Loan options'),
    '#type' => 'select',
    '#title' => t('Field type'),
    '#options' => $db_result_array,
    '#size' => 2,
  );
  return $form;
}


How can I use Rules to 'Set a Data Value' on a node's field WITHOUT updating that node's 'updated' timestamp?

If it is not necessary for you to use rules, you can also try to invoke the hooks node_update and node_insert.
There you can load the parent, change the fields value and save it with the field_attach_update function.

You can find an interesting article about this at https://www.urbaninsight.com/2011/10/24/saving-nodes-fields-without-saving-node-itself


Commerce View + Multiple products on product_reference field

If anyone need an image gallery for commerce, and you have a node referencing multiple product which have multiple images, Image zoom is the correct module.


There is no hook for 3rd party cookie removal, and there cannot be. You need to bootstrap Drupal and call user_logout().

You could also use hook_boot() to test for the cookie and logout if it's not there, but it is a bad idea - it may seriously hurt your performance and will not play nice with external caches.


How do I fill the authors name in a term reference field?

... I can't choose node:author or other tokens that display the user name. I get the restriction: "Data types: Select data of the type Taxonomy term."

1. Switch to the direct input mode

You should click the Switch to the direct input mode button (near the bottom left), which looks like this:

After clicking that button, it will bring up a selection list of the available terms (= possible values) that you can use in your taxonomy field.

2. Example

Consider this example, in Rules Export format, of a rule (actually a Rules Component, but the idea is the same) to illustrate how such Rules Action to "Set a data value" should look like and which will set the value of the term reference field field_sample_tags to term id = 31:

{ "rules_replace_a_term_field_by_another_term_field" : {
    "LABEL" : "Replace a term field by another term field",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "node" : { "label" : "Node", "type" : "node" } },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_sample_tags" } },
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_demo_tags" } },
      { "data_is" : { "data" : [ "node:field-demo-tags" ], "value" : "1" } }
    ],
    "DO" : [
      { "data_set" : { "data" : [ "node:field-sample-tags" ], "value" : "31" } },
      { "drupal_message" : { "message" : "Term updated in node with id = [node:nid]" } }
    ]
  }
}

Some more details to explain the above prototype:

It uses a node as a parameter (to execute the Rules Component).
These are the Rules Conditions:

check if the entity (= node) has a field field_sample_tags.
check if the entity (= node) has a field field_demo_tags.
check if the value of the field field_demo_tags corresponds to the term we want to replace (in this example, the term has id = 1).

These are the Rules Actions:

Set the value of field field_sample_tags equal to the term with term id = 31 (which is the term in the vocabulary for which we want to add the term reference).
Display a message on the site (only used for demo / testing).

3. Improvement - Pick the existing term that fits

Your question doesn't say "How to pick the appropriate term (i.e. its term id) to be used to perform the 'Set a data value' for a given node author (how can you derive that term id from the data about the node author)?".

If you only have a few node authors (say "Xin" and "Pierre"), you could use the Conditional Rules module to improve that Rules Action to 'Set a data value', so that the value to be used for the term id depends on the value of the node author.

4. Open question

Your question doesn't say "What should happen if no term exists yet for a specific node author?". If such scenario is impossible in your site, then you're lucky (and good to go). Otherwise you'll have to further improve the Rules logic you're implementing to:

get the appropriate (new) term created on the fly.
go find out what the term id is for the newly created term.
improve the Rules Action to 'Set a data value' to actually use the term id of this newly created term.

If you wonder how to do that (also), use this link ... 3 times (one for every bullet).


How to give a path to a link with filter?

'&' is used to divide query parameters, to split the page and parameters, use '?'

e.g.
my-view?field_subject=C


You might be able to do that by using the HOOK_NODE_VIEW(). In my experience I have had great success using the ACL and content access modules as you can control the view, edit and delete function of the nodes by roles, but also a the node level you can specify what user(s) can have access and what type of access.


I've figured out the issue.

From here:
https://simplesamlphp.org/docs/stable/simplesamlphp-authproc

I had to rename the attributes to friendly names so I could use them in the assignment feature of the module.  The previous URL attempted to do that, but it wasn't quite as easy as the one line.  I had to add each URN to change to the friendly name that I wanted.


Display multi-value entity reference field in node edit form as draggable?

You can get the multiple values input in a table format with the draggable option if you choose Autocomplete widget for that field under Manage form display for that Content type (not the Autocomplete (Tags style)).

If your field accepts an unlimited number of values the widget will present as one autocomplete input field with a button to Add another item. As you add more items you will be able to drag and drop to rearrange the values order.

You can also get that reordering widget with Inline entity form widget (with the additional module Inline entity form).


Two Errors Lumped Into One - File Field Deleted - Cannot Be Found/Deleted/Recreated

You should, in theory, be able to just remove the references to that field from the field_config and field_config_instance tables, clear caches, and then be able to recreate the field again as if it never existed.

Please do try that in a development environment first; it's also possible, in theory, that some other non-core module has a reference to that field in some way, which may either be responsible for the problem in the first place, or cause problems when you manually remove the data.


Is it possible to change the Alt value inside the image.html.twig template?

In a Twig template you can use the method attributes.setAttribute():
{% set attributes = attributes.setAttribute('alt', 'new alt') %}


You should do a search of the entire codebase (not just theme files), as well as a database search in all tables (it should only take about 3 minutes).

UPDATE:

Also, make sure you have taken any content delivery network (CDN) caching into account. Are these files causing "File-not-found" errors from a remote browser, or from a browser on the local machine (dev laptop, for instance).

If you do have a CDN in place (MaxCDN, CloudFront, Akamai, etc.) you can try uploading a mostly blank CSS file with the same name as the one that you're attempting to get rid of.


Views PHP: Getting field values and generating link

Try using these code

$body = $data->_field_data['nid']['entity']->field_image['und'][0]['body'];

OR

$node = node_load($data->$nid);
$body = $node->body[0]['value'];

This may be because of the issue here


Protecting original images (D7, watermark, imagecache)

You can try using an .htaccess to protect the directory containing the original images as mentioned at http://drupal.org/node/424068#comment-3149994


Logging into Drupal from an external application

You can use the form API to write a custom function for validating authentication. Something like this (this is from Drupal 7, but for 6 you have the same logic and the API is not very different). The code here is from a module I've wrote to authenticate users from an IP.Board (a forum software) database:

<?php
/**
 * @file
 * Allow Drupal 7 to use IP.Board members table for authentication
 *
 * Some code is based on this nice tutorial http://www.touchnoc.com/node/86
 */

/**
 * Alter the user login block form
 */
function ipbridge_form_user_login_block_alter(&$form, &$form_state) {
  _ipbridge_user_login_form_alter($form, $form_state);
}

/**
 * Alter the user login page
 */
function ipbridge_form_user_login_alter(&$form, &$form_state) {
  _ipbridge_user_login_form_alter($form, $form_state);
}

/**
 * Change the validate callback
 */
function _ipbridge_user_login_form_alter(&$form, &$form_state) {
  $k = array_search('user_login_authenticate_validate', $form['#validate']);
  $form['#validate'][$k] = 'ipbridge_authenticate_validate';
}

/**
 * Custom validation
 */
function ipbridge_authenticate_validate($form, &$form_state) {

  // try normal validation first
  user_login_authenticate_validate($form, $form_state);
  if ($form_state['uid'] !== FALSE)
    return;

  // still here? Try to find the user in IP.Board
  $name = $form_state['values']['name'];
  $pass = $form_state['values']['pass'];

  $records = db_select('ibf_members', 'u', array('target' => 'ipb'))
  ->fields('u', array('member_id', 'name', 'members_pass_hash', 'members_pass_salt', 'email'))
  ->condition('u.name', $name, '=')
  ->execute();

  if ($records->rowCount() == 1) {

    $ipbUser = $records->fetchObject();

    // this is how IPB generates the pasword hash
    $hash = md5(md5($ipbUser->members_pass_salt) . md5($pass));

    if ($hash == $ipbUser->members_pass_hash) {

      // based on Drupal's user_external_login_register (that function doesn't set the email address)
      $account = user_external_load($name);
      if (!$account) {

        $userinfo = array(
          'name' => $name,
          'mail' => $ipbUser->email,
          'pass' => user_password(),
          'init' => $name,
          'status' => 1,
          'access' => REQUEST_TIME,
        );

        try {
          $account = user_save(drupal_anonymous_user(), $userinfo);
        } catch (Exception $e) {
          drupal_set_message(t('Are you trying to login using an IP.Board username that was previously registered in Drupal? Caught exception: ' . $e->getMessage()), 'error');
        }

        if (!$account) {
          drupal_set_message(t("Error saving IPB account."), 'error');
          $form_state['uid'] = FALSE;
          return;
        }
        user_set_authmaps($account, array("authname_ipbridge" => $name));
      }

      $form_state['uid'] = $account->uid;
    }
  }
}
?>


How to render a Drupal 7 field in stand alone PHP file?

You could definitely bootstrap Drupal in a standalone file, but if you're doing it inside the same document root as the Drupal installation you'd be better off implementing a custom menu path in a module, and using the callback for that path to output the necessary value.

If you print directly from a page callback function and don't return anything, the standard theme wrappers won't be included and you'll just be left with the value you've printed.

A basic example might look like this:

function MYMODULE_menu() {
  $items['custom-path'] = array(
    'title' => 'Custom page', // Required, won't actually be displayed anywhere
    'access arguments' => array('access content'),
    // 'access callback' => TRUE, // This is an alternative to the access arguments if you don't need any access control for this path
    'page callback' => 'MYMODULE_ajax_page',
    'type' => MENU_CALLBACK
  );

  return $items;
}

function MYMODULE_ajax_page() {
  $output = function_to_produce_field_output();

  print $output;
}

After you clear Drupal's caches any request for http://mysite.com/custom-path should produce the un-themed results from your page callback; you can then use that path as your AJAX callback.

You might also want to look at drupal_add_http_header() to set an appropriate content type before you print the output.

As far as getting the field output goes, it's a bit of a pain but this should work:

$entity_type = 'user';
$bundle = 'user';
$field_name = 'field_field_name';

// Get field info for the allowed values
$field_info = field_info_field($field_name);

// Get instance info for label/required/description/default value
$field_instance = field_info_instance($entity_type, $field_name, $bundle);

// Build the select list
$select = array(
  '#type' => 'select',
  '#value' => $field_instance['default_value'],
  '#options' => $field_info['settings']['allowed_values'],
  '#required' => $field_instance['required']
);

// Build the element wrapper
$wrapper = array(
  '#title' => t($field_instance['label']),
  '#description' => t($field_instance['description']),
  '#children' => theme('select', array('element' => $select))
);

// Get the fully rendered element
$rendered = theme('form_element', array('element' => $wrapper));

print $rendered;


The quickest way to load a specific node by field value is to use the method loadByProperties().

You specify one or more field values and returned is an array containing the nodes matching the field values:

$nodes = \Drupal::entityTypeManager()
  ->getStorage('node')
  ->loadByProperties(['title' => $title]);

Normally you loop over the nodes. In your case you are looking for one specific node. A single node is also returned in array, so apply reset() and this returns either the node or NULL if nothing was found:

if ($node = reset($nodes)) {
  // found $node that matches the title
}


Access Denied is an exception and if you want to have control over any aspect how this is handled the best place is an exception event subscriber, see How can we catch the acces denied exception in drupal 8 for the general aspects or Returning alternate HTTP codes for unpublished content in Drupal 8 for an example how to change a 403 to a 404 exception.

  I'm trying to modify the text that shows on the standard Access Denied
  page?

This question is specific for the text, see this answer for a 404 message, How to change page not found page error message in drupal 8?, replace it with 403 for an access denied message.

  My first question is can Access denied be customized?

The standard way is of course in the basic site settings admin/config/system/site-information.


Can't get generated content to push footer down

First of all, never modify a core theme. Sub-theme. :) Second, the problem is that you are specifying "position:absolute" on some of your blocks which causes the CSS box-model to ignore any content inside the wrapper divs. When you write absolute, you are telling the browser: I know exactly where my content will be and so therefore you should ignore any flowing you want to do.

Try moving away from using position:absolute to position elements and instead use floats which will push the content region height and, in turn, your footer.

More info: http://www.w3schools.com/css/css_boxmodel.asp


Translating variables with context in Twig templates

In Drupal 8, you can translate a string in a Twig file with a specified context in two ways :

{{ "Text to translate"|t({}, {'context' : 'Context name'}) }}

and

{% trans with {'context': 'Context name'} %}
    Text to translate
{% endtrans %}


Update entity on cart page programmatically Drupal Commerce

Assuming that you want to display the full view result and add some extra content to your cart, put the following lines in a file named views-view--commerce-cart-form.tpl.php :

if($view->current_display == 'default'){//OR your display
  //dsm($view);
  print $rows;
  print '
MY CUSTOM CONTENT
';
}

Check views-view.tpl.php doc to see available variables.

Otherwise, have a look at Commerce Cart View Override :

  This module provides the ability to override the default cart page
  view for Drupal Commerce.


Is there a clean-URL-reflective version of file_create_url()?

I ended up using

str_replace('/?q=', '/'drupalGetHeader('location'));

So basically I gave up on including the ?q= that appears in the URL and instead stripped it from everything. It seems a little messy but it works for my purpose. Still doesn't really answer the question though.

drupal_parse_url() looked promising at first, but it didn't work because

drupal_parse_url(file_create_url($uri)) returned 'path' = http://example.com/path/to/file

but

drupal_parse_url(drupal_get_headers('location')) returned simply 'path' = /path/to/file


Get Users by roles for organic groups drupal7

Try this if it works for you.call this function with user_role id and group id as parameter.

    function get_users_on_role_and_group_basis($rid, $gid) {
      $users = entity_load('user');
      foreach($users as $user) {
         if(is_array($user->og_user_node)) {
           if (array_key_exists($rid, $user->roles)) {
             foreach($user->og_user_node['und'] as $key=>$values) {
               if(in_array($gid,$values)) {
                 $get_user[] = $user;
                }
            }
          }
        }
      } if(isset($get_user)) {
          return $get_user;
        }else {
        return 0;
      }
    }


You can do this on a lot different ways regardless where you are using this, but it is mostly Front End question.

There is a Grid Field Formatter module that can help you with this, but it is not the best solution.

  Grid Field Formatter module provides a simple way to overridde the
  display of multi-value fields to show as a grid/table with a certain
  number of columns.


Query with db_select() to select node by id and join field and terms

I hope this works for you:

 $query = db_select('node','n');
 $query->join('field_data_field_projectresources','p','p.entity_id = n.nid');
 $query->fields('n',array('yourfieldnames'))
       ->fields('p',array('yourfieldnames'))
       ->condition('n.nid','5');
 $result = $query->execute();

Here is another answer that will help you very much.

Check out documentation for 'join' on drupal.org.


Create pagination in theme('table') when not using SQL query

Try the following function:

/**
 * An generic array pager for Drupal.
 * For Drupal 5 and 6, the default limit is 10. For Drupal 7 it is 9.
 */
function pager_array_splice($data, $limit = 9, $element = 0) {
  global $pager_page_array, $pager_total, $pager_total_items;
  $page = isset($_GET['page']) ? $_GET['page'] : '';

  // Convert comma-separated $page to an array, used by other functions.
  $pager_page_array = explode(',', $page);

  // We calculate the total of pages as ceil(items / limit).
  $pager_total_items[$element] = count($data);
  $pager_total[$element] = ceil($pager_total_items[$element] / $limit);
  $pager_page_array[$element] = max(0, min((int)$pager_page_array[$element], ((int)$pager_total[$element]) - 1));
  return array_slice($data, $pager_page_array[$element] * $limit, $limit, TRUE);
}

$output = pager_array_splice($yourarray, 5);  // 5 is per page values

See Paging non-SQL data for more details.


How to add links to sidebar without using a block?

Can be done using the  _phptemplate_variables function in template.php in your theme directory.

function _phptemplate_variables($hook, $vars) {
  if ($hook == 'page') {
    foreach (array('left','right') as $region) {
      $vars[$region] = drupal_get_content($region);
      return $vars;
    }
  }
}

And just call this function below where you want to display the link.

$output = l('some link text','node/1234');
drupal_set_content('left', $output);


How can I use configuration management to "snapshot" config on my dev server while I try new things out?

I would suggest to only use features for reusable components between projects. The configuration management system works quite well for me for the workflow that you are suggesting.

To export all configuration to a directory (by default ./sites/default/config)

$ drush config-export # or use the alias: drush cex

This exports your active configuration into a bazillion files, then you can add it to git as usual:

$ git add -A sites/default/config # -A includes deleted and new files
$ git commit -m "config: my config changes here"

Now you have your snapshot, you can play with your site and if you end up in a state that you are not happy with, you can always import your exported files back to the active configuration by

$ drush config-import # or the shorter: drush cim

You can also use drush config-diff name.of.config to see the differences. Or you could just export again and git diff them

If you like your new configuration better, you can just start again: export, commit, repeat.

This is also useful to push your configuration to your test server. You just need to deploy the new code with the exported configuration and import it with

$ drush @stagingsrv cim

For some advanced cases check out the config_devel module


print theme_get_setting in php-as-css file

Below code worked for me ! Make sure there is a value for setting "theme_custom_background_path" in your theme settings. For example i can able to get logo path of theme using below code

Created a file called get_setting.php inside my Drupal Root
Copy pasted below code
Executed in browser.

Code

define('DRUPAL_ROOT', getcwd());
include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$theme_settings = theme_get_setting('logo');
print "body { background: url(" . $theme_settings . ");}";


What core configurations should be used in settings.php for a production site?

Drupal 8 has a default settings.php you can use:

sites/default/default.settings.php

Just copy it as sites/default/settings.php, add your DB connection array - and you are pretty much ready to go. Then use the UI to turn on caching and CSS/JS aggregation.

For security you may want to add in your Trusted Host Pattern

# TRUSTED HOST PROD
$settings['trusted_host_patterns'] = [
  'mysite\.com$',
];

If you really want to you can lock down your caching & preprocessing settings in the settings.php file, rather than setting it through the UI

# CACHING & JS/CSS AGGREGATION PROD
$config['system.performance']['css']['preprocess'] = 1;
$config['system.performance']['css']['gzip'] = 1;
$config['system.performance']['js']['preprocess'] = 1;
$config['system.performance']['js']['gzip'] = 1;
$config['system.performance']['cache']['page']['max_age'] = 86400;


You can load node again in other place and render it fully or partially. Via block or something else. Node load is hard operation, use module entitycache to load the same nodes faster.


Oh, It looks like I've found an answer myself, so I will post it here in case someone will have similar issue. One of the solutions (I am still not sure if this is the optimal one, but it works) is to use module Contextual View Modes (It requires Context module and Entity API). With this combination of modules it is possible to create context rules where in Conditions section there is particular user role and in Reactions one must define particular View mode for Content Type. And that's it! It just requires at least 3 modules to be installed, so maybe there is some simplier solution...


How to display users with same select list value to each currently logged in user

You should set the contextual filter to have a default value provided by the UID.  Since you're trying to only display the list of users where they have the state in common, you'll need to set the default for the profile:state to be provided by the UID.


Found this after 5 seconds of googling:

https://www.drupal.org/project/color_field
https://www.drupal.org/project/colorfield
https://www.drupal.org/project/jquery_colorpicker

The search query was: drupal color field.

Choose one,
add one color field per content type to the user entity type (users should be able to edit their profile),
then retrieve the current user and the selected values and add them as node class via template_preprocess_node.

  I may have been unclear. I don't want to let each user set their own
  color palette, I want users with the right permissions to be able to
  set the palette for an arbitrary content type for ALL users/anonymous
  users accessing the site. (I'll update my question) – tanbog

For that you need to create a configuration form. @see docs Working with Configuration Forms.

You can get a list of all content types to build your form. @see question Get the list of all content types.

You also may want to use the color FormElement. @see docs class Color.

In the end you probably still use template_preprocess_node, to get the stored config in there, and then set the CSS class according the current node type.


Drupal7 REST Basic Authentication not working (Postman)

Everything seems fine, as the response says, 'username' name/key is missing from the request. So construct a body request like follows or else follow the screenshot

{"username":'myusername', "password":"mypassword"}


Is it possible to give users different roles/profiles on different part of the website?

A widely accepted solution for this would be using the Organic Groups module.

With this module, you can define different access settings and local roles for a given group type, and for all the nodes associated to it (this would be the "inheritance" you are looking for).

It is not the simplest module to use, though. You can find some "getting started" documentation here: https://www.drupal.org/node/861418


The $view->set_display($i); will not work unless you have an integer as the display name of your view (which is something I'm not sure if possible or if you need it).

try changing the $i in $view->set_display($i); to the display name of your view:

for($i=2; $i<=4; $i++){

    $view = views_get_view('view_name');
    $view->set_display('display_name'); //Example: page, page_1, block_1, custom_display_name ..etc
    $view->set_arguments(array($i));
    $view->execute();

    dpm($view->result);
}


Upgrading to 7.26 - Internal Server Error

Always run the update script each time a module / the site is updated.

IE:  site.com/update.php

It triggers the update hooks in the modules and lets them deal with any db type changes.

After that flush the Drupal caches (admin/config/development/performance/) to clear out any old references.


You can always try the Quiz module. I have some experience with it and it mighty suffice for your needs.

Or you can always create your own form with the well-documented FormAPI. You can define your own validation- and submithandlers. Very, véry cool features.
What you can do is create a custom block, and fill it up with your own form.

Depending on your experience level (and time), you can one of above options...
Good luck!


Getting the error "$().once is not a function"

The standard $ alias is not used in Drupal 7, to provide the best possible support for no-conflict jQuery.

You need to wrap your code in a closure like so:

(function($) {
  // Add code using $ as an alias for jQuery here...
})(jQuery);

See Managing Javascript in Drupal 7 for complete examples and explanations.


How to display custom fields of taxonomy in field twig

You can use item.content['#options'].entity.field_job_title.value to get the value of the job_titlefield value, I don't know if this is the best way to do it.
So your code will be something like:

{% for item in items %}

        {{ item.content }}

{{ item.content['#options'].entity.field_job_title.value }}

{% endfor %}


What's wrong with my custom node template?

Use print render when the variable is a build array and use
Use print when the variable is a PHP string containing HTML.

For more details, render arrays on d.o. (render and build arrays are the same thing).


Why does drush say "command not found" when I try to execute remote commands?

This message is from the remote machine complaining that it didn't understand where to find the drush executable, not Drush complaining that it can't find the (sub)command you may be trying to give it, even though the punctuation suggests the latter. (If bash: means Bash is  passing you a message, then drush: should mean the same thing--if there's any consistency. But actually it is intended to mean drush: is the subject of the message, not the source of the message passed through bash: to you.  It would be clearer if the second : were removed.)

Drush logs into your remote machine over ssh, but it's not a normal interactive login, so it doesn't source the .bash_profile.  It does, however, source the .bashrc file.

Add the drush path (not including drush itself, just including the directory containing drush) to the PATH variable in your remote .bashrc and all should be well.  For instance, that may look like this:

PATH=$PATH:/usr/local/zend/bin


The first error message is saying that, basing on headers returned from Apache, Drupal is not able to determine which Apache version the server is using. If you have access to the httpd.conf file, you can set ServerTokens to at least ServerTokens Min, so Drupal will be able to check which Apache version the server is using.
If you know your server is using at least Apache 2.2.16, you can go forward and proceed with the installation. What you are getting is just a warning for you to check the Apache version, since Drupal cannot find out that.

The other message is telling you that it should preferable to install the OPcache extensions, which means you need to have access to the php.ini file, and being able to install extensions on your server.
If you aren't able to do that, don't do anything. That is not an error message, but a warning message telling you it is preferable to have OPcache enabled to make Drupal faster, but Drupal 8 works also without it.


Printing views exposed sort criteria separately to exposed filters

If you can not use each item of $widgets in separated way, you can push each widget in a separated array for use each widget across your custom html.

<?php foreach($widgets as $id => $widget): ?>
    <?php
    array_push($elements, $widget);
    ?>
<?php endforeach; ?>

<?php
echo $elements[0]->widget;
echo $elements[1]->widget;
//etc
?>


Automatically Generate PDF from Webform Submission

It seems like the entity_print module does exactly what you want.

From the docs:

  Entity Print allows you to print any Drupal entity (Drupal 7 and 8) or View (Drupal 8 only) to PDF.

The module is weel maintained with more then 5K websites using it.


Assigning a role based on signup url on a Drupal 7 site?

You can do it with Auto Assign Role module, It provide paths that will trigger a specific role when an account is created.

  The Auto Assign Role serves three primary purposes. The first is to
  provide an automatic assignment of roles when a new account is
  created. The second is to allow the end user the option of choosing
  their own role or roles when they create their account. The third is
  to provide paths that will trigger a specific role when an account is
  created. The administrator has full control over these functions and
  can have them working together or independently of each other. Auto
  Assign Role is integrated with the Content Profile module so that you
  can have content types serving as registration pages. You can even
  replace the default user/register page with a customized version of
  your own design.


How to get all nodes of a content type as header menu item?

You can configure content type to create menu items. So look at content type configuration.
It will dynamically create menu items when new node is created.


How to tell if node has been updated via UI form as oppose to programmatically?

Create an additional field in the content type - for example update_source - and set the value programmatically.

If the user is editing the node on node/[nid]/edit page, set the value to UI and otherwise set it to programmatic.

You can do this with simple hook_form_alter() and URL checks to make sure the user is on node/[nid]/edit page. Something like this would work:

if (arg(0) == 'node' && arg(1) && arg(2) == 'edit') {
  // Your code
}


How to skip the ReferenceAccess constraint on a file upload by an anonymous user?

That constraint is validated by \Drupal\Core\Entity\Plugin\Validation\Constraint\ReferenceAccessConstraintValidator. ReferenceAccessConstraintValidator::validate uses the following code.

  /* @var \Drupal\Core\Entity\FieldableEntityInterface $referenced_entity */
  $referenced_entity = $value->entity;
  if ($referenced_entity) {
    $entity = $value->getEntity();
    $check_permission = TRUE;
    if (!$entity->isNew()) {
      $existing_entity = \Drupal::entityManager()->getStorage($entity->getEntityTypeId())->loadUnchanged($entity->id());
      $referenced_entities = $existing_entity->{$value->getFieldDefinition()->getName()}->referencedEntities();

      // Check permission if we are not already referencing the entity.
      foreach ($referenced_entities as $ref) {
        if (isset($referenced_entities[$ref->id()])) {
          $check_permission = FALSE;
          break;
        }
      }
    }

    // We check that the current user had access to view any newly added
    // referenced entity.
    if ($check_permission && !$referenced_entity->access('view')) {
      $type = $value->getFieldDefinition()->getSetting('target_type');
      $this->context->addViolation($constraint->message, [
        '%type' => $type,
        '%id' => $id,
      ]);
    }
  }

(In particular, see the line containing $referenced_entity->access('view').)

We can hook into the file's access control to alter the outcome, with hook_entity_access() or hook_ENTITY_TYPE_access().

Another solution could be to create a new field type which inherits everything from Drupal\file\Plugin\Field\FieldType\FileItem, except for the ReferenceAccess constraint in its plugin definition. You can do this in two ways:

Create a new plugin class that extends the original class, and copy and modify its docblock, including the @FieldType annotation.
Implement hook_field_info_alter(), copy the file plugin definition to your own, and make the necessary adjustments there.


Add a page display with an URL for your specific view, then on that page it will work and please don't forget to clear the drupal cache.


I got it, I was calling a tag not specific enough.

Once I replaced:

$('#mainnav ul.menu').smartmenus();
$('#main-menu').smartmenus('menuHideAll');

with

$('#mainnav ul.menu:first').smartmenus();

Everything was fine.


How to set relationship when I create a new (custom) content to another (custom) content in Drupal

I hope I'm understanding your question correctly... you'd like to know what's the best way, in Drupal 7, to add a reference to a node of another content type when creating this content type?  (i.e. to store a reference to a 'Group' when creating a new 'Person')?

If that's what you're trying to do, a good way to do that in Drupal 7 is using the Entity reference module.

Once you download and enable this module, you'll be able to go to the 'Manage fields' tab of your 'Person' content type and select to create a new field of type 'Entity Reference'.  That field option will only appear once you've enabled the module.  Before hitting 'save' after you've selected that field type, make sure you notice that you'll have two options for the field widget: you can select for it to be a 'Select list' in which case, it will just have a drop-down list of all the Groups currently available on your system for you to choose from when creating a person.  Or you could choose 'Autocomplete', which works better if you have a TON of groups and don't want a super long list.  That'll allow the user to start typing the name of a group, and it will just automatically detect and complete it.  :-)

Once you've selected those two options on the first screen, on the second screen you should select 'node' as the 'Target type' and select 'Group' as the type of the referenced node.  Finally, just choose whether you want that field to be required or not and whether you should select only one or multiple values (like any other field).

Let me know if that works for you, and I hope I understood your question correctly!!


Panels visibility rule: Hide if value is in the query string

Using PHP code is not recommended unless absolutely necessary. You never want to store the PHP code in database, you do that in the modules :-)

I would recommend you to write an ctools access plugin for the same; check the logic there and give access to users accordingly.

Benifits:

The code is more maintainable, and can be version controlled.
You could reuse the same visibility rule throughout the site wherever necessary.

Please check my answer here, for an example of a working access plugin.


Show current page on Drupal 7 breadcrumb

Some themes - like Zen - provide this option, so check under Appearance -> Settings.  If your theme doesn't offer the option, you can edit your theme's page.tpl.php - simply add $title after the $breadcrumb variable.  Alternatively you could override theme_breadcrumb().


How to set multi-value hidden field from javascript?

Fields will only appear in the $field_state array if they were there when the form was built. (If you inspect the $_POST array directly you should see your values there.)

The solution: When creating the form add enough fields so you don't need to add any more with js.

If you didn't create the form yourself then use hook_form_alter to add more fields.

If you need to be able to add more fields on the fly then you will have to look into the #ajax property. The examples module has some good examples on that.

Also make sure to use the #default_value, not #value property if you need to set a default value for any of the hidden fields as using #value will lock the value to that and stop the client from being able to make any changes.


Re-creating Blocks Page for Content Authoring?

The nodeblock and node-level-blocks modules may be a good starting point.


After many days of unraveling views, entity references, and paragraphs, I finally figured this out. The moment was celebrated with an awkward, club-footed jig.

For context, I'm building a financial data delivery site that connects investment fund managers with funds to manage.  My content types look like this:

I have an entity type called Contact, which has inside it a Paragraph field called Job History.  There are 3 different job history paragraph bundles for 3 different types of jobs, but each type has fields for Job Title, Phone, Email, Employment Date, and an entity reference field called Fund.  I also have another entity type called Fund, which is referenced by the Fund reference field.

1. Contact (entity)
- Job History (paragraph)
-- Fund
-- Job Title
-- Phone
-- Email
-- Employment Date

2. Fund (entity)
- Various fields (irrelevant to this solution)

I want to create a table view that will appear on all Fund pages, and show any contacts, with their contact info, for said Fund.  In other words, this view should display any Contact nodes that reference the current Fund node, along with those nodes' phone, email, etc fields.  I can achieve this using only Views...

Create a content view and filter by node type: Contact.
Add a relationship, Content: Field (Job History).  This allows me to access the fields inside the Job History paragraph field.
Add all above fields I want to display (name (title), job title, phone, &
email) to the Fields section, making sure each one uses the Paragraph item from field_job_history relationship.

At this point, I have a view that displays all contact nodes & their fields. Let's narrow it down to those that reference only the current Fund node.

Add a relationship, Entity Reference: Referenced Entity (A bridge to the Content entity that is referenced via field_reference_fund). Use the existing relationship, Paragraph item from field_job_history.
Add a contextual filter for Content: NID. Use relationship, Content entity referenced from field_reference_fund. Provide default value: Content ID from URL.

The view will now display the fields within the paragraph, and limit the results to only those nodes that reference the current node.

I hope this provides the solution you were looking for!


node--reviews.html.twig is correct. In my current theme, I have node--staff.html.twig and node--video.html.twig; they work perfectly fine. It could be a cache issue or probably a spelling issue.


Is there a module that saves Twitter posts in a custom table?

Try the feeds module and data module

http://drupal.org/project/feeds
http://drupal.org/project/data

and import the rss of your twitter feed or search into the feed than save it as a simple database record with the data module.


How to display the value of a report parameter in a Forena Report and in a CSV export of it?

Display the value of a report parameter in the report

A sample of showing the values of the specified parameters can be found in reports/sample.user_distribution_simple.

If you execute that report with a parm like (eg) state=VA, or you just use an URL like /reports/sample.user_distribution_simple?state=VA, the report will contain a phrase like "This report lists all users in cities assigned to a state with code = VA.".

Line 26 in the .frx source of this sample that creates that phrase looks like This report lists all users in cities assigned to a state with code = {parm.state}.

So in this specific case, try something like this:

You selected 'item {parm.a}, item {parm.b}, and item {parm.c}'.

That is: preceed the parameter(s) with {parm. and have them followed by a }. Some more details about this:

The { and } are an indication you want to include something in your report about the report "context" (= Forena terminology).
The parm. part of it is to indicate "one of the report parameter values".
The a is to actually name the exact parameter (like 'a').

This technique (syntax) is also used to create "linked" reports (drill down reports, etc).

Here is a sample of one of my "custom" reports where I do something similar:

Within the "Report Execution Parameters" (collapsed in the screenprint above), I specify the search criteria of the log messages to be retrieved (the "8" within "... statistics within 8 most recent log messages ..." was the value of one of the parameters).

Include the value of a report parameter in the exported CSV file

The file saved via the CSV export feature, will actually include all the report data shown in the report as "tabular" format (which is compliant also with the csv tag description ...). So to get the report parameter (and the specified value) included in the CSV export file, you'd have to somehow include that in the appropriate area of your report.

As a sample, consider the reports/sample.user_distribution_simple again. You could enhance (customize) this report (which is specified using xHTML ...), by adding these extra HTML lines before the
 tag:

    &nbsp;
    &nbsp;

    Report parameters
    Parameter values

    state
    {parm.state}

In doing so, and by rerunning the report again with report parameter (say) state = VA, you should get a CSV export file that looks like so:

city,users
Amesbury,"3,991"
Catskill,"3,123"
Ketchikan,"6,107"
Michigan City,"1,741"
Selma,"1,833"
Vineland,"1,825"
 ,
Report parameters,Parameter values
state,VA

One could argue about the layout/format of the CSV output file (like the 3rd line from the bottom that only has a ","), but the keypoint is that you can use the full power of xHTML to enhance the layout to fit your needs. E.g. replace the &nbsp; (twice) with something more appropriate, or move those tfoot rows somewhere above the thead rows (to have the parms and values shown at the top of the CSV file.


A good way to do this using context:

Under conditions select Path and input your path

then under Reactions select Theme HTML.  Here you can select the class you wish to add to the body.


"admin/content" filters not available anymore

You need just to install the Views module that is part of Drupal core. Once you install it, that page appears as the following, which is how I see it in my site.

If I uninstall the Views module, that page appears like the following.

Now that the Views module is in core, there are many pages that have been converted into views. As you see from the first screenshot, there is a new Files tab which is a view.

If you don't see the Views module listed between the modules, download again Drupal, because that means the archive used for the installation is missing some Drupal files, or they have not been correctly copied.


Change the front page value for logged in users

I would recommend the Front Page module, not rules:

The Front Page module allows for customised home pages dependant on
role. The pages can be of the following types:
Alias (only 2.x branch) - Allows for another Drupal path to be shown
as the home page without redirecting the user.
Redirect - Allows you to redirect users to a local or remote URL.
Themed - Allows you to enter some static text that will be placed into the content area > of a standard Drupal page. Full - Allows for static content to be displayed
to the screen as is. This method does not pass through Drupal's
theming system.


Reset View result counter after changing page (manually or with Twig)

It doesn't work because counter is actually an object with the value as a property, that's done to properly handle markup or special characters and preventing them from being escaped multiple times.

Depending on what template you're overriding and where, you could possibly do this in twig, especially if you are where you are loop over the rows already, although that might be a bit complicated.

My/the backend developer approach would be to make your own counter views field/plugin that doesn't consider the pager. This logic happens in \Drupal\views\Plugin\views\field\Counter::getValue(). So you can copy this  class into a custom module, rename to NoPagerCounter or so, and change the annotation to @ViewsField("no_pager_counter"). Then you remove the pager related part in the getValue(). Now you just need to implement hook_views_data() and define this as a field, just like views_views_data does with the counter:

  $data['views']['no_pager_counter'] = array(
    'title' => t('View result counter (no pager)'),
    'help' => t('Displays the actual position of the view result'),
    'field' => array(
      'id' => 'no_pager_counter',
    ),
  );

(Possibly with a better title/help, I just switched the ids)

Another variant of that would be to add an option for this to the existing class and provide a core patch/feature request for this. If others agree that it is useful then it might eventually get committed and you don't need to maintain custom code, but you will have to maintain the patch until then.


How do I create a unified list of referenced users in a multi-entry entity-reference field in a multi-entry field collection field?

I guess the solution must be to somehow embed a view to feed this
  view, but I'm not sure how to approach that, perhaps that would
  require an additional module?

You're on the right track, use the Views Field View module to achieve that.

You could also do this programmatically if you have a template file or a preprocess function

Ex:

<?php print views_embed_view('blog_posts','block_1', $contextual_filter_value); ?>

To make it as a list, use CSS:

.view-id-test.view-display-id-block .views-row {
  display: inline-block; /* If it doesn't work try display: inline; */
}

.view-id-test.view-display-id-block .views-row .field-content::after {
    content: ",";
}

.view-id-test.view-display-id-block .views-row-last .field-content::after {
    content: "";  /* or content: normal; */
}

.view-id-test.view-display-id-block being the unique parent classes wrapper as you don't to affect every single view and only a specific view & view display. (Use inspect element with your browser, to find a good parent wrapper.)

If you don't want to use CSS, then you will have to do it programmatically in your view's fields template file.

// load view
$view = views_get_view('view_name');
// set arguments for view
$view->set_arguments($contextual_filter_value);
// execute view
$view->execute();
// get all travelers from the result
foreach ($view->result as $result) {
   // capture the result of your field in an array.
   $travelers[] = $result->field_traveler;
}
//make array into comma list
$travelers_list = array(implode(", ", $travelers));
// print the list
print $travelers_list;


How do I add additional view modes for a node?

first we have to add additional view modes with hook_entity_info_alter

function customuserblog_entity_info_alter(&$entity_info) {
     $entity_info['node']['view modes']['blog_post_big'] = array(
        'label' => t('simple big  teaser'),
        'custom settings' => TRUE,
      );
    }

// we may attach additional theme functions or templates and add variables with hook_view

function customuserblog_view($node, $view_mode) {
  if ($view_mode == 'blog_post_big') {
   // add some additional variables for template
    $node->content['#theme'] = 'custom_blog_big_teaser_view';
  }
}

// in our hook theme

customuserblog_theme(){
    return array(
      'custom_blog_big_teaser_view'= array(
          'render element' => 'form',
          'template' => 'custom-blog-big-teaser-view',
       ),

    );
}