Latest Drupal related questions

Score: 3
May  avatar
How can I replace a string in a text?
zw flag

With {{ content.field_myfield.0 }}, I get a text. When I use {{ content.field_myfield.0|replace({"foo" : "bar"}) }}, nothing is rendered and no errors are reported.

I also tried replacing content.field_myfield.0 with content.field_myfield.value or `content.field_myfield.0.value, but I still get an empty string.

How can I replace a string?

Thanks

Score: 2
Problem with same webform added multiple time in a page
th flag

Problem

I have an Article node with layout builder enabled for content author.

I have webform Subscribe newsletter with ajax enabled.

I add webform Subscribe newsletter to the node twice. So there are 2 same webform added to the node.

When I submit the second form, the confirmation message appear in the first webform.

Expected

Confirmation message should appear in second webform.

What I tried

I tr ...

Score: -5
how to get url of link to content in twig?
cn flag

I just created one view block to show all my blogs in it. I am getting all fields in twig but unable to call "link to content" to current node of every blog from view block.

Any solution please help me.

I tried like below with url not working

<a class="d-inline-block" href="{{ url }}">
<h2 class="blog-head" style="color: #2d2d2d;">{{ content['#view'].field['field_blog_post_title'].value(row)  ...
Score: 0
turpentyne avatar
How to limit facets options to specific terms in taxonomy
tr flag

I have a Drupal 9.3 site with Search API, Database Search and Facets modules active.

The site also has a taxonomy with hierarchy. I've built a working View and added a Facet to filter items by that taxonomy. I can enable the "Use Hierarchy" checkbox in the Facet's settings. (I've also turned on the hierarchy processor in Search API).

This gives me a working filter where I can check a parent taxonomy ...

Score: 0
How can I standardize the query from exposed form input?
in flag

I apologize in advance if the title for this post is misleading, my intention is to use exposed form input from a form in a block display (not on the view page) to build a query on a page display for the same view. The page display has another exposed form block that filters on the same fields, plus others. When I submit input from the first form, the query looks like field_foo_target_id=123, which d ...

Score: 0
William Breindel avatar
Accessing a Paragraphs field's from inside the parent paragraph
us flag

I have a paragraph twig file that I'm adding to my subtheme.

Inside of it I have another paragraph that is being used. And there could be more than 1 of the child paragraph.

I have this code:

 {% for key, item in content.field_faq_section_question if key|first != '#' %}
  {{ item }}
    
{% endfor %}

And it prints the title and the text fields of the paragraph properly. But What I need to do it  ...

Score: 0
kendavidson avatar
Table view combined fields, separate sort
us flag

I'm looking for some assistance in setting up a table view to be able to sort merged columns separately. At a high level I have the following view table:

First Name Last Name Age/Weight^
Ken Davidson Age: 42
Weight: 200

I have all three columns sortable, except that the third column only sorts by Age, even though it has two possible sort options. Clicking the Age/Weight will only sort by ...

Score: 1
How can I get the canonical path with {{ path('entity.node.canonical') }}
us flag

When I use {{ path('entity.node.canonical', {'node': node.id}) }} in a node template file, it renders the path alias.

How can I get the canonical path?

Score: 0
Unit Test validateForm of custom content entity form
ke flag

I have a custom content entity and some custom validations in the entity form validateForm method.

Now I "just" want to test my implementation of the validateForm method (or for the start I just want to test for the correct form id, but even this fails).

Mocking my own custom entity is the main problem I have at the moment.

Here are some code examples and my error message This is my custom valida ...

Score: 0
May  avatar
How do I add HTML markup to the title?
zw flag

I am trying to alter my title to include html. I have tried the following

function MODULENAME_views_pre_render(\Drupal\views\ViewExecutable $view) {
  if ($view->id() == 'products_test') {
    foreach($view->result as $value) {
      $value->_object->set('title', 'test - <b>My new Title</b>');
    }
  }
}

This outputs the title as test - <b>My new Title</b>, rather ...

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.