Latest Drupal related questions

Score: 1
bdereta avatar
Custom node routing
cz flag

I have a product content type with alias: /products/headphone. This product page has two url variations:

  • /products/headphone/wire
  • /products/headphone/wireless

Both urls should point to the same node, however within preprocess function or twig, I should be able to capture which variation is loaded (wire|wireless)

I figured I should create a custom module and handle custom routing:

my_module.routing.yml: ...

Score: 0
user3038672 avatar
Extending block, a block with a paragraph field, and 3 paragraph fields... how to loop through the paragraphs from the block extension
cn flag

This is what I have:

I have three twig files:

  1. block--paragraph-images.html.twig (which extends block.html.twig)
  2. field--field-paragraph-image-block.html.twig (the paragraph field which is located in the custom block type, block--paragraph-images.html.twig.)
  3. paragraph--field-paragraph-image.html.twig (which houses three fields: field_paragraph_image, field_paragraph_title, and field_paragraph_text ...
Score: 0
fallenturtle avatar
Message Subscribe is ignoring flag and sending notifications to everyone
au flag

I'm developing a Drupal based forum and I'm using the Message stack modules combined with a tweaked version of this custom module. https://github.com/Lullabot/message_integration The idea is that all users get an email when a new thread is posted, but only users to subscribe to a thread get notification for comments left in that thread. The part where people get emails for new threads is working, bu ...

Score: 0
Webform sometimes not sent on pages using different theme (via theme negotiator)
cn flag

I have a website with a main theme and another "mini" theme that is used via a custom module with a theme negotiator, determined by node type. The pages using the mini theme include a webform, in a block.

The mini theme pages seem to display properly, including the webform, but in many cases after filling the form, the submission is not sent (not logged in tables and no confirmation). There are s ...

Score: 0
Kevin avatar
Deleting a Paragraph Item results in AJAX POST error "Missing bundle property on entity of type node."
in flag

Working with an older D7 site. On it, we have added the latest version of Paragraphs to add some content items to a page. This all works fine.

However, when trying to remove a Paragraph Item from the form, you get an AJAX error. The root of it is:

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 8006 of /mnt/www/html/moswebsandbox1/docroot/include ...
Score: 0
Ivan Ginovski avatar
Toggle view displays on the same page
jp flag

There are 2 view displays (2 blocks) which are showing products, one with tile display, one with list display, as shown in the image below.

enter image description here

Is there a way to have both blocks on the same page, but toggle them with a button? Once the button is clicked, one block is hidden and the other one is shown. enter image description here

What would be the best way to achieve this? Is there a module that provides functionality about this?

 ...
Score: 0
FrankDesign avatar
Drupal 9 Commerce change the Pay button text
cn flag

I have created Drupal 9 website. On the website we accept donations using Commerce with Commerce Stripe as the payment processor. By default, the payment button says "Pay and complete purchase". As users are not purchasing anything, I want to change the text to something like "Donate Now". I have searched for answers online but all seem to point to the module String Overrides, which is D7 only and doesn ...

Score: 0
Jorn Reed avatar
Validation for radio inputs don't work for me
il flag

I'm building a form with the drupal forms api. Validation works well for all my other fields. But I've started to try and work with radio buttons too now. It doesn't matter if I click on a radio option, the validation returns always 'color is required'.

// Form build method code
$form['birthdate'] = [
  '#type' => 'date',
  '#title' => $this->t('Your date of birth'),
  '#date_date_format'  ...
Score: -1
Jorn Reed avatar
Formatting date field with the Form API
il flag

Hi there I'm using drupal 9.x and the forms api to generate a dynamic form. Altough I'm living in the Netherlands where the date format standard is 'dd/mm/yyyy'. I've looked around on the internet for recent ways to modify that format in the html input. But all ways seems to be deprecated cause they don't seem to work for me. I've tried stuff like:

$form['birthdate'] = [
  '#type' => 'date',
  ' ...
Score: 2
richirm avatar
drush cr on replicated servers
in flag

I am the administrator of a Drupal site replicated on 4 servers, behind a load balancer. There is only one database that is shared by the 4 instances. When I run drush cr, is it necessary to run it on each of the 4 nodes, or is it enough to run it on only one?

Score: 0
config:import:single - Class 'Drupal\config\StorageReplaceDataWrapper' not found
cn flag

When I am trying to import a single configuration file within my multisite environment, I am facing the following error:

root@d655a4e6dc36:/opt/drupal/docroot# drupal --uri="3030-bronze-minnow-vuask4c0.ws-eu18.gitpod.io" config:import:single --directory="/opt/drupal/config/sync/" --file="core.extensions.yml"

Error: Class 'Drupal\config\StorageReplaceDataWrapper' not found in /opt/drupal/vendor/dru ...
Score: 0
getCommentedEntity returns null
in flag

I have a comments page set up and when I devel the page for a specific comment I see the getcommentedentity method. enter image description here

I am trying to get the commented entity details using the below code in my VBO action file:

public function execute(ContentEntityInterface $entity = NULL) {
    $comment = $entity->get('comment_body')->getValue();
    $commentid = $entity->get('cid')->getValue();
    $va ...
Score: 0
Update body field from ajax callback
cn flag

I need to update the common "body" field when I change some paragraph fields value.

Here is my hook_form_alter :

$form["body"]["#prefix"] = "<div id='body__update_real_time_seo'>";
$form["body"]["#suffix"] = "</div>";

$form["field_content_edito"]["widget"][3]["subform"]["field_paragraph_subtitle"]["widget"][0]["value"]["#ajax"] = [
    "callback"  => "_update_real_time_seo",
    "event"  ...
Score: 1
Fadi Alkhatib avatar
Adding Current Product page Variant ID/SKU to webform submission Drupal 8
it flag

I have product type event, this event have registration fees if price value not zero.

Product page built with views and I embed related webform inside it.

am using module called commerce webform order: which add handler to webform to create order and redirect user after submit webform to checkout page.

Currently I use fixed selected variant as screenshot below

enter image description here

This field needs to be filed with product I ...

Score: 2
Gabriel Fernandez avatar
hook_node_presave get original of translated node
cn flag

I'm using a hook_node_presave and I want to detect which field is updated when the translated node is updated. Here is my code :

function hook_import_node_presave(\Drupal\node\NodeInterface $node) {
  if (!$node->isNew()){
    $entityFieldManager = \Drupal::service('entity_field.manager');
    $fields = $entityFieldManager->getFieldDefinitions('node', 'article');
    foreach($fields as $field ...
Score: 1
thornley avatar
Difference between a front-end theme and an administrative theme?
im flag

I am teaching myself Drupal 9 and I see that the Claro theme is defined as a "Drupal administration theme" while Olivero is defined as a "Drupal front-end theme." Are these complementary themes? I'm not sure about whether I should install both - to have both a front-end and an administration theme or whether I need only one or the other. Any help you might offer in understanding the difference between a " ...

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.