Latest Drupal related questions

Score: 0
somo avatar
How to conclude from Upgrade Status module if my website is ready to be upgraded from 9 to 10 in command line?
mp flag

How to conclude from Upgrade Status module if my website is ready to be upgraded from 9 to 10 in command line?

From the documentation I understand that I should run either of these commands:

  • vendor/bin/drush upgrade_status:analyze (us-a) --all
  • vendor/bin/drush upgrade_status:checkstyle (us-cs) --all

Is that correct or at least, Would you use more particular arguments?

My question is general and p ...

Score: 0
Krishna Mohan avatar
How to get path/URL without language prefix (for multilingual site)
sh flag

I have written a code to get the parameters (node_id, taxonomy_id) from the URL using the following code.

Sample URL: /foo/bar/[nid]\/[tid]

$path = \Drupal::request()->getpathInfo();
$arg = explode('/', $path);
$node_id = $arg[3]; //gives [nid]
$term_id = $arg[4]; // gives [tid]

This works, but when I switch to other language (say spanish), the URL becomes

/es/foo/bar/[nid]/[tid]

So obviously the co ...

Score: 0
somo avatar
Is there any danger in uninstalling Redirect module?
mp flag

Drupal 9.5.3 with no core customizations and very few contrib modules:

  • Redirect
  • Asset Injector
  • Token

All nodes in this website have alternative aliases such as example.com/my-first-node instead of example.com/node/1.

When creating the website nearly a year and a half ago I have also installed Redirect. I don't recall why exactly. But I know for certain, that I didn't do anything with it "manually ...

Score: 0
Converting Unix Timestamp to Time Ago Format in twig
cn flag

I'm working on a project where I need to convert a Unix timestamp to a "time ago" format (e.g., "2 hours ago," "3 days ago," etc.) using Twig. I've tried using the {{ created|date('M Y, D') }} function, but it only provides a regular date and time format.

Can someone please guide me on how to modify the code to achieve the desired "time ago" format? I want to display the elapsed time since the timestamp ...

Score: 0
Juan Carlos Osorio avatar
how to add the "alt" attribute to a "managed_file" type image field
kn flag

I have a custom form in drupal 9 where I am creating a managed_file type field to upload an image:

$form['footer']['logo'] = array(
  '#title' => 'Logo',
  '#type' => 'managed_file',
  '#upload_location' => 'public://',
  '#upload_validators' => [
    'file_validate_extensions' => ['png jpg jpeg'],
  ],
  '#description' => t('The valid formats are png, jpg, jpeg'),
  '#default_val ...
Score: 0
mullzk avatar
Set new paragraphs to unpublished by Default
ec flag

Is there a way, to set new Paragraphs to unpublished per Default?

For Content Types, I can set that new Nodes are not published per Default (Structure -> Content types -> Tab 'Edit' -> Widget 'Publishing options' -> Group 'Default options'. Is there a way to enable the same behaviour for paragraphs?

I use Drupal 9.5.9 and Paragraph 8.x-1.15

If I add a new paragraph to a page, I don't want i ...

Score: 0
Delford Chaffin avatar
Attach JavaScript to page with Commerce Events
gg flag

I'm using hook_page_attachments_alter in Drupal 9 to add some JavaScript dataLayer calls to certain routes, but I also need to add some to certain cart events (i.e. add item to cart).

I've written a CartEventSubscriber that listens for cart events and have one responding to the AddToCart event, but the only variable it exposes is CartEntityAddEvent $event.

Is there another way to tell from hook_pa ...

Score: 0
Libbna Mathew avatar
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "node_type" plugin does not exist
in flag

I have upgraded drupal 9 to drupal 10 and now while creating a content page or editing the existing content page it is throwing error in error logs

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "node_type" plugin does not exist. Valid plugin IDs for Drupal\Core\Condition\ConditionManager are: gtag_domain, gtag_language, language, current_theme, request_path, user_role, webform, entity_b ...

Score: 0
mullzk avatar
Url-aliases or redirect without language prefix
ec flag

How can I use url-aliases in additional languages without the language prefix?

From his old homebrew-CMS, my client has the following URLs:

  • example.com/english-page => redirecting to example.com/en/node/1
  • example.com/deutsche-seite => redirecting to example.com/de/node/1

I use Drupal 9.5.9, Redirect 8.x-1.8 and Pathauto 8.x-1.11. Default Language is German (de)

node 1 in German has url-alias '/deu ...

Score: 0
Kernel Test: Error: Call to a member function get() on null
cn flag

It's my first time with kernel tests.

I'm working with this test:

<?php

namespace Drupal\Tests\info_irpf_calculator\Kernel;

use Drupal\info_irpf_calculator\Model\IrpfUserData;
use Drupal\info_irpf_calculator\Model\IrpfUserDataInterface;
use Drupal\KernelTests\KernelTestBase;

/**
 * Tests the IRPF calculator.
 *
 * @group info_irpf_calculator
 *
 * @coversDefaultClass \Drupal\info_irpf_calculator ...
Score: 0
Anche avatar
How do I configure the Symfony mailer module?
pl flag

I have a contact form (Contact module and contact storage module). After installing the Drupal Symfony Mailer module, a policy for my contact form appeared. In the Email body in edit of the policy, I enter the tokens of the fields of my form, which I take from /admin/help/token. For example,

[contact_message:field_request_bankname]
[contact_message:field_request_bankname:value].

But these tokens don' ...

Score: 0
tek bhatt avatar
How to show/hide a webform block on nodes of specific content type based on node field value?
id flag

I have a webform with machine name "podcast". I am displaying this webform as a block in the nodes of content type with the machine name 'podcast'. There is a file field with the machine name 'field_podcast_discussion_guide' in the content-type podcast. I want to show/hide the 'podcast' webform block based on the value present in the field_podcast_discussion_guide field for each node of content type 'po ...

Score: 0
MrSnrub avatar
Where is the "Install Profile" value in the Status report set?
in flag

I am using Drupal 7. If I go to Reports --> Status Report, the "Install Profile" value is incorrect (it has an extra dash at the end). Where is this value stored? I wish to correct it.

Score: 0
Sleewok avatar
How do I get the total amount when creating a payment method at checkout(Gateway Plugin)?
ca flag

This is for a gateway plugin that I am developing. This is when the user is checking out and entering payment information, etc.

My Process When the paymentMethodAddForm is submitted I create a transaction with the status of 'HOLD'. The user is then presented with a "review" form. When the review form is submitted the transaction is updated with a status of 'CAPTURE'.

The Issue I need to submit the HOLD tr ...

Score: 0
Nathan Healea avatar
Composer install times out with a bind-mounted volume running Composer through Docker
hu flag

I've been working on trying to set up a Drupal 10 local development instance on my Windows machine and keep running into an issue of the Drupal installation failing when I have a volume mounted.

Following the instructions given on Using Composer to Install Drupal and Manage Dependencies / Installing with Composer via Docker, I've run docker run --rm -i --tty -v %cd%/drupal:/app/drupal composer create-proj ...

Score: 0
quantumized avatar
How can I uncheck checkbox fields during form's validation?
ng flag

We have a Drupal 9 custom validaton hanlder where we need to remove all checkboxes from a multi-value term reference field.

I can clear/change other field types but not this one.

We tried the following code, and other variations.

  $form_state->setValue('field_region', []);

The values always retain even though getValue() for the field shows as cleared in the validation function.

Do you have any i ...

Score: 1
Alberto avatar
Filter content depending on user access
fo flag

In Drupal 10, I use the Permissions by Term module to restrict user's access to content depending on dictionary values.
I have a content view that does not respect the access permission given by that module.

Is there a way to avoid the logged-in user sees the nodes to which does not have access?

Score: 0
Giuseppe avatar
How can I show the "content" menu without the "Access the Content overview page" permission?
br flag

On a site, I installed the Media and Microcontent modules. I need to set up two user roles, one which should access only the "Media content overview" page and the other one which should access only the "Micro-content overview" page.

I've seen both modules share a similar behavior, as they place their overview page route under the system.admin_content link.

From my test, if the roles don't have th ...

Score: 0
HasseWilson avatar
How to enable a custom ContentEntityTypes display mode?
pf flag

On Drupal 9 - commerce I have made a custom ContentEntityType, lets call it bundle_item.

It's all handled when I import product from an ERP system, and attached to a product entity as an entity reference, and all that is good.

But when i try to render the EntityReferenceItems, i cannot, since i dont have access to the entity from admin/structure/display-modes/view/add

Is it possible to enable the ...

Score: 0
tt12 avatar
New message causes a fatal error
si flag

I am facing following error in logs and white screen on sending new message through Private Message Module (Open Social Distribution 11.9.4).

Drupal\Core\Entity\EntityStorageException: Parameter "private_message_thread" for route "entity.private_message_thread.canonical" must match "[^/]++" ("" given) to generate a corresponding URL. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 815 ...

Score: 0
commonpike avatar
How to override views-exposed-form in a module?
in flag

I'm trying to override views-exposed-form. It works fine in a theme, but it's strange in a module. Eventually, it does find the template, but the form is available as {{ element }} and is missing the actual form tag - it's just the children.

<form>{{ element }}</form> sort of works.

In my module, I have

function MYMODULE_theme_suggestions_form(array $variables) {
  if ($variables['eleme ...
Score: 0
GreenTree avatar
How to use a view mode for all the content entities
jp flag

I would like all the nodes for the "Services" content type to use the "Demo" view mode.

Structure -> Content type > Services > Manage Display tab shows 3 view modes: Default, Demo, and Teaser.

Structure -> Content Type -> Services -> Manage Display -> Demo view mode: I have one field "Marketing headline" enabled.

I added a node for the Services content type. When I visit the node,  ...

Score: 0
How to send notification emails to users who flagged a node?
us flag

I want to notification email users who flagged a node.

Previously in Drupal 7, there was Views Rules which is used to get flagger email and loop on them to send message.

Since Views Rules has no 8/9/10 version, I would like to know what alternative ways to do the same, i.e. send notification emails to users who flagged a node?

Score: 0
Fazeela MukhappillyAboobacker avatar
Load webform handler to change to_mail

I have a contact form with three handlers, on to send mail to admin, second to sales team and the last one to the one who have filled out the form.

I would like to change the to_mail address programatically, config sync is not allowed.

Is there any way to load webform handler and set the to address programatically.

function efx_send_mail_update_9953() {
 $config = \Drupal::configFactory()->getEditable ...
Score: 1
ice70 avatar
Migrate user roles with static_map
cn flag

I am trying to migrate D7 users into D10. I have enabled the following migrate modules:

  • migrate
  • migrate drupal
  • migrate plus
  • migrate tools

The migration yml is as follows:

id: create_user_account
migration_group: site_import
label: 'Create User accounts'
source:
  plugin: d7_user
process:
  uid:
    - plugin: skip_on_value
      equals: true
      source: uid
      method: row
      value:
      ...
Score: 2
Juc1 avatar
How can I change the query string used in pages showing search results from keys=football to keyword=football?
eg flag

Search results are given in a page whose URL is, for example, https://example.com/search/node?keys=football. This URL is not recognized by Google Analytics as a search result URL.

How can I change the search URL to https://example.com/search/node?keyword=football?

Score: -1
somo avatar
How to markup headers or footers of views?
co flag

In Drupal 9.5.3 I have a certain View to which I want to add an header text.
I want to style that header text via CKeditor or as plain text.

For some reason CKeditor isn't available there, but I also didn't find a way to edit the header as plain text.




enter image description here




What I have tried to solve this problem

I went to admin/config/content/formats and didn't find a way to enable plain text editor there. I saw  ...

Score: 0
Maher B avatar
Programmatically saving data in a field under user account
cn flag

QR codes have been printed out for a bunch of students in a university. When they visit the site via those QR codes, and they are logged-in, the refcode query parameter used in the link needs to be saved for their account in a field_usr_ref_code field (a Text (plain) field).

In a .module file I am using the following code.

use Drupal\user\Entity\User;

/**
 * Implements hook_entity_load().
 */
fu ...
Score: 0
Patrick Man avatar
How to add/insert a value to the end of an array programmatically (in the .theme file) Add a $row
cn flag

I have some code in the .theme file that renders an array list. I wish to add one additional entry at the end.

I found I could do that with a quick and dirty PHP echo statement, and it works just fine, but I would love to know the right way to do this, how to actually insert an entry at the end, one additional $row after all the others. Here's my code so far (that works, but seems inelegant).

function c ...
Score: 0
liquidcms avatar
How do I disable ONLY_FULL_GROUP_BY in MySQL 8?
us flag

Is it possible to disable ONLY_FULL_GROUP_BY in MySQL 8?

I saw suggestions on how to do this on the MySQL server directly, as well as hacking up Drupal core, but none of them have been successful so far. I suspect either because the options do not apply to MySQL 8 or Drupal is hard coded to force this option (even though I cannot find any reference to this in core).

The issue comes from a view no ...

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.