Latest Drupal related questions

Score: -3
How to get url path of media file (pdf) in node twig file?
cn flag

I Uploaded a pdf file using media library. Now i want to render file link in twig file. please help in this

Score: 0
Adjust total price in commerce checkout
in flag

I have a store setup with 2 products. Public and private tours. Public tours are 10 for each unit.

Private tours on the other hand are only meant to collect a deposit. I need the total to be $50 no matter the quantity selected and the rest is paid on site.

I tried creating a custom PromotionOffer as seen below. I can create the promotion but it doesn't seem to apply while in the cart/checkout. I eve ...

Score: 0
Matt avatar
Creating an instance of custom entity with entity reference field breaks entity collection page
cn flag

I created two custom entities, entity_one and entity_two. entity_one has a entity reference field that allows you to select unlimited instances of entity_twos. The edit form for entity_one seems to work fine. The field exists and properly auto populates with entity_twos. However as soon as I submit and create an entity_one the list page for entity_ones gives me the error.

Error: Call to a member functio ...

Score: 0
Decoy_Octopus_ avatar
How to group some exposed filters in a collapsible block
cn flag

I have a view with several exposed filters
The theme is based on bootstrap, so I'm looking for a way to group some of them within a collapsible or accordion block (Bootstrap example)

I'd like to avoid installing an extra module if possible.
Drupal version : 8 / 9

Thank you

Score: 0
Ex0r avatar
Custom Views Field Plugin
cn flag

I am creating a custom views field plugin, and I am having a huge amount of notices in the dblog that I cannot trace.

It's a simple views field plugin that just renders some content into a custom "non-db" field on the view.

Issue #1, is that in the view, the field is listed as just ':' (The field group and field name are not being displayed on the view).

Secondly, I am receiving these notices in the db ...

Score: 0
user3099225 avatar
Add SRI hash to existing CDN links
cn flag

I have a Drupal site where there are few CDN links. Iwas thinking of adding SRI hashes to those links.

How can I do that?

Every solution I tried requires to add a custom module, but I don't know how these things work.

Somehow, I managed to create a custom module which creates a Hello page. I just followed a tutorial. Can I add hashes in it?

name: SRI Hash
type: module
description: 'SRI  ...
Score: 0
Andrew Magill avatar
Change language code for existing languages
uy flag

My site has two existing languages with several pages of existing content. The language code for both are incorrect. I need to change the language code for English from en-gb to en-ca. Drupal UI doesn't seem to allow that (see below).

Drupal edit language

How can I change the language code for an existing language ?

Score: 0
How to retrieve the geographical coordinates of a photo?
cn flag

I have the Geolacation and Media module.

I publish nodes with photos that contain geographic coordinates in the EXIF.

How to retrieve the geographical coordinates of a photo?

I want to display under each photo of my node, a "Go there" button to go to the exact place where the photo was taken. When the user clicks on the button, the device must offer to open the coordinates in a google maps for example  ...

Score: 0
iain-g avatar
Filter date/time from date-range picker
ar flag

I have a content type with a Date-range field; the default output in the view gives me, for example, Saturday, June 4, 2022 - 16:30 - Saturday, June 4, 2022 - 19:00.

What I would like to show is Saturday, June 4, 2022, 4.30-7.00pm.

I figured out that, in View > Fields I should rewrite results and add a standard Twig filter like {{ field_event_date_time|date('M d, Y') }}, but I get no output from  ...

Score: -1
R Potharaju avatar
Remove actions (edit button) with hook_views_pre_render()
cn flag

I am trying to hide/remove the edit button on a view, for few records using the following code.

function member_management_views_pre_render(ViewExecutable $view) {
  if ($view->id() == 'my_view_id') {
    if (mycondition) {
      foreach($view->field as $key => $value) {
        // $value->_entity->operations->setValue() = 0;
        // operations->field->handlers->displayh ...
Score: 0
Hefi avatar
How do i list all child terms that share the same parent term? But on "child term" page?
et flag

Let's say I have the following taxonomy (a 3-level hierarchy).

  • Acura
    • Integra
      • Hatchback 1991
      • Hatchback 1995
      • Hatchback 2000

If I am on the last term of this hierarchy, for example Hatchback 1991, how do I display all other specific models that belong to its parent (Hatchback 1995 and Hatchback 2000)?

Probably Taxonomy Term Siblings.

Score: 0
John Machado avatar
Media Library results filtered by user
in flag

I am working on a project that will be using 100's users and potentially thousands of users. The users will be required to upload at the very least 5 images and possibly some PDF files.

Created a content type, and added some Media fields, which works perfect for this project. The user files uploaded will be all public but the issue is that when the user goes to browse for their files all files fr ...

Score: 1
Link in URL field to Media File
in flag

Before the Update to the latest DruPal 8, we were able to link to public://foo/bar.pdf to a file which was in /sites/default/files/. No the public:// prefix does not work anymore in the URL input field.

We are still able to enter the full link, but this might have the downside that it needs to be updated when the file name changes.


We also tried /media/1337 but it shows a new page with the download ...

Score: 1
Mathew Dony avatar
Use path alias as contextual filter
cn flag

I have nodes in Drupal for News Articles that generates this automatic URL alias.


I also have a view for News nodes.


This is the data.


The problem is that I can't use Content: Path (url) or Content: Path (Path) as contextual filter.

sync/newslist/1234, where 1234 is node ID, works. I would like to pass the path or the URL to the contextual filter, so that sync/newslist/world-first-chart-alert ...

Score: 0
Rubix05 avatar
Render a fulltext exposed search bar separate from the rest of the filters
cn flag

I would like to render my exposed fulltext search bar in a separate location from the rest of my search filters. My other exposed search filters are things like display number, sort order, etc... I am also using facets.

My current problem is that I need to render the search bar in a whole separate region from the rest of my exposed filters. My current solution is to render {{ exposed }} twice but then u ...

Score: -2
Frédéric Hébert avatar
Conditional JavaScript based on URL value
us flag

I have a single form I need to insert twice in two pages by template. I have to put different values in the list selection field in the active page by the URL.

With a JavaScript field, I want to put the URL value in a conditional field.

How can I achieve this?

Score: 1
PROMES avatar
routing for dynamic block for custom entity
co flag

For a custom entity I have created several dynamic blocks. But the blocks are not displayed. They are placed in admin/structure/block. Below is an example of block 1.


  path: '/collection/{myentity}'
    _title: 'Stuff collection'
    _permission: 'access content'
    myentity: \d+
        typ ...
Score: 0
João Mateus avatar
check if a page has been redirected and then add a class to a certain div
ms flag

Im using the redirect module to redirect /page/scheduling to /page.

I need to check if the user arrived to a certain page by this redirect.

by checking this i will then add a class to a certain div.

How can I accomplish this?

Score: 0
Debugging anonymous session regarding cookie specific page caching
cn flag

Have been following this guide to make caching depend on the value of a specific cookie:

However, it does not seem to work for anonymous users.

Debugging (xdebug) within both



is possible when logged in as admin and running "cache rebuild"  ...

Score: 0
khaled alsamman avatar
display paragraph field in a view
cn flag

I am trying to display my paragraph bundle fields in a view. is that possible?

I have a bundle that contains 2 fields with no input limit. I want to display one of the fields in a view. I added a relationship of type Paragraph to my view and then added the "field_Description" to the view fields. Unfortunately it didn't work.

enter image description here

view img

In more detail, I have a bundle A in bundle B, I want to target bundle  ...

Score: 0
Bass-Ninja avatar
Programmatically create result row in views
ru flag

I have created a bunch of content types. Since I am using Drupal only for displaying results fetched from another service I was wondering if there is a way to display results in a view without actually having objects in the database?

For example, I get data from a certain endpoint and I want to display them in a table view. Is there a way to achieve that or would another approach be recommended?

Score: -4
Basic Page - anchor link with id
es flag

I'm trying to create an anchor link on a basic page back to the previous NON basic page to where the user came from.

I.e. <a class="btn" href="/dashboard">Back>/a> obviously works.

BUT <a class="btn" href="/startups/{{|startup_id}}/videos">Back</a> doesn't.

Any ideas as to how to resolve this would be greatly appreciated.

Score: 0
Free Radical avatar
How can I get a multivalue field correctly inserted?
kz flag

I have a custom module that creates a field type. It is a plain text field abd I've added it to a content type using the Drupal UI. The cardinality of this field is "Unlimited".

This is how I create the field in code:

class MyItem extends FieldItemBase {

   * {@inheritdoc}
  public static function schema(FieldStorageDefinitionInterface $field_definition) {
    return [
      'columns ...
Score: -3
Prashant Chauhan avatar
How can we use \Drupal class inside Settings.php
cn flag

How can we use \Drupal class inside the Settings.php file so that we can load configurations etc? For example:

Score: 0
Meni avatar
Location of product attributes
tr flag

Probably field_data_field_attributes holds attributes data in SQL.

How can I relate this data with a specific product?

Score: 0
How do I print an exposed filter block in a template file?
id flag

I have a view with an exposed taxonomy filter. I configured it to be displayed as a separate block so that I can print it another twig template. I tried this.

 * Implements hook_preprocess_block() for block.html.twig.
 function themename_preprocess_block(array &$variables) {
   $variables['featured'] = views_embed_view('view_name', 'contextual_filter_block_machine_name');

Then I used

Score: 0
Set no cache when generating dynamic local action via derivatives
vn flag

I'm trying to generate a dynamic local action via a derivative. The derivative works and returns a link generated dynamically but the cache seems to maintain its value.

As per this Drupal core change log, I understood I could set cache parameters on the derivative, which I tried but in vain so far - I'm not very familiar with these concepts yet so appreciate any guidance on how to prevent $gid from be ...

Score: -1
Orlando avatar
How to group with charts module - Google library
si flag

I use views to extract data from a webform and I want to graph articles vs quantities (600), I use the charts module with the google library (CDN), but something that should be extremely simple I can't get it to group the articles, there is not much to configure in the charts module. Does anyone know how to do it? enter image description here

Score: 0
How do I test a CKEditor 5 text format field with Behat/Mink?
cn flag

Drupal 10 is switching from CKEditor 4 to 5.

So, I installed the experimental CKEditor 5 module and am attempting to update my Behat tests to use CKEditor 5.

I am using an @javascript test in Behat on CircleCI to check my Drupal 8 site.

The standard I fill in "my field" with "value" step fails for fields that use CKEditor. For example, for a long text field with the label Question, if I add a step:

Score: 1
Rifas Ali avatar
How to update taxonomy field with array of terms?
fr flag

I am having a body like this

    "userid": 435,

Where userid is the drupal user id. And I need to update field field_user_territory which is a taxonomy field. I do not want earlier territories to go instead I need to update with 2 more territories.

This is the code I tried.

foreach ($territories_id as $territory_id) {

            $user = \Drupal\user\E ...

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.