Latest Drupal related questions

Score: 0
Tomáš Bažant avatar
Shared sites/all/libraries/ directory is not recognized by contrib modules
de flag

I'm trying to put the colorbox javascript library to the shared sites/all/libraries directory but it is not recognized by the colorbox module. The same seems to go for the jquery.cycle library. I just copied the libraries directory from sites/nias.cz/libraries` to the shared one. The final example path is

sites/all/libraries/colorbox/jquery.colorbox.js
Score: 2
How to do dependency injection for ConstraintValidator?
cn flag

After upgrading to Drupal 10, running the coding standards check suggested that I could use DI in my validation constraints.

For example, this simple one:

<?php

declare(strict_types=1);

namespace Drupal\my_module\Plugin\Validation\Constraint;

use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;

/** ...
Score: 0
Patoshi パトシ avatar
How can I find out if all my contrib modules are compatible with the latest core version?
kr flag

I have quite a number of Drupal modules on my Drupal 9 website and I want to update my Drupal core to the latest, but I'm not sure if this would break the entire site if one of the modules isn't compatible with the latest core version.

I can go to each module page individually to check, but is there a quick command in the CLI to find out? drush pm-list doesn't really seem to help.

Score: 0
Jean Vieille avatar
How to prevent modal boxes for Drupal 7 edit forms
cn flag

I am very annoyed by the modal boxes showing up for most edit functions in Drupal. For example, when editing a php field code, only a few lines are displayed, I must copy the content in an other editor and back. How can we prevent this "smart" feature to get back to the old fashion editing?

Score: 1
techenzie avatar
Why is my translated content loaded on a 'raw' node address even when there is an alias given? (Multilingual Site)
lc flag

I have two languages (English and Spanish) in my Drupal site. The default language (English) content has already been created and now I need to translate the content (articles/pages/blocks) into Spanish for the respective entities. Let's say there is an About Us page which has an alias as '/about-us'. Now, when I go ahead and translate this to Spanish (enabling all the language modules and enabling conte ...

Score: 1
Matt Pugh avatar
How can I find all the nodes that use a hierarchical vocabulary taxonomy term and reference a child term but not its parent term
ps flag

I am using Drupal 7. I have a content type "Public Resource" that uses a hierarchical vocabulary called "Resource Topics" that has up to 3 levels (parent->child->child of child).

We have about 1000 Public Resources that are created. It has come to my attention that when our staff has been creating Public Resources nodes and choosing the "Resource Topics" terms if they choose a child they d ...

Score: 4
Martin Joergensen avatar
How can I dynamically switch between two databases for ALL queries?
cn flag

I need to copy some entities from one Drupal 9 database to different Drupal 9 database. I have searched and looked high and low, but none of the examples I have found work anywhere. I found no help on drupal.org, so I'm reaching out here.

Both databases are full Drupal 9 databases; they are almost identical, but some nodes and users are present in one, which I need to copy to the other.

In Drupal 7  ...

Score: 0
Ivan Leon Yam avatar
Where can i find the path/URL of a module after installing it?
ge flag

I just installed two modules on a Drupal 9 site: https://www.drupal.org/project/simple_forum and https://www.drupal.org/project/answers.

I want to get the URL where all posts/questions are listed and use it in a menu, but I cannot find where those are. The only thing I found is the URL for creating new posts and questions.

Score: 0
lee avatar
Hide/remove "Last" label/icon in views pager
cn flag
lee

I don't want my user to click the "Last" label on the views pager, but I can't find a way to remove this "Last" label even I leave the "Last page link text" field empty, I don't want to use the mini pager, so in the full pager, how can we remove the "Last" label/icon ? Thanks

Score: 0
DStrider avatar
Where to implement CSS previously implemented by CSS_editor now deprecated
in flag

Theme css in useViews with tables have a Flag that changes from Pending to Complete when the row is completed. The background of the entire row changes color depending upon the word.

Working css_editor code (theme settings custom CSS enabled):

tr.pending td { color: red; }
tr.Complete td { background-color: #66ff99; }

After uninstalling the deprecated css_editor module, I have no idea where to put the above code. Al ...

Score: 1
Akbar Bakhshi avatar
Problem with Adding new fields with Ajax call to a custom form
vu flag

I have a simple form where I am trying to add a couple of fields to it when the user clicks a button using an ajax callback. Here is what I have:

public function buildForm($form, FormStateInterface $form_state)
  {

    $form['add_fields'] = [
      '#type' => 'button',
      '#value' => 'Add new fields',
      '#ajax' => [
        'callback' => [$this, 'ajax_callback'],
        'disabl ...
Score: 2
EvilArgest avatar
How to get webform url object, if I have webform machine name and webform path
uz flag

I have webform path and webform machine name, how can I get url object of this webform?

Score: 2
Christopher Lambert avatar
Testing equality of two variables - one is entity reference
mk flag

I'm new to Drupal theming and twig, so apologies for asking a simple question, but it's driving me crazy. I can't find the solution.

I'm trying to test the equality of field from a Custom content type - field_program_level - that's an Entity reference type. field_program_level has two possible values : G and UG.

I've tried everything I know and my code doesn't work. My current code is:

{% set yy = conte ...
Score: 1
Going from 9.5.1 to 10.0.1 keep getting same error message regarding Twig
cn flag

I've tried going to 10.0.1 using Composer and then tried updating to 10.0.1 and get the same error message....

The website encountered an unexpected error. Please try again later.

Error: Class "Twig_Extension" not found in include() (line 12 of /home/customer/www/wiulibraries.org/public_html/video1/modules/entity_embed/src/Twig/EntityEmbedTwigExtension.php).

include() (Line: 571) Composer\Autoload\incl ...

Score: 1
Quetzcodecoatl avatar
Trying to insert a line break inside a table header array
tw flag

So I'm programming a module in Drupal that contains several custom forms, one of which also has a table.

One section of the code of the table mentioned above looks like this:

$form['completion_' . $week] = array(
   '#type' => 'table',
   '#title' => 'Completion Week',
   '#header' => array(' ', 'Header 1', 'Header 2', 'Header 3'),             
);

The forms and the tables themselves work correct ...

Score: 1
amol avatar
How to retrieve all taxonomy term using json api
th flag

I want to retrieve all taxonomy term name using json api.

I have tried:

http://local-tes/jsonapi/taxonomy_term/specialties

but its only return 50 values, I want to fetch all taxonomy terms values.

Score: 0
Rob Holmes avatar
Retrieve the name of the menu that a menu link is in
cn flag

Given the code below i can get the menu link of the current page. What id like to know is how to determine what menu that link resides in.

  $current_path = \Drupal::service('path.current')->getPath();
      $params = Url::fromUri("internal:" . $current_path)->getRouteParameters();
      $entity_type = key($params);
      $menu_link_manager = \Drupal::service('plugin.manager.menu.link');
     ...
Score: 0
How can I to make the CKEditor 5 balloon editor inline editor work?
cn flag

Drupal 10 comes with CKEditor 5, which allows for inline editing, including a balloon editor.

It doesn't seem there is a setting in Drupal 10 for that yet. How can I activate the balloon editor?

Score: 0
tonytheferg avatar
How to display a shipment method as an order item row in csv or table view
cn flag

I am creating a csv order view with a relationship to pull in referenced order items, and it gives a row for each order item as expected :

Order 1, item 1 title, item price,
Order 1, item 2 title, item price,
Order 2, item 1 title, item price,
Order 2, item 2 title, item price,
Order 2, item 3 title, item price,

I would also like to add only one extra row for every unique order that contains the refer ...

Score: 1
How can I set a Rules action to unpublish a comment when a specific flag is set?
pe flag

I'm attempting to create a flag that will unpublish a comment when the flag is set on that comment.

I'm attempting to use Rules, Flag, and Rules Flag to achieve this.

The comment type is default 'comment' I'm calling the flag 'unpublish_publish' The flag is global

Where I get stuck is on the Actions portion of the rule creation. For the trigger event I have: After flagging a comment of type Default com ...

Score: 1
Juan Carlos Osorio avatar
How do I change the "secure" and "httpOnly" attributes of the cookies provided by the EU Cookie Compliance module?
ec flag

I am using the eu cookie compliance module in Drupal 9 and I need to change the "secure" and "httpOnly" values of the cookies, as I am getting a vulnerability error "CWE-614: Sensitive Cookie in HTTPS Session Without 'Secure' Attribute". I have tested from the settings.php using the following code:

ini_set('session.cookie_secure', 1);

However it didn't work, I also tried with some modules but it didn' ...

Score: 0
How to change media image private to media image public, just for a specific filemime, and update the url?
eg flag

Using Drupal 9.4. The Media File system is set to Private The Drupal default media type Image is set to private. It now contains hundreds of images. We want to switch only this media type from private to public. We want to keep PDF files private, these are in the Drupal default media type Document.

My process is this. Copy all the images from the private folder over to the public folder, keeping  ...

Score: 0
Boussetta moez avatar
Custom sorting using a MySQL statement instead of simple field
jp flag

I'm using a view to list products from db index. I want to implement a custom sorting (my goal is to sort by current taxonomy term page, products having a specific node field field_MY_FIELD_NAME = CURRENT_TID, showing up first)

First using hook_views_data_alter I override the sort of an indexed field that I have chosen as a sort criteria inside the view

function MODULE_views_data_alter(array &$data) ...
Score: 0
Michiel avatar
How to render fields with ->view() in a render array table?
jo flag

I am building a table in my build function of a block and want to render formatted field values or entities with the ->view(); method in a cell of my table.

As described here: https://www.computerminds.co.uk/articles/rendering-drupal-9-fields-right-way

I have a value like this:

$cell_value = $entity->field_name->view();

It outputs a render array. But when I put it in the table like this. Noth ...

Score: 1
ice70 avatar
RewriteBase and Administer software updates permission not working
cn flag

User 1 is unable to run /update.php, with the error: In order to run update.php you need to either have "Administer software updates" permission or have set $settings['update_free_access'] in your settings.php.

If I set $settings['update_free_access'] to true, I can run the update.

I get this even on a default installation [Drupal 9.4.8]. It looks like it is down to the Apache configuration:

DocumentRo ...

Score: 0
Ahmed Ashraf avatar
How to access block contents in run within hook_form_alter?
fr flag

I am using Drupal 9 and I need to get the block content within hook_form_alter implementation, I tried these lines:

$bid = 'consumerorganizationselection';
$block = \Drupal::entityTypeManager()->getStorage('block')->load($bid);

but this ended up returning the block configuration not the content. enter image description here

Is there any approach to get that block content in Drupal 9?

I tried the solution of the duplicate que ...

Score: 1
Avoid group of revisions history view duplication
us flag

My taxonomy View lists all revisions grouping by different columns, by adding revision fields for each value, and get the filter "published" removed. The only filter is: city name (not null).

For example:

| London | Roma |

| value 1 | value 1 |

| value 2 | value 2 |

As you can tell, people can add different city data by making new revision of the taxonomy. It wo ...

Score: 0
How to make an entity reference field only load a rendered entity, when clicking on it? (ajax load on click)
cn flag

I want to mimic a zettelkasten system, by starting in a very simple way:

An entity of type 'Note' includes a body and an entity reference field, that can reference another note (of the same entity type) as fully rendered embedded entity.

I like to make the viewed note only display the entity reference field as link, but when I click on it the referenced link must turn into a fully rendered entity. ...

Score: 0
Tomáš Bažant avatar
How do I configure sites.php for a multi-site with fixed IP and subdir?
de flag

I have just installed clean minimal Drupal 9, created a sites/sites.php with the following line

$sites['10.0.0.133.drupal.web.foo-bar'] = 'foo-bar.com';

and the following subdir sites/foo-bar.com with settings.php that includes the correct database settings. After entering http://10.0.0.133/drupal/web/foo-bar into the browser, the default site respond which means the site alias has not been recogni ...

Score: 0
How to limit the depth of embedded referenced entities
cn flag

Using Drupal 9 or 10 Using a node type Page with one entity reference field, which is displayed as rendered entity, displaying the same Page content type.

When viewing a page, how do I prevent the page from having endless nested pages in it, leading to infinite loading? I like to limit the nesting to 4 levels deep.

The Stunning Power of Questions

Much of an executive’s workday is spent asking others for information—requesting status updates from a team leader, for example, or questioning a counterpart in a tense negotiation. Yet unlike professionals such as litigators, journalists, and doctors, who are taught how to ask questions as an essential part of their training, few executives think of questioning as a skill that can be honed—or consider how their own answers to questions could make conversations more productive.

That’s a missed opportunity. Questioning is a uniquely powerful tool for unlocking value in organizations: It spurs learning and the exchange of ideas, it fuels innovation and performance improvement, it builds rapport and trust among team members. And it can mitigate business risk by uncovering unforeseen pitfalls and hazards.

For some people, questioning comes easily. Their natural inquisitiveness, emotional intelligence, and ability to read people put the ideal question on the tip of their tongue. But most of us don’t ask enough questions, nor do we pose our inquiries in an optimal way.

The good news is that by asking questions, we naturally improve our emotional intelligence, which in turn makes us better questioners—a virtuous cycle. In this article, we draw on insights from behavioral science research to explore how the way we frame questions and choose to answer our counterparts can influence the outcome of conversations. We offer guidance for choosing the best type, tone, sequence, and framing of questions and for deciding what and how much information to share to reap the most benefit from our interactions, not just for ourselves but for our organizations.