Latest Drupal related questions

Score: 0
frajer avatar
How to get translated menu link entity
cn flag

I have a headless Drupal 9 solution and I'm currently working on i18n of the whole site.

I've managed to do everything except menus. The content translation core module is installed and setup correctly. I have all the menu items translated. This a snippet of the code:

  $parameters = new MenuTreeParameters();
  $parameters->onlyEnabledLinks();

  // Get drupal menu tree.
  $menu_tree = \Drupal::men ...
Score: -5
alhemist avatar
How to install Drupal 9 with Composer?
sh flag

My shared hosting doesn't meet the requirements for installing Drupal 10 as it lacks libmysqlclient and/or MySQLnd and the hosting company refuses to install them.

Currently I run several Drupal 9 websites on that same shared hosting environment so I guess that installing Druapl 9 could work and indeed Drupal 9 should be fine for the particular project I work on.

If I am not mistaken, the following ...

Score: -3
harikris avatar
Custom field values in View for unformatted list
cn flag

I have a view (Values_culture) and I set up the views-view-unformatted--values_culture.html.twig file as a template for that view.

In my case, I have a field - field_link_to_the_kb_section to enter the website URL

I tried the following way to add that value to the <a href> :

<a href="{{row.content['#row']._entity.field_link_to_the_kb_section.value}}" target=""><img src="sites/default/ ...

Score: 1
devr4n avatar
How can I add the hero section image in the View to REST_API?
mt flag
  • Hello im using Drupal 9.5.9 version. How can I add the hero section image in the View to REST_API?

  • I have created an api with Rest_API to fetch data from Views I have created. I have no problem retrieving public data. However, I am getting "null"/"empty"/"id" errors when trying to get the image in the Hero Section in the View. I created two paths to get the images in the view, one to get all the v ...

Score: 0
Bohdan V. avatar
How to run drush cim command for importing all the configurations
pm flag

I cloned the drupal project on my local.

I have a Docker desktop app.

so I run docker-compose up -d on command prompt.

docker-compose.yml:

services:
mariadb:
    image: wodby/mariadb:$MARIADB_TAG
    container_name: "${PROJECT_NAME}_mariadb"
    stop_grace_period: 30s
    environment:
      MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD
      MYSQL_DATABASE: $DB_NAME
      MYSQL_USER: $DB_USER
      MYSQL_PASSWO ...
Score: 1
Evan avatar
Struggling to enable twig debugging using DDEV (built site with Pantheon)
me flag

Update: I've realized that neither my settings nor settings.local files are doing anything. I placed die() and print statements throughout both files, rebuilt cache, and see nothing. I'm stumped.

Update 2: I added the output from ddev drush status at the bottom of the post

Default Drupal 10 site built by Pantheon. The only thing I've done besides setting up these files was update the permission for ...

Score: -2
alhemist avatar
My shared hosting doesn't have up to date libmysqlclient for Drupal 10, what latest core version can work?
sh flag

My shared hosting provider doesn't have up-to-date libmysqlclient so I can't finish the Drupal 10 installation.

The libmysqlclient driver version 3.1.21 is less than the minimum required version. Upgrade to libmysqlclient version 5.5.3 or up, or alternatively switch mysql drivers to MySQLnd version 5.0.9 or up.

As this is a shared hosting, I can't control the software to fix this.

Is there any wor ...

Score: -1
thiokol avatar
Webform custom element Ajax callback
cn flag

I have already developed a field widget that queries an API based on a value in a textfield and i want to now create a Webform element to do the same thing for poeple using Webform.

Because i need my element to have a textfield, a button to trigger the API request, and an HTML area to display the result, I am presuming i need to extend my class from WebformCompositeBase.

If I write the callback in t ...

Score: 0
Clean logout from REST service
lc flag

Considering that none of the usual suggestions really work...

The standard user/logout provided by Drupal has CSRF issues, as numerous questions describe, it shows a "'csrf_token' URL query argument is invalid" even if the appropriate token is provided (going deep into the core shows th ...

Score: -4
alhemist avatar
How to edit blocks with the Layout Builder core module?
sh flag

In Drupal 9 at least, it is possible to edit only nodes with Layout Builder core module, but I have no idea about latest Drupal 10 versions or even Drupal 11 betas or what's planned for the near future.

How to edit blocks with the Layout Builder core module?

Score: 0
rroblik avatar
Webform composite sub-element altering : how to do?
za flag

I'm currently developing a Webform based module (D9). One functionality I'm working on is around form "interdependency" : for a given form, some fields can be pre-filled from another webform submission of the same user. The hard part is tat I want to prevent end-user editing the prefilled data; I'm think about / testing multiples options :

  1. Simply add #disabled property to each prefilled fields : not ...
Score: -1
Hartmut Theis avatar
better_exposed_filter used with slick. The path have taxonomy id, but I need t name
om flag

I need to have a path, with replace the taxonomy id, with the t name. In better_exposed_filters in slick.

Score: -1
Jannes Althoff avatar
Add Semester Timeformat
tc flag

I'm trying to add a timeformat to show in which academic semester the date is in, we have the Winter Semester from 1st of October to the last day of march, the rest of the year is summer semester. It should be shown like this:

WiSe 22/23 or SoSe 21 or SoSe 20

I've tried adding a new module which overrides the time.formatter service but it doesn't work at produces error pages. Here is my code:

semester. ...

Score: -1
jojan avatar
How to configure language code for the international pages
iq flag

Pages that are generated for each language code when enabling internationalization, has "en" - default language as its language code in the HTML Tag.

How to configure the internationalization modules, so that the page for the language would have its corresponding language set in the html tag.

for ex: www.example.com/fr should have the html tag with <html lang="fr">. Currently it is just "en" which  ...

Score: 0
thiokol avatar
When providing default settings for elements in a field widget, what is the syntax for multiple value checkboxes?
cn flag

I have a field widget with three different settings, two of them are just string values but the third is multiple checkboxes.

This page describes how to set default settings, simple enough for integer or string and single value fields, but I'm not sure how to set default values for some of the checkboxes in the multiple checkbox element.

Below is the function where i need to set some of the values in  ...

Score: 1
micbay avatar
Custom Menu Template not Rendering Menu Links
ua flag

I'm building a custom module that modifies the main theme (barrio bootstrap in this case) to establish a landing page. In that process, it hides blocks in some regions and takes over rendering the main menu.

When I try to replace the default menu template used by the primary menu, menu--main.html.twig with my own template mymenu--main.html.twig which is exactly the same TWIG code (other than debuggin ...

Score: -2
alhemist avatar
When installing, I get the "Undefined constant PDO::MYSQL_ATTR_SSL_CA in Drush\Sql\SqlMysql->creds()" error
sh flag

I am trying to install Drupal 10 on a CentOS LAMP stack.

PHP version: 8.1
MariaDB version: 10.5.21-MariaDB-cll-lve-log

I did that:

cd WEB_APPLICATION_ROOT_DIR
composer create-project drupal/recommended-project WEB_APPLICATION_DIR_NAME
cd WEB_APPLICATION_DIR_NAME
composer require drush/drush

Then, I did this: vendor/bin/drush site:install and then I got this:

Undefined constant PDO::MYSQL_ATTR_SSL_C ...

Score: 0
Ben Alan avatar
['#attributes']['class'] variable is not being rendered on the page
do flag

I'm working on an old Drupal 7 site.

In the template file paragraphs-item--user-block-paragraph.tpl.php the content is being rendered, but the class is not added to the element.

Here is the code:

$content['#attributes']['class'][] = 'my-class';
print "<script>alert('".$content['#attributes']['class'][0]."');</script>"; // confirmed variable is set to my-class
print render($content); // confir ...
Score: 1
Kevin avatar
Get the node that a block is placed on without a route parameter?
in flag

Is there a way to devise from a block instance that was placed in Layout Builder how to load up and extract what node (or entity) it was placed into?

We are indexing pages into Solr and some inline components that load the node from the current route for data are failing because Search API is loading the entities to index and not crawling paths.

Score: 0
jaykobo avatar
JsonAPI does not work with "and" and "or" group
hn flag

A website search accesses http://api.example.com/de/jsonapi/node/product. The current fetch request looks like this.

http://api.example.com/de/jsonapi/node/product
?filter[or-group][group][conjunction]=OR
&filter[title-filter][condition][path]=title
&filter[title-filter][condition][operator]=CONTAINS
&filter[title-filter][condition][value]=${query}
&filter[title-filter][condition][memberOf ...
Score: 0
user111115 avatar
How to access Block Layout data and add to render array for rendering in a Twig template?
gl flag

I'm a relatively new Drupal developer, and this ticket for my job has been proving extremely difficult for me to figure out through research.

I want to access the block layout data (/admin/structure/block/manage/block_name_example?destination=/admin/structure/block) for a custom block that we're using for our hero page banner. We're using the Block Scheduler plugin, which provides an Expiry tab t ...

Score: 0
Renzo Emiliano Carletti avatar
How can I work with Twig when using the Display Suite module?
va flag

I am working with Commerce 2 and Display suite, i want to add a field to the presentation that when a product has a boolean field valued to true, do not display a field and display other with twig. Maybe this way im more clear: field in product: Variation and a boolean flag if flag = true dont show the variation "Add to cart" but "Coming soon"

The problem i want to solve is that when i have no st ...

Score: 1
Rene avatar
Why does this code not load webform submissions?
cn flag

I’m trying to load all submissions from a specific webform, and for some reason it always returns no results (even though I know it has results from the UI). I found this bit of code that I adapted for my needs:

$webform = \Drupal\webform\Entity\Webform::load($webform_id);

if ($webform->hasSubmissions()) {
  $query = \Drupal::entityQuery('webform_submission')
    ->condition('webform_id',   ...
Score: 0
harikris avatar
Custom view page for unformatted list
cn flag

I have a view (Values_culture) and I set up the views-view-unformatted--values_culture.html.twig file as template for that view. In my case, the template is not detected, or the template does not print values.

In the attached screen the format type is Grid. Please ignore that.

How can I properly customize the view templates and print each item from the specific content type mentioned in the view?

Score: 0
DevNooby avatar
TFA Session expired when user login
nz flag

not sure if anyone faces this issue, when I tried to login with the authentication. It shows TFA session has expired. But the user account was logged in. Screenshot attached, I tried to drupal set message instead of dpm(), notice that the expires property was gone.

Screenshot 1 - authentication verification Screenshot 1 - authentication verification

Screenshot 2 - TFA session expired message but the user was logged in Screenshot 2 - TFA session expired message but the user was logged in

My Drupal version: 7. ...

Score: 0
Prof avatar
Webform Option Limit: How to change the number to subtract from the limit
ar flag

I've used the option limit handler before without problems, but now I have a new scenario. I have a limit of 200 seats and each user can reserve up to a maximum of 5 seats. The user chooses the number of seats from the element seats_number(of type number).

Example: 200 seat limit, user selects 4 seats, new limit is 200-4=196.

What should I change in the settings handlers?

Thank you so much for help me. ...

Score: 0
alhemist avatar
How to clone a content type and then convert nodes between the original and any clone it has?
sh flag

I have a Drupal 9 core without any contrib modules.

I want to clone content type A to at least one other content type such as content type B, C, D or whatever and after doing so convert at least one node from content type A to one of the new ones.
Any cloned content type should have a different name in any possible database context such as human-readable name, machine name, etc. to prevent possible ...

Score: -2
unixmiah avatar
How to get previous clicked on link and previous page url in Drupal from a TWIG
cn flag

Ive tried several ways of getting the previous page url and what link they clicked on within a twig file. How do you accomplish this from a twig in Drupal9.

I have tried the following JS in twig but its not rendering.

<script type="text/javascript">
    document.write(document.referrer);
</script>

I had solved it by using JQuery. It's for building a mailto: string that auto populated an email ...

Score: 0
Ramalingam Perumal avatar
How to display taxonomy field value in paragraph twig file?
mx flag

How to display role taxonomy field value in paragraph--user-category.html.twig file? Field structure: field_role-> role taxonomy field.

I can print by {{ content.field_role | raw }} But I need to display value text only.

I tried below the code and not working. Please advise. {{ paragraph.field_role.entity.value }}

Printed value: {{ dump(paragraph.field_role) }}

enter image description here

Score: -4
user111108 avatar
Referencing a paragraph-type via code
tf flag

I'm new to Drupal so the following may not be accurate.

I want to reference a paragraph-type from an Entity reference revisions field created in a content type using a hook_form_alter and I can't find the way to do so.

I've created a content type using the UI and also a new Entity reference revisions field inside it without selecting a paragraph. I need to select it by code (and even more than just  ...

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.