What's the fastest method/implementation for an Ajax callback? I have a map which loads markers via ajax on various/numerous map events. Currently, I define a custom page callback for my hook_menu() item which prints my json/js.

Since my page callback does not return any content and only prints content, Drupal does not render the full template, menu, etc, and thus allows me to return a page with only my JavaScript.

Although this does work, I believe that Drupal still fully bootstrapping, which means it is adding a lot of overhead I would like to drop.

I've been looking at High-performance JavaScript callback handler, which boasts itself as a "High-performance JavaScript callback handler" and which, in short, looks as though it offers a js.php to compliment index.php to direct your requests to and customize/limit/optimize the bootstrapping Drupal does by default.

Unfortunately the js project doesn't have a D7 release yet (petition for one here), which leads us to the beginning...

What is the fastest way to implement an Ajax callback in Drupal?

I define a custom page callback for my hook_menu() item which prints my json/js.

That is what Drupal 6 offered. The Drupal 7 AJAX framework can do a little more than that. Yes it bootstraps Drupal, but it also gives a lot of features for free. In short you can use ajax_deliver() as a page delivery method, and send commands to the browser.

  ... Ajax may be enabled by adding classes to buttons and links. By adding the 'use-ajax' class to a link, the link will be loaded via an Ajax call. When using this method, the href of the link can contain '/nojs/' as part of the path. When the Ajax framework makes the request, it will convert this to '/ajax/'. The server is then able to easily tell if this request was made through an actual Ajax request or in a degraded state, and respond appropriately.

However if you want to sidestep the framework for performance reasons then there is nothing to stop you calling php files in your module directly from javascript. You will get no Drupal goodness but you also will have complete control over the page.


Push Notifications: How can I send extra parameters in push notification data? I am using Push Notifications module to send notification to registered tokens.

I am able to send a plain text notification successfully via rules.

I am looking for a way to send the notification with extra fields so that it can be identified which type of notification is this and what action to take on this.

Below is the data example I need to send the notification in:

{
   "aps":{
      "alert": "Enter your message",
      "badge":1,
      "sound":"default",

     "extraField 1":"some value",
     "extraField2":"identifier"
   }
}

Here is the rule export:

    {
    "rules_push_notification" : {
    "LABEL" : "Push Notification",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "push_notifications" ],
    "ON" : { "node_insert" : [] },
    "IF" : [
      { "node_is_of_type" : {
          "node" : [ "node" ],
          "type" : { "value" : { "music" : "music", "news" : "news" } }
        }
      }
    ],
    "DO" : [
      { "push_notifications_send_message_bulk" : { "message" : "[node:title]", "target_group" : "authenticated" } }
    ]
  }
}

Notes:

My Rules Action maps (corresponds) to the data example like so: that "Enter your message" would be replaced by the value of "[node:title]".
About that "extra field 1" (and "extra field 2"): When I send a Push notification, On Tap it needs some action to be taken which is decided in those extra fields, for an example if I need to show a music article I will send "music" as identifier and second field will be the node id of the content help mobile to open that particular article.

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

Integrate 'identifier' in your Alert message

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

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

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

Integrate 'some value' in your Alert message

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

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

Send JSON messages

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

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

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

Upcoming improvements in D8

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


How to configure an exposed filter in a view using a date picker? How can I configure an exposed filter so that users can filter my site content by creation date, preferably using a date picker?

I tried using Content: Authored on as filter, but it gets me a text field to enter the date to enter a date/time in the yyyy-mm-dd hh:mm:ss format, which makes entering the date more difficult for users and more error prone.

What is the difference between Drupal 8 and Drupal 7 with Views 7.x-3?

You can use the Date Popup module.

  Adds the native HTML 5 date popup widget to all date fields in views
  filters.

As the Use form element of type date instead textfield when selecting a date in an exposed filter is still in progress.


How to theme a select box with multiple selection enabled I have a select box with multiple selection option enabled in my custom form. Everything is works fine, however the problem is the appearance is not good and also If I have more options then the selection becomes difficult.

Is there any module out there which offers left-right selection widget like below

or any other better solution which offers better user friendly selection for select box with multiple selection option enabled.

Hope there is an easy way to achieve this rather than writing custom CSS, jQuery/JavaScript code.

The Improved Multi Select widget sounds right up your street:

The Improved Multi Select module replace the default multi-select boxes with two pannel list and search.
The first panel holds the options that are available, and the second panel holds the options that have been selected.

It looks pretty good too:


Custom preprocess_function does not fetch translated value of the content type Drupal 7.34 core
Using custom theme from Themebrain TB Sirate
Multilingual setup works properly
Content type has both English and Russian values

English Language mode: When open/viewing a node, page-title display content type that is "Article" (English)

Russian Language mode: When open/viewing a node, page-title display content type that is "Article" (still English, must be Russian)

Question how to display Russian value of content type.

Here code from preprocess_funcion.inc of the custom theme

/**
 * @file
 * Override of theme_preprocess_...
 */

function tb_sirate_preprocess_html(&$vars) {
  $current_skin = theme_get_setting('skin');
  if (isset($_COOKIE['nucleus_skin'])) {
    $current_skin = $_COOKIE['nucleus_skin'];
  }
  $vars['classes_array'][] = !empty($current_skin) ? (" " . $current_skin . "-skin") : "";
}

/**
 * Override or insert variables into the page template.
 *
 * @param array $vars
 *   An array of variables to pass to the theme template.
 */
function tb_sirate_preprocess_page(&$vars) {
  if (isset($vars['node'])) {
    if ($vars['node']->type != 'page') {
      $result = db_select('node_type', NULL, array('fetch' => PDO::FETCH_ASSOC))
        ->fields('node_type', array('name'))
        ->condition('type', $vars['node']->type)
        ->execute();
      foreach ($result as $item) {
        $vars['title'] = $item['name'];
      }
    }
  }
}

/**
 * Override or insert variables into the node template.
 *
 * @param array $vars
 *   An array of variables to pass to the theme template.
 */
function tb_sirate_preprocess_node(&$vars) {
  $vars['page'] = ($vars['type'] == 'page') ? TRUE : FALSE;
}

It seems to me that problem is here

    function tb_sirate_preprocess_page(&$vars) {
  if (isset($vars['node'])) {
    if ($vars['node']->type != 'page') {
      $result = db_select('node_type', NULL, array('fetch' => PDO::FETCH_ASSOC))
        ->fields('node_type', array('name'))
        ->condition('type', $vars['node']->type)
        ->execute();
      foreach ($result as $item) {
        $vars['title'] = $item['name'];
      }
    }
  }
}

What can I do to pull Russian value of the content type from DB?

Thanks in advance for any help!

You can confirm this by looking under the "Overview" tab of the translation interface:

If the percentage in the "Node types" for your second language is ("Norwegian Bokmål" in the image above) is 0%, the translated strings for the Node types has not been imported into the translation interface.  This means that even after you enable that language, the fallback English strings will be used.

However, it should now be possible to add these translation by hand.  Navigate to the translate tab of the translation interface, and limit search to Node types.

The strikethrough over the string with the two letters in the Languages column means that the translation is missing.  Click "edit" to add the missing translation.

This exact procedure fixed it for me as can be seen from the "Overview" tab below.  The percentage for "Node types" for "Norwegian Bokmål" in now 100%.


In Drupal 7 Commerce, where do you send an order completion confirmation email to administrators or store owners? I just noticed that I wasnt getting any confirmation emails when there is a order completion. Where do I set this up so I can get an email notifying me of a completed order for Drupal 7 commerce?

I guess this is available in the rules provided by the drupal commerce at (admin/commerce/config/checkout/rules):

admin -> commerce -> config -> checkout -> rules -> "Send an order notification e-mail"

Configuration of recipient email address including the admin address you want the order confirmation sent to can be done at this place.

Also you can check the doc for commerce order mail: https://drupal.org/node/2061215


adding multiple content to homepage I am very new to Drupal. I want to add multiple content to my homepage,very simple,like this structure,I need to add two contents ,Main Content 1 and Main Content 2. I am able to add Main content 1 easily, but how can i add the main content 2 below the main content 1?. Will I be able to do it from the admin panel or I will need to change the theme structure?

You can easily customize your theme depend upon your requirement

Open up your theme's .info file and you should see some regions like this:

regions[featured] = Featured

regions[content] = Content

regions[sidebar_first] = Sidebar first

regions[sidebar_second] = Sidebar second

to add a new region just type in a new one in that .info file. I'd be careful of replacing any though as there are several regions in D7 that are required.

Then you'll need to print out your new region in your page.tpl.php file which goes something like this now:

<?php if ($page['sidebar_first']): ?>

        <?php print render($page['sidebar_first']); ?>

    <?php endif; ?>

Don't forget to clear your cache or you won't see the new region. It really helps to poke around in some other D7 themes and see how they've done things also.

taken from this source http://drupal.org/node/1088718


Different favicon for local version of site? It's a small thing, but it would be nice if a site running locally could use a different version of a favicon, to make it easier to separate local and live sites visible in browser tabs.

I had in mind a really simple implementation, where a local favicon would just have "_local" appended to the name of the current theme favicon, so:

favicon.ico
favicon_local.ico

Then, if the site is running locally, and if a local version of the favicon exists, use it instead.

My question - what's the best way to implement this? Also, what would be a good way to check if a site is running locally?

Thanks for any ideas, code, or pointers.

Do you use any versioning like Git? If so, you can just upload the real favicon to your live site, then change the favicon locally and add it to your .gitignore afterwards.


How do I add custom CSS styles to the body field? I have a content type "page with fields" which I made out of "Basic page" by adding two text fields at the beginning of the page which now looks like this:

Page title
Field1 Label: field1 text
Field2 label: field2 text
Here goes the body field text which is long text.

The problem is the lack of space between the body text and the fields 1 and 2. Now I want to add some custom CSS styles to the body field in order to put some extra space and later to be able to add some other visual changes.

My theme is Bartik 7.26 on Drupal 7.

Use the "html inspector" of your browser (Ctr-Shift-I for Chrome) to find the the css classes of thoses fields.

Then add the proper css code in /themes/bartik/css/style.css.

That will be the quickest way to do it but I strongly recommend you to create a sub-theme of the bartik theme (https://drupal.org/node/225125) so if the theme gets updated, you won't loose your changes.

You should check out Display Suite too (https://drupal.org/project/ds), it a fantastique module to change the way nodes are displayed.


Looking for a Module to allow presentation of data like a Microsoft Access Table A client that is currently using Microsoft Access to manage some reporting tasks would like us to extend a custom module to allow them the same (or similar) functionality on their website.

I was looking at Data Tables which has a Drupal module and that would get us most of the way there however I wanted to reach out to the experts out there to see if there are any better solutions.

Their website is currently Drupal 6 but we may be rebuilding it in Drupal 7 so I will need solutions for both versions.

EDIT I'm interested in displaying data tabularly, but also need to have the filtering and sorting options on the columns. Data Tables has the sorting down but I don't see how it can filter.

Thanks in advance!

Take a look at Node Table module.

Generates sticky headers automatically
Supports flexible column sorting on none, one, or multiple columns
Supports a default sort column with asc / desc option
Supports add, delete, edit of rows and columns
Supports drag and drop reordering of rows and columns (row reordering works only when no column sorts are enabled)

  NodeTable module is a versatile module for handling HTML tables on
  Drupal sites. The module provides functionality for creating,
  uploading, editing, and presenting HTML tables within nodes or as
  nodes.


Should I use Spaces or Domain Access to share & separate content between subdomains? I realise that without the following additional information the title question is too broad.

I have multiple sibling Drupal 7 sites with their own domains that I wish to consolidate into a single site, whilst to some degree retaining their apparent separateness. The rationale is discussed in this blog post, but to summarise:

The sites have been developed in parallel and share many features
Cross site search indexing would be much simplified by a single database
Maintenance of a single site would be less costly
Updates and new features could be rolled out simultaneously across sites
The single, [incidentally] simplified and documented site would be easier to hand over to another developer

From the approaches considered in these two excellent but dated appraisals from Atchai and Palantir I had initially identified Spaces as my preferred, maintainable solution, but an apparent shift in usage, and seemingly low overall usage of Spaces leads me to question my assumptions.

Googling shows a dearth of recent articles on the subject, and d.o usage shows a decline in the weekly installs for the spaces module, which implies that people are taking a different approach.

Domain Access, however, is on the up:

Does anyone have any recent experience that would help?

I believe I have settled on an entirely different preferred solution - multisite.

For my particular situation, my priorities are derived from having to hand over the multiple site setup to another developer (with unknown resource/ability). I believe that with this in mind my question contained a couple of false assumptions, namely

that a single site would be simpler to hand over to another developer
that therefore maintenance costs would be lower than retaining multiple sites

The site will probably not have to share much content, and even fewer users, between sites so the main crossover is providing a shared search index. I have already solved this by separating the search functionality via aggregation (in an admittedly circuitous fashion). There are more powerful and efficient multiple site options involving Apache Solr or similar, but having separated search from the sites, these options are still open, and need only be implemented in one place.

A single site with multiple domains must necessarily make use of Domain Access, Spaces, Organic Groups or some combination of these. It may, therefore, be a single site, but it is not a simple site. Even if the documentation I provide with the site is perfect, the inheriting developer may encounter complications or complexities when maintaining or extending this more sophisticated site. Domain Access, though the most popular strategy, worried me particularly because of its interference with the core

I also found this article particularly useful in resolving my indecision. One aspect I had not considered with regard to a multiple domain site was the potential for path conflicts. I can certainly imagine a situation where both site1 and site2 have an /about path, and I cannot imagine an easy, maintainable way of getting round this within a multiple domain site without allowing drupal to create an ugly /about-0 path for site2. I find this distinctly unappealing, and it could cause some issues for existing paths.

I have always been quite reticent about using drupal's inbuilt multisite functionality to share a codebase between different sites (with different databases). For the purposes of updating etc it has often seemed simpler to me just to have separate codebases and manage shared code through version control, (because I can break a single site). In this handover situation, however, I think maybe a single codebase better communicates the absolute similarity of aspects of the different sites. As long as configuration is, as far as possible, captured in Features, there should be little confusion about the degree to which components and behaviours are shared between sites. The multisite codebase can easily be separated out into different sites later if required.

As a side-note, one advantage I had not previously considered for the multisite setup was the reduced amount of memory required to cache compiled PHP code (detailed here).


Create user on content creation In a "course" content type, I have an "instructor name" field, which points to a registered user.

When the "course" content is saved, I need to check if there are any registered users with the name in the "instructor name" field. If there is, I'd like to relate the created content with his id. If not, I'd like to create a new user (a dummy user maybe)  and relate the content with that user.

Is this possible without php coding, just using modules? And if it is, how? I am a new drupal user with .net background and have no knowledge of php.

Yes, you can do it with Rules module.

Basically, after enabling the Rules & Rules_UI module, you create a new Rule acted on a node is created, add an action of creating a new user entity. You need to spend a bit of time to specify the condition to suit your need.

Some screenshot of flow attached for you.


Manage config translations programmatically My module creates and manages some config_entities programmatically (ie. not through an EntityForm) in response to associated content entities being saved.

In order to handle multi-language content entities, I see two options:

create one config entity and add translations for it
create a unique config entity for each translation

The first seems cleaner - however, I don't see how to actually transparently manage translations for config entities. Translating an entity with the config_translation module appears to create a new entry in the config table with collection = language.xx, but I don't see how to access a translated entity explicitly (rather than it being automatically mapped by the site's interface language). Is this even possible?

The answer from @Smartsheet eng is correct if you want to load and read a specific translation as a config entity, see also How to progragrammatically get NodeType translated value in D8?.

However, changing them is different, because the config entity can't be saved like that, it doesn't understand what is a translation and what's not. It will just overwrite your default language with that data. See also https://www.drupal.org/project/drupal/issues/2910353.

To actually manage a translation of a config entity, you have to directly interact with the config system, you can see how in \Drupal\config_translation\Form\ConfigTranslationFormBase::submitForm():

$config_translation = \Drupal::languageManager()->getLanguageConfigOverride($langcode, $config_name);

// Write the keys you want to translate on the config object.
$config_translation->save();


Styling views table - Toogle row class on click I have a view which is shown as table. I would like to add a css class to entire row, once the user has clicked somewhere on the row.

With views i added '.baza-pregled-strank-row' class to each row. Below is my jquery code, which is successfully loaded, but not doing what it should, because once i click on the view-field, the class is not aded to the row. Big thanks.

(function ($) {
$('.view-field').on('click', function(e) {
      $('.baza-pregled-strank-row').toggleClass("highlight");
      e.preventDefault();
    });
}(jQuery));

First of all you need to add custom class to your VIEWS wrapper and also for TABLE ROW.
I have added my-view-wrapper for the VIEWS and row-wrapper for TABLE ROW

Add CLASS to your VIEWS

Add CLASS to your TABLE ROW

(function ($) {
  Drupal.behaviors.viewRowHighlight = {
    attach: function (context, settings) {
      $('.my-view-wrapper .row-wrapper').click(function(e){
        $(this).toggleClass('clicked');
      });
    }
  };
})(jQuery);


Drupal 8, how fix the error 'class not found' for custom class ? Its a php issue but maybe I missing a 'Drupal 8' thing ?

I have this custom module :

> mymodule (directory)
    > mymodule.module
    > src (directory)
        > myclass.php
        > myclassinterface.php

In myclass.php, I have :

namespace Drupal\mymodule\src;

Class myclass implements myclassinterface{
    ...
}

In my mymodule.module, I have :

use Drupal\mymodule\src\myclass;
...
function mymodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id){
    $test = new myclass();
    // or $test = new Drupal\mymodule\src\myclass(); // same error, class not found
}

And when I load a page via my browser, I get a blank page and apache log tell me the class 'Drupal\mymodule\src\myclass' not found.

I don't understand..where is my mistake ?

Drop the "src" from your namespace and use statements. Wipe the cache after making that change.


Export/Deploy Drupal site/page to static? (no cache) I wonder if there is an existing  module that can help in the subject.
I am not looking for a caching module (like Boost or Varnish), but a way to export my whole site (or only certain pages) into static.
The idea is that I want my web server will be a very simple and light and will only serve static files (html/css/js) - no database on production, no php engine will be installed on server. All the Drupal engine will be on another server, export will be done each time adding/editing/changing a node or view, and a new set of html files will be created in a directory structure.
These files will later on be copied to the production site that will serve always and only static files, no .htaccess that will check requests if file exist etc.

Is there a module for that, or a workaround that this can be achieved with Drupal?

Thanks

I use HTTrack for this, also there's this article on drupal.org: Creating a static archive of a Drupal site.


Checking access in Views I posted a support request on Drupal.org, but I thought I may find a faster answer here.

I am using the User Relationships module to create mutual relationships between two people with the purpose of viewing content. The node access part of UR seems to work fine. I am having trouble with Views, though.

Can anyone explain to me how I would do the following?

Create a View containing content a user (not current logged in user) has created, filtered by a content type (lets call it Image). This view has a path with an argument like user/%/images.
When the current user goes to user/%/images, it should show the images for whichever user ID is passed as the argument ONLY IF both users are related/accepted relationship. There is only one relationship type on the website. If there is no relationship, I would like to serve Access Denied, or at the very least, Page Not Found. But 403 makes more sense.

I cannot get this to work.

My goal is to show links to different types of contents users have created, and the viewing user (requester?) needs to have a relationship to view the content. Otherwise they should see nothing at all, or return an access denied error.

What you need is to create a custom views access plugin. I found a blog post that contains the basic information about how to do that here: http://techcp.wordpress.com/2011/01/11/adding-custom-access-plugin-to-views-in-drupal/

You then need at least need to do two specific things:

a) Extend it so that the access callback function receives the second url argument as the argument (in function get_access_callback(), change array() to array(1)).

b) In defined access callback function, check if there is a relationship between the currently logged in users and the uid that gets passed in, by using user_relationships_load() (documentation is for D7, but very similar in D6). Something like this (untested):

function your_access_callback($uid_viewed) {
  global $user;
  $params = array('between' => array($user->uid, $uid_viewed));
  return (bool) user_relationships_load($params, array('count' => TRUE));
}

That should already be enough to make it work four your case. However, this sounds like an interesting improvement to UR in general, for this, two additional things would be necessary.

c) Allow to configure which argument is the user id. Maybe there are also other ways where it could come from (if the view is displayed as a block for example). Not sure how to do that.

d) Allow to configure which relationship type should be checked. Expose a form element for that in the options and then pass the chosen relationship type id to your access callback and in there to user_relationships_load().


correct primary key indexing Perhaps this is more of a DB/SQL question than Drupal. However, when defining large primary keys (multiple cols) how should I be indexing?

In my example below I am both setting a primary key -and- index on multiple cols. This is because I expect to use all of those cols in the WHERE part of queries. Is this correct?

  $schema['tournament_stats_node'] = array(
    'description' => 'Stores relations between tournament stats and node.',
    'fields' => array(
      'entity_type' => array(
        'description' => 'Primary key: Entity type of participants, e.g. user/team.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'nid' => array(
        'description' => 'Primary key: Related node ID',
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
      ),
      'id' => array(
        'description' => 'Primary key: Unique entity ID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'stat' => array(
        'description' => 'Tournament stat type',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array('entity_type', 'nid', 'id'),
    'indexes' => array(
      'entity_type' => array('entity_type'),
      'id' => array('id'),
      'nid' => array('nid'),
      'stat' => array('stat'),
    ),
  );

This is not a trivial question and you're actually asking multiple things :)

As mentioned by BetaRide, a technical, auto-generated key has the advantage that it is much simpler to maintain. The primary key defines how the data is stored and if you have a simple key then update/insert/delete should be a bit faster. What's better in general is a hard question to answer, you could make some comparisons (test both approaches, write 1 million rows and then compare update/delete/query speed)

For the indexes, you do most certainly not need a separate key per column. Some hints:

Only a single index can be used for a single query. Unless you will have queries which only have a condition on e.g. the id, that index is useless.
Indexes on multiple columns are read from left to right. E.g. a index on A,B,C can also be used for a query with conditions on A and B but not for one on B and C.
The more indexes you have, the slower are updates.

Same here, I recommend to fill your table with data and then use EXPLAIN to see how your queries are executed and which index they use. Then you can start to optimize things.


pass custom variable for image field from preprocess node to twig I have a content type (gallery) with an image field which is unlimited: field_picture.
I have a logic which calculates custom css classes to their HTML containers, like: grid-item--width1, grid-item--width2, grid-item--height1, grid-item--height2.
I store these in the grid_class.
I can't merge these classes with the item class, because I want to style different HTML containers by them.

I tried to add this new variable (grid_class) to the image elements from the mytheme_preprocess_node__gallery and I thought drupal8 will pass them to the twig template.

function mytheme_preprocess_node__gallery(&$variables)
{
  foreach (Element::children($variables['elements']['field_picture']) as $key) {
    // here is my logic which calculates the classes for the image elements' containers
    $grid_class = "grid-item--width1 grid-item--height1";
    $variables['elements']['field_picture'][ $key ]['grid_class'] = $grid_class;
  }
}

but in my twig template (themes/custom/mytheme/templates/field/field--node--field-picture--gallery.html.twig) when I loop through the items, the grid_class isn't available.

{% for key, item in items %}

    {{ (dump(item)) }}

{{ item.content }}

{% endfor %}

I also tried to add it from mytheme_preprocess_field(). I saw the array of the field_picture element, but I didn't find the items in there.

any help or hints?

I found that I have to use the mytheme_preprocess_field hook.

function mytheme_preprocess_field(&$variables) {
  if ($variables['field_name'] == "field_picture") {
    foreach ($variables['items'] as $key => $item) {
      $grid_class = "grid-item--width1 grid-item--height1";
      $variables['items'][ $key ]['grid_class'] = $grid_class;
    }
  }
}


How to Display terms only if associated with a node Using Drupal 6:
I need to show child terms for the currently viewd taxonomy term in a block. I finally stumbled on a piece of code that does exactly what I want. Original code from here

As per the instructions I've added the following to my template.php

function themename_child_terms($vid = 1) {
  if(arg(0) == 'taxonomy' && arg(1) == 'term') {
    $children = taxonomy_get_children(arg(2), $vid);
      if(!$children) {
        $custom_parent = taxonomy_get_parents(arg(2));
          $parent_tree = array();
          foreach ($custom_parent as $custom_child => $key) {
            $parent_tree = taxonomy_get_tree($vid, $key->tid);
          }
          $children = $parent_tree;
      }

    $output = '
';
    foreach ($children as $term) {
      $output .= '
';
      $output .= l($term->name, 'taxonomy/term/' . $term->tid);
      $output .= '
';
    }
    $output .= '
';

    return $output;
  }
}

I've then created a block and added :

<?php // $vid is the vocabulary id.
    print themename_child_terms($vid = 1);
?>

This shows the child terms of the current term perfectly. However, it shows ALL terms that exist under the parent term, even if there are no nodes tagged with that term.

e.g. viewing the page with all items in 'Term 1', I get

child 1
child 2
child 3

correctly listed in the block. But, if there are no pieces of content tagged with 'child 3' for example, it's still showing up that term in the block. This isn't very useful as it links to an empty term page.

How would I modify the code to only show children that actually have nodes associated with them. So if there are no children tagged 'Child 3', then that term would not show up..

I've found this function in taxonomy.module
Can I use this function to do what I want?

/**
 * Count the number of published nodes classified by a term.
 *
 * @param $tid
 *   The term's ID
 *
 * @param $type
 *   The $node->type. If given, taxonomy_term_count_nodes only counts
 *   nodes of $type that are classified with the term $tid.
 *
 * @return int
 *   An integer representing a number of nodes.
 *   Results are statically cached.
 */
function taxonomy_term_count_nodes($tid, $type = 0) {
  static $count;

  if (!isset($count[$type])) {
    // $type == 0 always evaluates TRUE if $type is a string
    if (is_numeric($type)) {
      $result = db_query(db_rewrite_sql('SELECT t.tid, COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 GROUP BY t.tid'));
    }
    else {
      $result = db_query(db_rewrite_sql("SELECT t.tid, COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 AND n.type = '%s' GROUP BY t.tid"), $type);
    }
    $count[$type] = array();
    while ($term = db_fetch_object($result)) {
      $count[$type][$term->tid] = $term->c;
    }
  }
  $children_count = 0;
  foreach (_taxonomy_term_children($tid) as $c) {
    $children_count += taxonomy_term_count_nodes($c, $type);
  }
  return $children_count + (isset($count[$type][$tid]) ? $count[$type][$tid] : 0);
}

Thank you kindly for any solutions.

Nick

Hmm... I'd try something like this:

Change this part of your code:

foreach ($children as $term) {
  $output .= '
';
  $output .= l($term->name, 'taxonomy/term/' . $term->tid);
  $output .= '
';
}

to something like this:

// Avoid unnecessary "Invalid foreach" errors showing up in the log:
if (!empty($children)) {
  // If not empty, run the foreach loop:
  foreach ($children as $term) {
    // Then check to see if any nodes exist for that term id:
    $number_of_nodes = taxonomy_term_count_nodes($term->tid);
    // If there ARE nodes...
    if ($number_of_nodes > 0) {
      // ... then add them to the output:
      $output .= '
';
      $output .= l($term->name, 'taxonomy/term/' . $term->tid);
      $output .= '
';
    }
  }
}

Hope that helps... :)


Drupal 7 Core Module Function for node_save? In Drupal 7, i want to put a additional code when the Save button is Clicked (Saving) in "a content" form (New or Edit).

I don't want to know the hook (because i don't want to make an obvious Custom Module). Because i don't want to let other users know the operation by having a obvious Custom Module which will be listing inside the Module Panel. So i want to make a Silent Customization inside the Existing Drupal Core Module (correspondence Function).

Thats why I just want to know the Function in the Core Modules which finally process the Node Save task.

Can anyone please describe which Function (in Core Modules) is finally processing the Drupal Node Save? (Save` finally may be for both New Item Insert or existing Item Edit.)

DO NOT HACK CORE

Now that's out of the way, let's continue.

The way I see it, you have a couple of options:

1) Use Rules.

  The rules module allows site administrators to define conditionally
  executed actions based on occurring events (known as reactive or ECA
  rules). It's a replacement with more features for the trigger module
  in core and the successor of the Drupal 5 workflow-ng module.

Although this will allow people to see that there is code being run.

2) Create a custom module, but in your info file make use of the hidden property:

  As of version 7.x, modules and themes may specify that they should not
  be visible on the modules page by adding hidden = TRUE. This is
  commonly used with testing modules used with SimpleTest where
  end-users should never enable the testing modules.


How do you swap position of Order Total Components in Checkout Pane? In Commerce Shopping cart contents checkout pane, how do you swap the position of order components? We want the Sales Tax to appear -below- the Shipping.

Do it in a custom module implementing hook_commerce_price_formatted_components_alter(). See commerce_price.api.php for parameter information.


Ubercart: Change the product display form label "SKU" How would you change the display of SKU? (Which hook manages the product-node display?)

I need sku to output to display "Model #". on a product node page

Drupal Version 6.2x


Block won't appear on specific language pages I have a view with a filter to show entries based on chosen language (Configure filter criterion: Content: Translation language = Interface text language selected for page). The view is placed into a block, and that block is set to show for all languages. The block's placement is restricted to the page node and all its translations, for example /node/1234, /company, /empresa, and /enterprise.

Then when I go to some of the pages, it doesn't show. It's only appearing for Global default language and ES-US, randomly. French and US English it doesn't appear for, even though the alias is exactly what I've got: /company and /enterprise.

I cannot, for the life of me see any reason this should be happening. Every setting I know of is set, and the exact same thing is working for every other block I've set up like this.

Disregard the question above. After my 'frustration post' I realized the most obvious thing. It wasn't Showing French because I didn't have French translations... I had FR-CA - French CANADIAN translations.

Doh!


How to stop nodes being automatically added to a simple queue in Nodequeue? I'm guessing my problem is a configuration error, but every kind of node that is allowed to be added to my (I only have one) simple nodequeue does get added to the nodequeue when a node of an allowed content type is created. I only want specified nodes to be allowed into the queue. Any ideas of where to look?

In case someone else runs into this, I finally figured it out.

In the settings (admin/structure/nodequeue/[NODEQUEUE_ID]/edit), there's the list of "Type" checkboxes. When I originally set this up, I assumed that I had to check those content types that I wanted allowed into a queue. Turns out, this actually seems to auto-add new nodes of those content types. I unchecked all of the checkboxes, and now things seem to work as they should.


How do I use jQuery code through a module/theme? How do I use jQuery through a Drupal 8 module?
I'm trying to get some jquery code running on a drupal 8 website. It's a div animation that randomly moves the div within a wrapper.
I've added the JS and CSS files and they're both showing in the source. I've then added the Div ID of 'container' to html.html.twig(yes I copied it into my theme folder first) -

{%
  set body_classes = [
    logged_in ? 'user-logged-in',
    not root_path ? 'path-frontpage' : 'path-' ~ root_path|clean_class,
    node_type ? 'page-node-type-' ~ node_type|clean_class,
    db_offline ? 'db-offline',
    theme.settings.navbar_position ? 'navbar-is-' ~ theme.settings.navbar_position,
    theme.has_glyphicons ? 'has-glyphicons',
    'container',
  ]
%}

Also added a div to use for this. Again in html.html.twig

<js-bottom-placeholder token="{{ placeholder_token|raw }}"> //**Not part of my code just adding it for comparison.

TEST DIV, IF I MOVE I'M WORKING!

So the files show up in the source and the source also shows that the div ID of container has been added.

Here's the jQuery code, keep in mind that I've adjusted it to work with Drupal 8 so there's probably a syntax error or two.

$.extend(Drupal.theme, {
  animateDiv: (function() {
    ($('.fly')); }),

* Almost certain the problem is here ^^^

  makeNewPosition: function ($container) {
    // Get viewport dimensions (remove the dimension of the div)
    var h = $container.height() - 10;
    var w = $container.width() - 10;

    var nh = Math.floor(Math.random() * h);
    var nw = Math.floor(Math.random() * w);

    return [nh, nw];
},

animateDiv: function ($target) {
    var newq = makeNewPosition($target.parent());
    var oldq = $target.offset();
    var speed = calcSpeed([oldq.top, oldq.left], newq);

    $target.animate({
        top: newq[0],
        left: newq[1]
    }, speed, function() {
        animateDiv($target);
    });

},

calcSpeed: function (prev, next) {

    var x = Math.abs(prev[1] - next[1]);
    var y = Math.abs(prev[0] - next[0]);

    var greatest = x > y ? x : y;

    var speedModifier = 0.23;

    var speed = Math.ceil(greatest / speedModifier);

    return speed;

}

});

Here's the CSS code

.fly {
width: 50px;
height:50px;
background-color: red;
position:fixed;

}

That's what I've tried and yet there's still no jQuery activity, I've also tried using different types for class names(.div instead of #div etc) which I think is where the problem is. The flying div shows but isn't being styled and there's no jQuery. What am I doing wrong?

Update: After playing with the code for awhile I've managed to at least get the style to show on the div. jQuery still a no show though..

This isn't the same jquery code but it's similar and it's what I would like, the div floats around the entire page, I've tried using this code as well but I still get the same problem as above. http://jsfiddle.net/Xw29r/15/

In Drupal 7 and 8 your JS code needs to be wrapped like this:

(function($) {
Drupal.behaviors.myBehavior = {
  attach: function (context, settings) {

    //custom code goes here

  }
};
})(jQuery);

To test, put the following code inside your JS file.

(function($) {
Drupal.behaviors.myBehavior = {
  attach: function (context, settings) {

    //code starts
    $("body").click(function() {
      alert("Hello World");
    });
    //code ends

  }
};
})(jQuery);

Now when you click in the body, you should get an alert saying hello world.

For more info read the JavaScript API in Drupal
 8


CCK Select List widget with "Add another item" functionality? With certain field types that are set to unlimited you get an "Add another item" button that lets you create as many fields as you need. If you set a field with a Select List widget to unlimited it instead gives you a select list box that has ctrl click functionality for selecting multiple.

I want to know if there's a way to make a Select List widget that is set to unlimited instead show a regular select list, and an "Add another item" button that creates further select lists.

Try one of these modules

Select (or other)
CCK Select Other


How do I invalidate the cache of an entity? Is there any easy way to clear the cache for a custom entity?
I know there is an entry in the cache_entity-Table. If i manually delete it, everything is fine.
I tried doing the same as in \Drupal\Core\Entity->invalidateTagsOnSave() or \Drupal\Core\Entity->invalidateTagsOnDelete(). This does not seem to change anything.

Unfortunately I can't just load the entity and resave it in this situation.

But you know the entity ID that you want to have invalidated?

Then use \Drupal::entityTypeManager()->getStorage($entity_type_id)->resetCache([$id]);


How to change the existing images embedded in Views Twig template to S3 bucket URL I have embedded the images using views twig template,

file_url(row['content']['#row']._entity.field_future_program_image.entity.fileuri) %}

The output is public://2018-07/10a_0_0.JPG

Instead, I need the image URL from the s3 bucket: https://s3.bucketname/2018-07/10a_0_0.JPG

Note: I have configured amazon s3 and moved the local files to s3

Try adding

$settings['s3fs.use_s3_for_public'] = TRUE;

After that clear cache, now your site images will render form Amazon S3 bucket.


Views Relationship with profiles I am trying to create a view where I have the same taxonomy term for a node and profile to link the two together.  Here is what I did:

I created a profile with a taxonomy(Current Company) with a value of: company1

I create a node with a taxonomy(Current Company) with a value of: company1

I created a user view and created a relationship to see all content. This works but I tried to create a filter where the logged in user profile (company1) = the value of the node taxonomy (company1).

So basically since the logged in user belongs to company1 he only see content related to company1.

I have been trying different combinations and cannot get this to work, I know it has to be possible.

Thanks

You can use relationship settings to add in the taxonomy, and then add a contextual filter on "user:uid" with taxonomy value fetched from currently looked-in user.

Have a look at this refrence: https://drupal.org/node/1111722#comment-4315620

Copied here in case that node goes away:

Create a user view.

Add a contextual filter on user: uid. If no filter value is present,
build a default value using the currently logged in user. (This will
give you exactly one user object in your view -- the logged in user.)

Add a relationship, using the relevant taxonomy reference field on
the user accounts. This will bring you information about the
"interest" term for the logged in user.

Add another relationship, called "term: nodes marked with term" (or
something like that). This will bring you information about all nodes
marked with the interest term for the logged in user.

Either set the view to display node teasers, or select a number of
fields to display.

Add a display as usual. Done!


Unable to add content? I am working on a project with a fresh install of Drupal 7.41 and the customer wanted to use a Themeforest layout.

Installation of core, theme and modules went without a problem, however, when I try to create content via 'article or basic page' nothing happens except a page refresh. No content shows in the content list and no content is created.

Yet, I am able to create a webform with the webform module.

Notes

I have checked my logs and there are no errors.  None!
I cleared my cache several times
I am running as Admin and the proper permissions have been checked.
My roles are in the proper order.  (Admin being at the bottom)
I created a new custom content type and that does not work either.  Even after enabling permissions.

Any insight would be greatly appreciated as I have never encountered this issue before.

Apparently there is an issue with the CKEditor module.  Once I disabled it I am now able to post content as normal.  I will have to find another WYSIWYG to replace it.


How to have a combined search view that shows both users and content on search terms? I've looked at multiple modules (Faceted Search, Custom Search, an abandoned project named search_all) but I haven't been able to find anything that works with 7.x.

What I'm looking for is just a way to let users search on a search term and then get a page of results from all content, including other users in the system.

Any ideas?

Haven't tried it, but I believe you could use Apache Solr with the http://drupal.org/project/search_api, http://drupal.org/project/search_api_solr, and http://drupal.org/project/search_api_multi

Create two indexes, one for nodes and one for users.  Then create a view that uses both indexes.


HTML5 and Full HTML Filter I have the following markup:

The Father

Born in 1972, a fisherman by trade

</figcapion>

With the Full HTML filter:

The "add line breaks" option adds in lots of superfluous
's
The "correct faulty HTML" means that adding
 and
 sees the caption get chucked outside of the  mangling the layout

The thing is, I like automatic line breaks and I like faulty HTML being corrected, and I don't want my content creators to have to think which filter to use, or have to add in paragraph tags because they decide to use a
 tag.

Is there any module/option that can make these parts of the Full HTML filter work nicely with HTML5?

I just came across the same issue, and although this is a rather old question I thought I'd give my solution in case any others find their way here.

Text formats have the option to correct 'faulty' HTML, although it's not the best choice if you'd still like to make sure that actual faulty HTML is corrected, you can turn this off by navigating to:

HOME > ADMINISTRATION > CONFIGURATION CONTENT AUTHORING > TEXT FORMATS > %your format%

Deselect 'Correct faulty and chopped off HTML' and Drupal will stop mangling section, article, figure, and other useful HTML5 tags.


combine several exposed filters into one exposed (search) form? Is there an easy way to combine two or more exposed filters into one shared exposed form? So that I don't have to have several search fields for each and every field that I want to filter.

Is this possible? Any modules that does this? I am using the Better Exposed Filters module.

Thanks in advance

Views 3 provides solution for your question from the box.
It's Global: Combine fields filter.

Add fields.
Add Global: Combine fields filter to filter criteria.
Check fields you want to combine in filter's settings.

If you use Display suite or teasers mode - force using fields in the View settings (under Format -> Settings).


How to get "Show block on specific pages" working? I would like to show a certain block only on one specific page. I want to use the Show block on specific pages feature for it. I have tried to set the url of my page like content/hills-restoration-process  as well as the actual node number, like /node/36 but I don't seem to get it to work correctly. What am I doing wrong here? It seems like an easy and straight forward feature...
Thanks for hints and suggestions!

When you use this field don't provide the leading slash.  Try node/36.

Not sure why the alias wouldn't work - perhaps there's a character out of place.  Node numbers work better because the block then doesn't disappear if the alias changes.


Webform Redirect Hook I built a module that submits the webform data to a soap api. The API an take a while to respond (out of my control), so what I'm looking for is a redirection hook, so I can go Submit->Force Redirection->submit to api.

Users are hitting submit more than once due to the api response time (understandably)

You can disable the double click  on submit using the below jQuery code.

$('#formid').submit(function(){
    $(this).children('input[type=submit]').prop('disabled', true);
});

Now you can use the below code to alter submit of webform in your custom module

/**
 * Implementation of hook_form_alter().
 */
function mywebform_extra_form_alter(&$form, &$form_state, $form_id) {
  // Add extra submit for a particular Webform node:
  if ($form_id == 'webform_client_form_44') {

    // Add the submit handler after the existing Webform submit handler,
    // but before the second Webform handler. Pop off the first one and add
    // ours second.
   $form['#submit'][] = 'mywebform_extra_validate_44';
  }
}

/**
 * Submit handler for Webform ID #44.
 */
function mywebform_extra_submit_44(&$form, &$form_state) {
  global $user;

  // Now you can perform here api request and redirect
}

Hope it will help you.


Composer issue after I deleted the vendor directory We have Drupal 8.8.5 running on CentOS Linux 7 with PHP 7.1.33.

Was trying to update modules using composer. Composer said they were updated, but when I went into program, they weren't. In troubleshooting, I deleted the "vendor" directory. Now, I get this error:

  [root@ip-172-31-13-94 master]# composer update --with-dependencies
  Loading composer repositories with package information
  Updating dependencies (including require-dev)
  Your requirements could not be resolved to an installable set of packages.

  Problem 1
  - drupal/core-recommended 8.8.0 requires composer/installers v1.7.0 -> satisfiable by composer/installers[v1.7.0].
  - drupal/core-recommended 8.8.0-beta1 requires composer/installers v1.7.0 -> satisfiable by composer/installers[v1.7.0].
  - drupal/core-recommended 8.8.0-rc1 requires composer/installers v1.7.0 -> satisfiable by composer/installers[v1.7.0].
  - drupal/core-recommended 8.8.1 requires composer/installers v1.7.0 -> satisfiable by composer/installers[v1.7.0].
  - drupal/core-recommended 8.8.2 requires composer/installers v1.7.0 -> satisfiable by composer/installers[v1.7.0].
  - drupal/core-recommended 8.8.3 requires composer/installers v1.7.0 -> satisfiable by composer/installers[v1.7.0].
  - drupal/core-recommended 8.8.4 requires composer/installers v1.7.0 -> satisfiable by composer/installers[v1.7.0].
  - drupal/core-recommended 8.8.5 requires composer/installers v1.7.0 -> satisfiable by composer/installers[v1.7.0].
  - drupal/core-recommended 8.8.x-dev requires composer/installers v1.7.0 -> satisfiable by composer/installers[v1.7.0].
  - drupal/core-recommended 8.9.0-beta1 requires composer/installers v1.7.0 -> satisfiable by composer/installers[v1.7.0].
  - drupal/core-recommended 8.9.0-beta2 requires composer/installers v1.7.0 -> satisfiable by composer/installers[v1.7.0].
  - drupal/core-recommended 8.9.x-dev requires composer/installers v1.7.0 -> satisfiable by composer/installers[v1.7.0].
  - Conclusion: don't install composer/installers v1.7.0
  - Installation request for drupal/core-recommended ^8.8 -> satisfiable by drupal/core-recommended[8.8.0, 8.8.0-beta1, 8.8.0-rc1, 8.8.1, 8.8.2, 8.8.3, 8.8.4, 8.8.5, 8.8.x-dev, 8.9.0-beta1, 8.9.0-beta2, 8.9.x-dev].

Can someone tell us how to resolve this? Thanks!

Resolved the issue:

$ composer selfupdate

Updating to version 1.10.5 (stable channel).
   Downloading (100%)
Use composer self-update --rollback to return to version 1.6.2

Appaprently, my version of composer was too old.


How to display a Rules Link only if access to display the linked content was granted? I'm using the Drupal Commerce 7.x, Rules Link, and Content Access modules.

In my site Classified ads can be created, and then people can use credits (via User points) to pay for unlocking "contact informations".

For example, when an advertiser creates an ad, 2 things happen:

content (node) of type "Classified ad" is created, and
it is cloned and converted in another content (node) of type "Classified complete".

So there will be 2 different nodes: the first one is a "Classified ad" and the second one is a "Classified complete".

The "Classified ad" is the node which has limited information and the "Classified complete" is the node which has all information. They are all linked together with the "Rules link" module.

The "Classified ad" node is displayed for everyone and the "Classified complete" node linked to it can be accessed only if a user paid for it already.

More info about my current setup as described above is included also in my related question "How to access node properties of another node using the Rules Link module?".

Now I want to further refine the display of the link shown via "Rules Link": I want to display a link rules in "Classified ad" nodes only if all these conditions are satisfied:

The current user is an authenticated user (done, as per my linked question).
The current user already bought the node "Classified complete" so the user has an access granted to that node (with the Content access module).
A page redirect to the node "Classified complete"(done, as per my linked question).

How to check if my current logged in user already has the access granted to a node id (the 2nd condition in the previous list)?

From the (my) accepted answer to your related question (= How to access node properties of another node using the Rules Link module?), I do remember that apart from the Content Access module, you ALSO use the ACL module.

However, even though via the ACL module you do get some extra Rules Actions (such as content_access_action_user_grant), there doesn't seem to be (or at least I have not found it yet) a Rules Condition that you could use to check that "the current user already bought the node" (as in your question here).

Too bad, if IT IS NOT available, then just MAKE IT available. For that, you can use the Flag. If you then configure a (non-global) flag, you could use that flag like so:

When configuring the flag, only allow it for bundle 'Classified Ad'. And make sure to only grant access to the flag to users with a role like "special role for Classified Ads" (name it what you want), to avoid the link to flag such nodes would be shown to unauthorized users (due to which they could flag the node just using the UI, which you do not want to happen).
Around the time the user buys access to your 'Classified complete' node, perform an additional Rules Action to "flag the 'Classified Ad' node by the current user as bought", and with the machine name of the flag (say) 'node_bought' (pick whatever fits).
Within the Rules Link, use a condition like "Is the node flagged with the 'node_bought' flag by the current user?".

Below is a (rather basic) Rules Component (= condition set (AND) "Rules link: authenticated user Link contact infos condition") with machine name to match your existing Rules Link also, as in your linked question. And which you could use for this (change the machine name of the flag from 'node_bought' to your flag's machine name, prior to importing this):

{ "rules_link_condition_access_to_contact_info_links" : {
    "LABEL" : "Rules link: authenticated user Link contact infos  condition",
    "PLUGIN" : "and",
    "OWNER" : "rules",
    "REQUIRES" : [ "flag" ],
    "USES VARIABLES" : { "node" : { "type" : "node", "label" : "node" } },
    "AND" : [
      { "flag_flagged_node" : {
          "flag" : "node_bought",
          "node" : [ "node" ],
          "flagging_user" : [ "site:current-user" ]
        }
      }
    ]
  }
}

Something I'm unsure about right now (= homework for you to QA-test): as per that "special role for Classified Ads" (see before), the (extra) Rules Action to flag the node may fail (not authorized for current user). If that's the case, then just add these 2 extra Rules Actions as a work around for that:

Grant access for current user to "special role for Classified Ads", right before the Rules Action to flag the node.
Remove access for current user to "special role for Classified Ads", right after the Rules Action to flag the node.


mailsystem module does not appear in the selection field for HTML Mail module class when I go to the mailsystem module configuration, only two selection fields appear

I do not know why this behavior can be given, there is some option that makes this disappear. I have installed the mailsystem and htmlmail modules

What I see in the site where the selection field is missing

What should be shown (what I need)

Below where you show in your screenshot, see the "New Class" field set.
Expand that

For the Class to use for the format() (link is external) method field select HTMLMailSystem

Class to use for the mail() (link is external) method select SmtpMailSystem

Save the form.

The new class will be available for use to set the Site Default.


why are Twig template variables with markup not being rendered? In my template preprocess function I have a variable:

$test = "
this is a paragraph
";

and I pass it to my template:

$variables['test'] = $test;

and output it in twig:

{{test}}

but instead of getting a formatted paragraph, I'm getting the original output in plain text:

this is a paragraph

How do I get Drupal to render this as normal HTML?

Because twig auto-escapes unsafe content and your content isn't marked as safe.

You can explicitly tell it that it is with $test = Markup::create($test); but you should be very careful with that. If it contains any sort of user input, you might open yourself for XSS issues.

Better approaches are using a render array like ['#markup' => 'your text'] which by default will allow a certain amount of html tags but not all of them. You can also use an inline template as documented here: https://www.drupal.org/node/2311123.

Twig natively understands render arrays, so it doesn't matter for your template if you provide a render array or a string.


How can I unset an option from Profile2 while it is part of Registration? I have a Main Profile page that I added to the User Registration page but I only need one option from the entire Main Profile to display while the user is creating an account. I was able to hide all of them using 'display: none' in the CSS but this caused an issue with a particular field in the Main Profile where they could list themselves as 'Featured'.

In my Custom Module I have a form_alter function but when I print out the form in  tags it only shows the form values of the actual registration part. It doesn't include any fields from the Main Profile. In the developer tools on Chrome it shows that the Main Profile section is in the same form as the registration section.

Is there any way I can get to the Main Profile elements to do an unset on my particular field within my form_alter function?

Thanks

Main profile fields are added through hook_form_alter.
Solution:
hook_form_alter function is executed in all modules while accessing registration form. Your custom module form_alter is executing before Profile fields get added. To solve this issue increase custom module weight. FYI : Module weight change


change image size in media file selector of media module how can I change the size of the image that show in media file selector popup in media module
, I don't know which image style this module use, and how can I change the image style which is currently used or active.

The media module adds the image style 'square_crop' when it is enabled

you can alter this image style to change the display of thumbnails in the media browser (admin/config/media/image-styles/edit/square_thumbnail).

I believe the theme css also uses css to define the size, so to see the effect you will also need to make some changes in whichever theme is selected for the media browser (admin/config/media/browser):

.media-item img {
 border: 2px solid transparent;
 display: inline-block;
 margin-left: -2px;
 height: auto; /* override this in you theme */
 width: 100%; /* and this */
}


Receiving notifications when user edits a node? Newbie here!
I'm running a site on Drupal 7 (iloveqatar.net) and users have the ability to submit their own content (News, Events, etc...).

I'm facing a couple of issues.

1) When users submit new content that's in moderation to be approved, I don't get any notification. What's the best module to a) send emails to moderators / admins so they're aware there is content that needs to be approved and b) Display the notification on the site (like an unread message counter).

Right now I click on "Needs Review" on the admin bar on the top of the site every few hours just in case theres new content.

2) This one is the more problematic issue. When a user submits an event for example, and it's then approved, the user still has the ability to edit his/her post, which then creates a draft that needs to moderated and approved. However since it's creating a draft of an existing note, I'm not seeing it under the 'needs review' table. I actually have to go to that specific event and then edit it to approve the changes. Of course that's no good for me, because I can't go around checking every single post just in case there's an edit.

Does anyone know of a solution for this so that I can get notified and/or it shows up in 'needs review' ?

Please do let me know if I need to include any additional information to get help.

Thank you so much in advance!

Newer versions of the Workbench Moderation module integrate with Rules.  I am not sure if the patch is in the stable tree, or whether you need to use the dev version, though.

Assuming you have a version that supports this, then

add a new rule
for the reaction, choose Node: After moderation transtion
for the action, choose Send mail
if needed, you can add conditions based on the old and/or new moderation state.

After that, just configure the conditions and the email that gets sent out.


The service "redirect.request subscriber" has a dependency on a non-existent service "path.alias_manager" While upgrading D8.9 to D9.1 got the below issue. Tired all solution nothing works. Because on this issue site is down and unable to process anything.

[php7:notice] [pid 26850] Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: The service "redirect.request_subscriber" has a dependency on a non-existent service "path.alias_manager". in /var/www/xxxx/xxxx/xxxx/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php on line 86

Could anyone faced this issue or how to overcome?

In Drupal 8.8 path.alias_manager was deprecated and in Drupal 9 it was removed. You need to update the Redirect module to a version compatible with Drupal 9.
The current version contains the correct service definition having path_alias.manager as dependency:
modules/contrib/redirect/redirect.services.yml
redirect.request_subscriber:
  class: Drupal\redirect\EventSubscriber\RedirectRequestSubscriber
  arguments: ['@redirect.repository', '@language_manager', '@config.factory', '@path_alias.manager', '@module_handler', '@entity_type.manager', '@redirect.checker', '@router.request_context', '@path_processor_manager']
  tags:
    - { name: event_subscriber }


Add View Block when editing Content I've got a content type called PartyGuest. That content type has an entity reference field for "Primary Guest", so if I'm inviting Bob and Jane to the party, Bob and Jane are both content nodes but I only want to send one invitation so I make Bob's "Primary Guest" value equal to Jane. That way I know that Bob should be included on Jane's invitation.

When I'm looking at Jane's node (or editing Jane's node), I would like to be able to see a list of everyone else who is on Jane's invitation.

I've created a View Block with a contextual filter so that it lists the names of all other PartyGuests where the Primary Guest is equal to the contextual filter value. That part works... sort of.

61 is Jane's nid. If I type "61" into the "Preview with Contextual Filters" box, then my results are exactly what I expect. It shows Bob in the list. However, if I change the Preview with Contextual Filters value to by "node/61" or "node/61/edit", then I get no results at all.

How do I make my context filter grab the value from the url?

I've set the Contextual Filter to provide a Default value and to pull it from the 2nd URL path component, but it doesn't seem to work. Even when I have it set this way, it only works if I put "61" into the Preview box, but does not work if I put "node/61" into the preview box.

I've also tried setting the Default value to be the Content Id from the URL with no luck.

What am I missing?

"Content Id from URL" is indeed what you want. The preview box doesn't care for the rest of the url (the /node/*/edit part) and takes everything entered there as an argument.


Views: Modify filter/argument when no results occur I currently have a "store locator" proximity search setup very similar to the one detailed here: http://www.youtube.com/watch?v=AxeskzN8BAc.

The user enters a postcode, and receives results or no results as the case may be, for a given rectangular distance (say 100km around the entered postcode). Both postcode and distance are exposed filters.

If a node/marker isn't within the zone, I get no results. How can I dynamically modify or widen the distance so there are always some results? ie. How can I hook onto the exposed filter arguments and re-run the view for the no-results case?

You can call the view programatically and if no result are found call it again with new filter arguments.

For example:
    $view_id = 'your view id';
    $display_id = 'your display id';

$view = views_get_view($view_id);
$view->preview($display_id, $views_args);

if (!count($view->result)) {
  // No results, call view again with other filter value.
  $filter_name = 'your filter name';
  $filter_value = 'your filter value';

  $view = views_get_view($view_id);
  $view->preview($display_id, $views_args);
  $view->display['default']->display_options['filters'][$fiter_name]['value'] = $filter_value;
  $view->preview($display_id, $views_args);
}

You will have to adapt it using your current filter name and right values. You can rewrite this example to modify the view all the times you need.

Put this code in a hook_menu callback returning the  view.


Set the reply address for the contact form to user's mail address I have a Drupal 7 site with only few modifications and I have the /contact form enabled for anonymous and registered users, so that they can contact the admin (i.e. me) easily.

What irritates me is that their messages always have my own mail address as the reply address. And so in order to reply to them, I have to search my "Sent items" folder for the user name (I relay the mails through gmail at my CentOS server).

Isn't there a way to set the reply addresses to the ones of registered users and why isn't it done by default?

I've added apache to /etc/mail/trusted-users to get rid of the following mail header:

  X-Authentication-Warning: mysite.com: apache set sender to my@email.com using -f

But still, I see the "From" header is always set to the admin mail address.

Isn't there a way to set the reply addresses to the ones of registered users and why isn't it done by default?

When authenticated users send a message using the system contact form, the email address assigned to the sent message is the one set for their user account; I just tested it on my Drupal 7 test site, and I can confirm it works that way.

The issue you are seeing is probably caused by the fact you are relaying the emails through Gmail.
If you need to add any header to the email sent from Drupal to resolve this problem, then you can implement hook_mail_alter() in a custom module.


Creating a website with search filters like amazon and Ebay. Is it possible? I want to create a website which will be a search based. It will allow users to narrow down results based on categories and tags. The website is not a shopping website but will be a collection of articles. The user will narrow down the results using categories and sub categories and various types. I want to know that is this kind of functionality obtained from Drupal. I am using Joomla and its not allowing me to do what I want.

You can use something like Solr as that supports faceted searching.

It is rather complicated to set up though if you are using your own search server.


Multiple urls of same node This seems duplicate content, how can i  send a header 410 for the incorrect version of the url and make sure only the correct url is used on the whole website.

This is the original URL: http://www.traveldudes.org/node/2504/
This is the alias: http://www.traveldudes.org/travel-tips/climate-and-best-time-visit-serengeti-tanzania/2504
But what’s this URL? http://www.traveldudes.org/node/2504/gallery
Or what’s this URL= http://www.traveldudes.org/node/2504/map

There are a couple of easy to use modules that will help you manage your URL aliases.  They include,

Pathauto
Redirect
Global Redirect

The first two aliases you have sounds like the 'default' ones.  You may have created (or one of the modules you have installed automatically) created the other aliases.

All the same, you can manage your aliases (and re-directs) using the modules I mentioned.


Display values in the order they are in the form field I created a field called Authors, that can take multiple values (Users registered on the site).
I would like to display the authors in the same order I add them in the field.

They are currently displayed with no logical order (it is neither the order they appear in the field, nor the alphabetical order, nor the UUID of the users...)

Finally I've found the cause of the problem : the use of Selection list or Chosen as widgets for the field.

Using the Autocomplete widget, it works fine : the order of the values in the back-end is conserved in the front-end.


Get only one field from profile I have a profile field called "myutr" that I need to pass to the browser, for ALL pages, via js

drupal_add_js(....)

I know that $user does not contain profile fields so to get the value of this field I need to load it via

$account = user_load($user);
drupal_add_js($account->myutr); //I know that is not the correct code

But in a big site with more and more page views call user_load only for a field is for me a bad perfomance practice. So: is there a possibility to load only this field via drupal standard api ? Or I need to call db_query(....) ?

Thanks.

Have a look at this article, I've used the method in the past.

http://timonweb.com/working-with-drupal-fields-getting-single-field-values-for-display-and-manipulaton


Merging view displays into same view I've got a view with 5 complex view displays (4 pages and 1 feed).

I've also got another view with 7 even more complex view displays which where automatically generated from the calendar module.

Is it possible to merge those 2 view displays into the same view? Or alternativelly execute Add view from template within an existing view. So the 7 calendar view displays ends up appended in the view which already contains my 5 custom view displays.

What I've tried so far:

Add view from template in a new view and replicate/recreate by hand my custom 5 displays
export the 2 views with features and try to merge the code so I can "features revert" to a single view

Is there a better way?

Your 2nd approach may be more trouble than it's worth, unless this is a learning exercise. As far as other options go, can't think of any, you may have to just recreate your displays.


How to safely remove drush via pear and then install via composer? I have drush 5 installed on my VPS running CentOS 6. Drush was installed using PEAR.
Can I just remove the drush directory and the simlinks and then install drush 7 using composer?

I have been searching for a way to uninstall drush, but all I get are tutorials to install it.

Uninstalling Drush using Pear

If Drush has been installed using Pear, it can be removed using the following command.

pear uninstall drush/drush

Installing Drush via Composer

For the most current install instructions, refer to the Drush GitHub page.

1) Add Composer's global bin directory to the system PATH (recommended):

sed -i '1i export PATH="$HOME/.composer/vendor/bin:$PATH"' $HOME/.bashrc
source $HOME/.bashrc

2) Install Drush

composer global require drush/drush


FillPDF syntax for multiple webforms I have a single PDF form with fields specified to several webforms.  I can successfully generate a PDF for each form individually.  using the url http://mydomain.dd:8083/fillpdf?fid=58&webform[nid]=19 and http://mydomain.dd:8083/fillpdf?fid=58&webform[nid]=33.

How do I combine the two NIDs into one FID=58?

Thanks for your help.

After many back and forths, I figured out the syntax for using multiple webforms (and this can be applied to NIDs).  The syntax would be:

http://yourwebsite.dd:8083//fillpdf?fid=61&webforms[0][nid]=33&webforms[1][nid]=19

You can increment the webform number and continue to add NIDs.  I am pretty sure that this syntax works with SIDs as well, but I have no need for anything other than the most current submission at this time.

Additionally, note that as of the writing of this... this does NOT work the production version (7.x-1.10) of FillPDF but ONLY with the development version (7.x-1.x-dev).


Setting field values on a per-import basis when using Feeds A student newspaper I work with is needing some way of importing XML files from InDesign. I'm thinking Feeds/Feeds XPath Parser is the best route for this.

However, one problem with this is that each week the Production Editor will need to import 4-8 XML files, one for each section. "Section" is a taxonomy field in the Drupal "Article" content type, and it's listed nowhere in the XML files they output.

To this end, is there any way to manually set the values of certain fields when importing, on a per-import basis?

I'm thinking this would look like a text box that shows up in Feeds UI when uploading the XML file. Feeds Tamper seems like an idea, but it looks like it's more designed to set default values, and less set specific values on a per-import basis.

Any thoughts?

There's also hook_feeds_after_parse() which lets you modify what's being saved to to your targets.  Something like this should work:

function my_module_feeds_after_parse(FeedsSource $source, FeedsParserResult $result) {

  if($result->title == 'title-of-feed-importer') {
    foreach($result->items as $item_key => &$item) {
      if ($item_key == "name-of-the-field") {
        $item = 'Value to set';
      }
    }
  }

}


How can a module check if Drupal is showing one of the update pages? What should a module do to verify if Drupal is updating the database tables to avoid to output a message when one of the update pages are being shown (or to avoid to do any superfluous task during the update)?

The module I am referring to is a custom debugging module that does some tests at every requested page, and outputs the result using drupal_set_message().

devel.module has a function called devel_silent() that does some very comprehensive checking. I might replicate this in your own module.

function devel_silent() {
  // isset($_GET['q']) is needed when calling the front page. q is not set.
  // Don't interfere with private files/images.
  return
    function_exists('drupal_is_cli') && drupal_is_cli() ||
    (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'ApacheBench') !== FALSE) ||
    !empty($_REQUEST['XDEBUG_PROFILE']) ||
    isset($GLOBALS['devel_shutdown']) ||
    strstr($_SERVER['PHP_SELF'], 'update.php') ||
    (isset($_GET['q']) && (
      in_array($_GET['q'], array( 'admin/content/node-settings/rebuild')) ||
      substr($_GET['q'], 0, strlen('system/files')) == 'system/files' ||
      substr($_GET['q'], 0, strlen('batch')) == 'batch' ||
      substr($_GET['q'], 0, strlen('file/ajax')) == 'file/ajax')
    );
}

You can probably simplify this a bit to just the part that is checking for 'update.php' and the $_GET['q'] checking.

    strstr($_SERVER['PHP_SELF'], 'update.php') ||
    (isset($_GET['q']) && (
      in_array($_GET['q'], array( 'admin/content/node-settings/rebuild')) ||
      substr($_GET['q'], 0, strlen('system/files')) == 'system/files' ||
      substr($_GET['q'], 0, strlen('batch')) == 'batch' ||
      substr($_GET['q'], 0, strlen('file/ajax')) == 'file/ajax')
    );


Programatically render a block in a twig template I need to render a views block in my page.html.twig template. In D7 I would do this:

<?php
  $block = module_invoke('module_name', 'block_view', 'block_delta');
  print render($block['content']);
?>

In Drupal 8 module_invoke is deprecated and recommended to use this: (I've added the block's name as the second parameter)

Drupal::moduleHandler()->invoke($block, 'views_block__blog_block_1', $args = array());

I tried a few things. First tried to do it in a twig template but I don't know how to call php functions in a twig template, so that didn't turn out too well.

Then I called the function in the preprocess_page() function in the .theme file but before I could get it to work I tried something simpler just to try make a variable work inside the twig template which didn't work either, for example:

In the template_preprocess_page(&$vars) function in the .theme file:

$test = 'Hello World';
$vars['$my_var'] = $test;

I tried to call my_var inside the twig template but it didn't work and I got an error message saying "The site has an error, please contact the administrator"

So, to summarize, here are my questions:

How do I make variables available inside twig templates?
How do I call functions inside twig templates?
Do I render blocks inside the .theme file or twig template?

You're on the wrong track with module_invoke(). That's just a fancy way of calling the {$module_name}_block_view() function.

The fact that it changed doesn't matter, the point is that the block system completely changed in 8.x and is now using plugins and config entities, those functions no longer exist.

You have a few options.

a) Re-use an existing block config entity and view it. Very easy, but requires that configuration to exist, e.g. as a disabled block.

$block = \Drupal\block\Entity\Block::load('your_block_id');
$variables['block_output'] = \Drupal::entityTypeManager()
  ->getViewBuilder('block')
  ->view($block);

b) Create the block plugin instance directly, pass it the configuration (you can find the block plugin id and configuration easily in an exported block config entity). The downside is that you don't get render caching, but if you display it somewhere that is already cached (like a node template), that doesn't really matter.

$variables['block_output'] = \Drupal::service('plugin.manager.block')
  ->createInstance($plugin, $configuration)
  ->build();

c) In case of a view, you can also load the view directly and display it.

d) You can also re-think your approach completely and use block regions or Page Manager (which uses standard block plugins in 8.x).


Creating a profile sub page and filling with Webform data I'm looking to add an extra sub page to a user's profile that will contain the user's answers to a webform that they have previously submitted. I'm having trouble figuring out how to add this subpage.

Any direction appreciated.

If i understand well your question, what you want is a view that show the answer to a webform.

So you can create a view filtred by user, display it in a block and invoke it in the template of your profil page.


How do I enable a REST resource for a custom content type? I've created a bunch of custom content types like "Car Makes" and "Car Models", but I can't seem to figure out how to enable a REST resource for them. In my REST settings page, I see the default content, content type, user, user registration enabled and a lot of disabled types below it. This list doesn't contain any of my custom created types.

If I go to the permissions page, under "RESTful Web Services", I only see "Administer REST resource configuration" and "Access POST on User registration resource". How can I enable "Car Makes" as a REST resource and directly GET/POST with it?

I saw this screenshot, but I don't get anything like this in Drupal 8.4:

In this screenshot, Todo is a custom resource, which requires writing a plugin. Do I have to write a plugin module just to expose each of my custom content types in REST?

I can work directly with the content endpoints, i.e. POST /node/123, but I would like to POST /carmakes, for example.

sorry my english is not very good

If you want to access these types of content separately, you must do the following:
1) download the module restui: https://www.drupal.org/project/restui/releases/8.x-1.x-dev

2) Go to Extend, activate modules, HAL, HTTP Basic Authentication, RESTful Web Services,
Serialization, REST UI.

3) go to the path: / admin / config / services / rest

4) Edit the RESOURCE NAME Content, and mark all the checkboxes.

5) you should perform a test in the browser with the following path: drupal8 / node / 1? _format = json

note: if the information is displayed, it means that the rest server is set correctly.

6) Create a view and select the type of content you want to display and in the "REST EXPORT SETTINGS" section mark the "Provide a REST export" checkbox and in "REST export path" type "car_makes".

This way if you go to the route: "/ drupal8 / en / car_makes" you will see that it will show the information in json format.


Can I add a description for Ubercart catalog categories? I am working on an Ubercart store with several products with a hierarchy of categories.

I'm wondering if it is possible to add a description at the top of the catalog page for each category?

I know that each category is a taxonomy term with which I can set its description, but I can't see any way of displaying that. I've also looked at the option of using a custom block and using a token in the block body but tokens don't seem to be recognised in the block's body.

Any ideas?

Thanks,
Alan

In the catalog view, enable a Global:Text area in the Header, and set the input filter to PHP code.

The following code will print the term description and any associated taxonomy image in the view header.

<?php
$view = views_get_current_view();
$tid = $view->args[0];
$description = "";

if ( is_numeric( $tid ) ) {
  $term = taxonomy_term_load($tid);

  $description = $description . "
";

  if (isset($term->uc_catalog_image['und'][0]['uri'] )) {
     $description = $description . "uc_catalog_image['und'][0]['uri']) . "' class='term-image' /> ";
  }

  if (module_exists('i18n_taxonomy') && i18n_taxonomy_vocabulary_mode($term->vid) == I18N_MODE_LOCALIZE) {
    $description = $description . i18n_string("taxonomy:term:$term->tid:description", $term->description);
  } else {
    $description = $description . $term->description;
  }
  $description = $description . "
";
  print $description;
}
?>


Change path /comment/reply/11#comment-form How I can change path from /comment/reply/11#comment-form to /node/$node->nid/#comment-form in node $links?

I'm guessing this is a Drupal 6 issue:

The Comment module create the links with hook_links(). You can alter those in a custom module using hook_links_alter().


How do clean_class and clean_id work? I am new to Drupal 8 and Twig syntax. I am not able to understand how the clean_class filter works in region|clean_class. What is clean_class? I have added the following code in the page.html.twig file.
{%
  set classes = [
    'region',
    'region-' ~ region|clean_class,
  ]
%}

{{ dump(classes) }}

It prints this.
array (size=2)
  0 => string 'region' (length=6)
  1 => string 'region-' (length=7)

clean_class is a filter which invokes the \Drupal\Component\Utility\Html::getClass() method on the string, which:

  Prepares a string for use as a valid class name.

Basically it removes invalid characters from HTML classes in preparation for rendering. clean_id is the equivalent for HTML IDs.

There are other filters registered by core too, see TwigExtension::getFilters for more details.


Including a large amount of raw data with a module I have a module that demonstrates how to use another module (a graphing library). One of my controllers uses a large dataset to generate one of the example graphs. I currently have this data assigned to a variable in the controller. However, this takes up a large amount of space in the file. If I want to meet Drupal code style guidelines, I would have to break up the array after every [x,y] pair, making it even more difficult to review.

Should I move this data into some sort of include file, and read the text file into my controller? What's the "Drupal Way"?

Your intuition is correct; you should break out your large dataset into some include file. I don't believe there's a strict mention of large datasets in the Drupal coding standards, but isolating out large datasets is good way to isolate concerns (i.e. code-readability vs. dataset referencing).

A good reference example of this would be the Transliteration module. It has a transliteration dataset of include files indexed by unicode byte that's loaded on demand as it needs to transliterate a unicode characters to ASCII.

Your data will obviously be structured to fit your own use case, but given you're probably not the first person to work with large graphic library datasets and PHP, there's probably some general practices to glean from others who've worked on the same problem.


How should I display fields for a content type? I have a complex content type with several user-defined fields. In Drupal 6, I used Contemplate to display the fields in an HTML table. I've just upgraded to Drupal 7 and I'm wondering how to best achieve this now. The Contemplate project seems to suggest that Drupal 7's field display features are the way to go. But how do I create and populate an HTML table with a node's fields in Drupal 7? Do I extend/override a theme?

Update: To clarify, let's say I have several nodes with the same content type history. How do I display each of these nodes in the same specific way, including some of the user-defined fields I've attached to that content type. In addition, I use the pathauto module to give each of these nodes a path like history/<year>.

You can use display suite module to theme your node.

  Display Suite allows you to take full control over how your content is
  displayed using a drag and drop interface. Arrange your nodes, views,
  comments, user data etc. the way you want without having to work your
  way through dozens of template files. A predefined list of layouts (D7
  only) is available for even more drag and drop fun!

If you want to theme your node using code, then you should create template for your node. Check this link for reference.


Error 310 after Drupal installation I've installed a fresh copy of Drupal 7.8 on an FTP server. For some reason, I am unable to run install.php, receiving the error:

  Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many
  redirects.

The files have not been altered in any way.

What could be the problem?

The problem was that I didn't notice that Drupal 7 has compatibility problems while running on IIS and requires a complex (at least for me) configuration procedure to run correctly.
I've reached that conclusion when I tried to install Drupal 6 on the same server, and it ran instantly.


Deleted term shown in exposed filter I'm using exposed simple hierarchal select module for a taxonomy in my exposed filter, i have deleted some terms from the taxonomy but the filter  still showing the deleted terms.

I tried clearing caches and cron and even waited one day with no luck!

Any ideas what is the problem??

❤

I think it may be revisions or taxonomy revisions issue
module documentation  says
This module enables revisions for the taxonomy terms.

The users will have an option to create new revision for a taxonomy term as for
nodes. This means when a taxonomy term is edited in the default form, a new
checkbox is displayed for revision creation. If clicked a textarea will appear
to fill a revision log message.

Also on the taxonomy term edit page a new menu tab appears after the module
installation which will list all of the taxonomy term's revisions and provides


How to list all users in drush? I would like to list information about all users using drush.

There is user-information, but it shows information only about single user.

Are there any other solutions?

For Drupal 8 you could run the following command:

drush uinf $(drush sqlq "SELECT GROUP_CONCAT(name) FROM users_field_data")

The output will loke something like the following:

 User ID       :  1
 User name     :  admin
 User mail     :  info@example.com
 User roles    :  authenticated
                  administrator
 User status   :  1


Remove "Delete" in node/edit via hook_form_alter I need to programmatically remove the Delete button in node edit forms under certain circumstances.

Normally, I'd do this in a hook_form_alter using $form['actions']['delete']['#access'] = FALSE;.

When I view in dpm(), "delete", however, does not have an "#access" key (though 'Submit' and 'Preview' do).  How do I disable 'Delete'

(…and, if you know why it wouldn't provide #access, I'm curious about that too).

You can use hook_node_access instead

e.g:

/**
 * Implements hook_node_access().
 */
function MODULE_node_access($node, $op, $account) {

  if ($op == "delete") {
    // If no user object is supplied, the access check is for the current user.
    if (empty($account)) {
      $account = $GLOBALS['user'];
    }
    // You can add your own condition check here...
    return user_access("delete content", $account) ? NODE_ACCESS_ALLOW : NODE_ACCESS_DENY;
  }

  return NODE_ACCESS_IGNORE;

}


Config import for certain items appears to fail. How do I fix this? After synchronizing configuration from dev to staging, I would expect all changes to be imported and for a message to display, advising "There are no configuration changes to import"
Most changes have been imported but I am left with six items which seemed to have failed import. Or a least do not clear from the list of items for import.
I do not understand why the active configuration appears not be be updated by staged.
As well importing all, I have also attempted to import each item separately, without success.
As well as using the UI have also tried drush cim. Drush confirms that the configuration was imported successfully. But if I run drush cim again, the same 6 files remain.
Why does it appear that the import is failing and what should I do to fix it? Is my active configuration messed up somehow?
A screenshot and some code to illustrate the problem.
Via the UI

Via Drush
    [easable]:sync$ drush cim
    +------------+-----------------------------------------------------+-----------+
    | Collection | Config                                              | Operation |
    +------------+-----------------------------------------------------+-----------+
    |            | block.block.schoolpwa_subtheme_bottommenu           | Update    |
    |            | block.block.schoolpwa_subtheme_mainnavigation       | Update    |
    |            | block.block.mainmenu2                               | Update    |
    |            | block.block.websiteswitcher                         | Update    |
    |            | core.entity_view_display.node.page.default          | Update    |
    |            | media_bulk_upload.media_bulk_config.pdf_bulk_upload | Update    |
    +------------+-----------------------------------------------------+-----------+

     Import the listed configuration changes? (yes/no) [yes]:
     >

     [notice] Synchronized configuration: update block.block.schoolpwa_subtheme_bottommenu.
     [notice] Synchronized configuration: update block.block.schoolpwa_subtheme_mainnavigation.
     [notice] Synchronized configuration: update block.block.mainmenu2.
     [notice] Synchronized configuration: update block.block.websiteswitcher.
     [notice] Synchronized configuration: update core.entity_view_display.node.page.default.
     [notice] Synchronized configuration: update media_bulk_upload.media_bulk_config.pdf_bulk_upload.
     [notice] Finalizing configuration synchronization.
     [success] The configuration was imported successfully.
    [easable]:sync$ drush cim
    +------------+-----------------------------------------------------+-----------+
    | Collection | Config                                              | Operation |
    +------------+-----------------------------------------------------+-----------+
    |            | block.block.schoolpwa_subtheme_bottommenu           | Update    |
    |            | block.block.schoolpwa_subtheme_mainnavigation       | Update    |
    |            | block.block.mainmenu2                               | Update    |
    |            | block.block.websiteswitcher                         | Update    |
    |            | core.entity_view_display.node.page.default          | Update    |
    |            | media_bulk_upload.media_bulk_config.pdf_bulk_upload | Update    |
    +------------+-----------------------------------------------------+-----------+

     Import the listed configuration changes? (yes/no) [yes]:
     >

I've found that this sort of thing is because the config in your sync directory is not quite legitimate. My guess is that this is an issue on your dev and local environments too, not just staging.
I've found that the cause of this issue is usually a result of one of two things:
1. Configuration files were manipulated manually and the configuration in the file isn't possible.
An example, looking at your pastebin, the change for core.entity_view_display.node.page.default.yml is to remove the created field from the list of hidden fields on that display. However, there's no configuration for how the field should be displayed. A field can't be not displayed and also not hidden. To maintain the integrity of the config, the system defaults a field to hidden when it's not in either place.
2. Database updates were run, updates that change configuration, but configuration was not exported on the dev environment after the update.
An example, looking at your pastebin, it looks like some new configuration options (with appropriate default values) were added. It also looks like a module changed from working with true and false to 1 and 0.
To resolve this issue:
First go to your primary development environment. Then get your latest database of record, clear cache, and deploy (database updates, then import your configuration). The result should be the same thing you're seeing on staging, i.e. some configuration will appear to be not fully synced. This is expected (for the reasons described above). Next re-export your configuration, commit, and re-deploy.
To avoid this issue in the future:

Don't manipulate config files directly. If you do, test the configuration locally to make sure you got it right (this includes after resolving merge conflicts in config files).
Always export configuration after running database updates. Sometimes the updates change configuration.