Latest Drupal related questions

Score: 0
Chandra avatar
Migration entity_lookup not picking up repeating taxonomy terms
jp flag

Background: I am creating new articles in Drupal 9.5 from a source database using the Migrate API. The articles optionally have references to one or more taxonomy terms. I have already created the taxonomy terms in Drupal manually, they look good. I then use the entity_lookup process plugin to lookup the taxonomy IDs as part of the article migration. But when the taxonomy terms repeat, they don't se ...

Score: -3
Tomáš Bažant avatar
Preventing one site from redirecting to www. prefix in multisite
de flag

I am using Drupal 9, multi-site. Generally, for all sites except one, i want to redirect from non-www to www prefix and i'm using the root .htacces file for it by uncommenting redirect rules. But the one site is 3rd level domain such as noha.ruka.cz and i dont want this particular site to redirect to the www prefix. Any idea?

Score: 0
Wayne Foster avatar
I'm unable to run Drush v8.4.12 on PHP 8.1.6 using Bash on Windows11
in flag

I'm on the final two sites to migrate to D9 - but some D9 modules are now needing PHP 8.1 to stay on the latest upgrades. So - I've changed my server environment to use PHP 8.1 - and using XAMPP for Windows 11 - on PHP 8.1.6 - as per the Drupal.org PHP recommendation.

Only issue is - I'm now unable to use drush to update my remaining D7 sites. Has anybody got this to work on Windows 11 - using ...

Score: 1
Pipo Bizelli avatar
How to get Paragraph Changed Time?
nz flag

I know how get User entity changed time ($user->getChangedTime()).
Node has the same value ($node->changed), but I need to get this changed time from a Paragraph.

When I try this method $paragraph->getChangedTime() (the value changed do not exists) i got this:

Error: Call to undefined method Drupal\paragraphs\Entity\Paragraph::getChangedTime() ...

I have this field in my User entity, and I need t ...

Score: 0
Loopy avatar
Troubleshooting issue forks to make core version compatibility fixes
cn flag

During the Drupal 8->9 upgrade, we noticed an issue where module maintainers had abandoned a project or were not responding to merge requests in a timely manner. As you know, composer doesn't care about patches when it comes to compatibility with major versions of Drupal, so you need an actual release which is compatible with the next major version before you can update drupal core in composer. This  ...

Score: 0
Adam888 avatar
Is there a simpler way to sum selected options in Webform computed_twig
ph flag

I want to sum up all values of selected radios (all q_ keys checked values) in a Drupal Webform form. Now I am doing it like this {% set answersTotal = (data.q_1 + data.q_2 + data.q_3 + data.q_4 + data.q_5 )|number_format %} {{ answersTotal }} and it's working fine but I want a more efficient/simpler way to avoid having to type all the data.q_# as there are many q_ in each group. I tried this (in a ...

Score: -3
David avatar
Update entityManager()->getViewBuilder from 5 year old site?
sy flag

I have a Drupal 8 module which hasn't been updated for 5 years. I m trying to update to current version of Drupal.

The error I get is

Error: Call to undefined method Drupal::entityManager()

The code causing the error is below.

      $viewbuilder = \Drupal::entityManager()->getViewBuilder('paragraph');
      $data = $viewbuilder->view($paragraph);
      $array['#cache']['tags'][] = 'node:' . $n ...
Score: 0
Use a different template file for front end and submission view
ng flag

I have defined a custom template file referenced via #theme for my custom webform element.

public function getInfo() {
  $class = get_class($this);
  return [
    '#input' => TRUE,
    '#process' => [
      [$class, 'processWebformElementSeatbooking'],
      [$class, 'processAjaxForm'],
    ],
    '#element_validate' => [
      [$class, 'validateWebformSeatbookingElement'],
    ],
    '#pre_ ...
Score: 0
sudhan avatar
When doing views Rest Export the response has media field where i also want alternate text, how to get them as response
us flag

I am getting rest response through views and when i try to get response with field media i also need to get image/media alternate text.I tried to set through relationship for the particular media field and then fetch the alternate text but i receive in html format with html tags , how to get only the alternate text in plain text format. Please help.

Score: 0
Claudia Burman avatar
Menu from Views page display using contextual filter taxonomy term
im flag

Classified ads site here, Drupal 10.0.7

I have a View page display showing fields from nodes using Taxonomy Term Id as Contextual Filter. So if the URL reads "[domain]/clasificados/8" it shows all fields of nodes tagged with term 8

How can I generate a menu from that vocabulary that points to "clasificados/{id}" ?

Taxonomy Menu generates "/taxonomy/term/{id}"

Thanks.

Score: 0
awm avatar
Prevent last updated property from changing when updating node in code?
mx flag
awm

I have this code that updates a node in a queue worker:

      $changed = $entity->getChangedTime();
      // Don't update the changed time by 
      $entity->setChangedTime($changed);
      $entity->set('my_field', "my_data");
      $entity->setNewRevision(FALSE);
      $entity->save();
      

Here is a screenshot of xdebug showing changed and after_save value with the relevant co ...

Score: 2
Souvik Das avatar
Append new paragraph item to existing node
rs flag

I want to append a new paragraph item to a existing node, which has previously a paragraph item. I just want to add another paragraph item with the previous one. But my script only updates the previous added paragraph item with the latest data, not appending with the previous one.

$nid = \Drupal::entityQuery('node')->condition('title', $product_name)->execute();
        $nid = array_values($n ...
Score: 0
Jaypan avatar
Programmatically render block content render array with wrappers
de flag

I'm trying to render a custom block, created through the UI, programmatically with a wrapper. I can do this:

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

$output['header'] = \Drupal::entityTypeManager()
  ->getViewBuilder('block_content')
  ->view($block);

And the block is rendered, but only the fields of the block - the block wrappers are not rendered. ...

Score: 0
AllisonC avatar
Twig output not styled correctly
cn flag

In one of my twig templates, I have:

<pre>{{ dump() }}</pre>

Twig output looks like:

Sfdump = window.Sfdump || (function (doc) { 

enter image description here

Controller (partial code):

$renderable = [
  '#theme' => 'child-profile',
  '#profile' => $records,
];
$output = Drupal::service('renderer')->renderPlain($renderable);
return [
  '#type' => 'markup',
  '#markup' => $output,
];

How can I get this  ...

Score: 0
awm avatar
How to make a traditional entity field excluded from revision?
mx flag
awm

Is it possible to make an entity field excluded from revision? I want to avoid creating revision table for the field if possible. Otherwise, just excluding creating revisions is fine.

I tried to alter the field definition in code:

function mymodule_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
  if ($entity_type->id() === 'node' && isset($fields['field_my_fi ...
Score: 0
Best practice for user specific data related to specific nodes
in flag

I have a content type travel_locations wich contains multiple fields (such as title, body, geolocation, etcetera). Now I would like the user to reference nodes of this content type when for example he has visited this location, together with specific data about this visit (traveldate, rating, textfield for travelnotes etcetera). The specific travel data will probably be collected trough paragraphs modul ...

Score: 0
Kevin avatar
Apply Context/Conditions to a Views result item?
in flag

If you are using Context for a node, the node itself typically comes from the node page you are on. In some cases, you may want to apply the same context to views results on a node as well - but they are getting the same argument instead of the node of the result. How can you supply the result item as the context argument to conditions?

Score: -1
Sundar Raj Ponnulingam avatar
How do I set a plain text field value to be empty?
to flag
<?php
function MY_MODULE_node_update(NodeInterface $node)
{
    if ($node instanceof \Drupal\node\NodeInterface) {

        $nid = $node->id();
        $nodeType = $node->getType();
    
        $vid = \Drupal::entityTypeManager()
                ->getStorage('node')
                ->getLatestRevisionId($nid);

        $comments = $node->get('field_workflow_comment')->getValue();

   ...
Score: -4
Jimmy avatar
What is the correct procedure for creating multi-instances and websites?
sk flag

I have installed Drupal 10 and it is working with no issues. I can create my first multi-instance with a single website with no issues.

The problem I have is when I create my second website in the default instance; all of the links in the second website point back to the first website by default. I am assuming the method I am using to create Drupal 8 websites is not the same as it is now in Drupa ...

Score: 0
user110190 avatar
When "Use AJAX" is set to Yes on a View with Better Exposed Filters, the old search results are not cleared
is flag

Using Drupal 8, when AJAX is enabled on an exposed filter old search results aren't removed. I don't see any console errors but it seems that 'Use AJAX' isn't clearing the div before loading the next results. Is there a better way to go about fixing this other than attaching behaviors to Drupal AJAX?

Score: 0
Jasbir avatar
Select media popup is not opening after upgrade ckeditor from 4 to 5 Drupal
bi flag

We have drupal version 9.5.7 in our website, When we had upgrade ckeditor4 to ckeditor5 then Select media popup(for image and video) is not opening.

Console error: ajax.js?v=9.5.7:411 An error occurred during the execution of the Ajax response: TypeError: $element.dialog is not a function

enter image description here

When I click on add media button then select media popup is not opening, Please help me to fix it, thanks.

Score: 0
Tobias Krause avatar
Special sorting requirement in views for a multi-value field: how to avoid duplicated result items
cn flag

This is another attempt to solve Custom views filter plugin: filter over two fields of a custom entity where one of the fields is a multi value field in a seperate table

I have create a basefield (committee_role) for a custom entity (committee_membership). The entity holds data about the membership of a deputy in a committee in parliament. Politicians can have more than one role in a committee but at  ...

Score: 1
Robert Brax avatar
Image from field not properly displayed in teaser
ad flag

On Drupal 10 with Olivero theme, I set image in teaser to be displayed with original size. I also made sure the image field display is enabled in teaser view.

Still, the image is shown on the left of teaser, as minuscule round image. It seems teaser display doesn't respect what is set in admin.

How to have image displayed in teaser with specified size and location?

Score: 4
lilHar avatar
How do I use \Drupal methods in a class?
ve flag

I was out of Drupal for a few years, and PHP a couple years, due to having several years of jobs that didn't use Drupal between two that did. And I'm noticing a lot of functions that were reliable are now gone.

The particular case I am currently looking at is variable_get() occurrences replaced by \Drupal::state()->get().

However, I tried using it, and it's far from a drop-in replacement. In a class  ...

Score: 1
liquidcms avatar
Is it possible to send an argument to a title callback?
us flag

I am trying to figure out how to set page titles on various pages. I have seen a lot of posts suggesting preprocess functions. These are not correctly setting the route's page title but only setting the value for the html template.

Another solution is closer in that it suggests using an EventSubscriber triggering off the KernelEvents::REQUEST event. This is the correct approach. Some routes have  ...

Score: 4
Can services be autowired?
br flag

In drupal 8, each time we used to declare a class as a service by adding it to [module name].services.yml and then injecting it in the constructor of a different class. However, according to this answer https://stackoverflow.com/questions/44809739/is-there-a-way-to-inject-entitymanager-into-a-service , in newer symfony versions, we can inject a service without defining the class in services.yml. does it ...

Score: 1
user110161 avatar
/search-results page returns 404 if no query parameter is present
sm flag

I have inherited a Drupal site with a node that uses /search-results as path alias.

The page works fine if I use https://example.com/search-results?keys=test or https://example.com/search-results?keys, but it returns a 404 error if I use https://example.com/search-results.

Any thoughts on where to begin?

Score: 0
Peter Mengerink avatar
Commerce and Views - show all products where there are colours available as different clickable links
gy flag

I am building a commerce site. I'm trying to create a view where all my products will show with image, title and price. I sell t-shirts in say 3 different colours in 3 different sizes. In the overview page I want to show the 3 colours as separate items not as being part of the same listing. when I create a view it will come up either as all the options, so the same colour 3 times, one for each size or I ...

Score: 0
mankin avatar
Change operator in a query?
am flag

I'm working in a Drupal 9 website.

I need to change operator in my view query from != to <. In a view i got two contextuals filters:

  • The first to retrieve id from an entity reference field.
  • The second to retrieve current node id.

In the second contextual filter, exclude is selected to be != in my query.

The result i need is to transform this != to < for show all nodes who got the same reference fi ...

Score: 0
D. Jansen avatar
One taxonomy filtering two fields
sn flag

I have 2 fields on one node that both read the same taxonomy (Normal features and special features).

Now I want to show only 1 filter in the view that looks in both fields. And with the "Combined fields" filter I don't get these fields as an option, let alone only get a text field and no checkboxes

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.