Latest Drupal related questions

Score: 0
Interlated avatar
How do I debug overridden twig templates?
km flag

How do I debug the template overrides. The debugger stops on page.html.twig but doesn't stop on sub templates such as

web/themes/custom/localtheme/templates/field--paragraph--field-pbcrossfade-image--crossfade-banner.html.twig

The page.html.twig breaks here

enter image description here

The debugger does not break in the sub template.

enter image description here

Score: 0
If I am using PrivateTempStoreFactory, should I be using the Internal Page Cache Module?
pk flag

I found a Stack Exchange question here that kind of answers this question, but I was not clear about the answer from the exchange in the comments. Regardless of the reason I am using PrivateTempStoreFactory, should I avoid using the Internal Page Cache module if my site uses a custom module that uses PrivateTempStoreFactory?

Score: 1
Anthony Tailor avatar
Disable source code formatting in CkEditor
ua flag

In Drupal 9, is there a way to avoid CkEditor re-formats the source code?

There is one text editing mode set in Drupal, Full HTML. When I edit or create a Basic page node, once I click the Source button, paste in code, deselect Source, and then re-select Source, the formatted code becomes CkEditor-ified.

I only found posts from years ago or that aren't for Drupal 9. I've tried the CkEditor Config modul ...

Score: 0
hotwebmatter avatar
Template preprocess to generate Font Awesome markup for menu links
nr flag

In Drupal 9, I need the ability to prepend Font Awesome icons to menu links.

I have attached Font Awesome 5 JS and CSS assets to my theme via *.libraries.yml.

If I open a menu link in the DOM inspector and edit the markup of a link from this:

<ul class="clearfix nav">
  <li class="nav-item">
    <a href="#comments" class="nav-link nav-link-comments">Comments</a>
  </li>
&l ...
Score: 1
Chris Roditis avatar
Ajax form inside custom system.404 route controller doesn't work
in flag

I need to display custom logic in 404 pages so I have overridden the route controller of the system.404 route like this:

class RouteSubscriber extends RouteSubscriberBase {

  protected function alterRoutes(RouteCollection $collection) {
    if ($route = $collection->get('system.404')) {
      $route->setDefault('_controller', '\Drupal\mymodule\Controller\myController::on404');
    }
  }
}
Score: 0
user3108268 avatar
Set a Data Value from Text field to Term Reference field
us flag

Node has two fields:

  1. Text field
  2. Term reference field (autocomplete?)

The Text field is old and already has 500 nodes with 500 unique values.

The Term reference field is new and needs to contain same data.

So e.g. one node has Text field value of 123, the Term reference field also needs somehow to have it set to 123?

enter image description here

In Rules Set a value data only lets you copy content from term reference field ...

Score: 0
Rog Boy avatar
Checkbox Ajax call back giving me error
ma flag

New to drupal 7, following code should work fine according to my knowledge can someone help me why ajax give me error in console ? and what the solution

Code

function user_activity_tree_structure_showoptional_form($form, &$form_state, $base_nid) {
      $form['enablecond'] = array(
        '#type' => 'checkbox',
        '#title' => "Checkbox  ",
        '#ajax' => array(
        'callba ...
Score: 0
Interlated avatar
How do you add a CSS class if the default field value is chosen?
km flag

How do you identify that the default taxonomy field choice has been chosen?

Solution consists of a taxonomy list. If the default is chosen the title in the display should be hidden.

Using views to display the list.

Score: 1
berliner avatar
How to create automatic url alias for taxonomy/term/%tid/feed
bd flag

How can I set automatic URL aliases for taxonomy feeds?

Say I have a term with tid=1, named holidays, with a system URL of /taxonomy/term/1 that is accessible by the URL alias /holidays. Then I want the rss feed for that term to be accessible on the URL alias /holidays/feed or /holidays/rss.xml. That sounded rather easy when I first thought about it, but it seems that pathauto is not supporting that (o ...

Score: -1
José Luis avatar
Insert PHP snippets in content
in flag

Drupal 9 doesn't have the PHP Filter module in core. I need to insert PHP snippets in the content editor (for example a Twig variable).

Is there any way to insert PHP snippets in Drupal content?

Score: 0
gmak avatar
Pass a value via URL to a node edit form and use it to redirect after saving the node
cn flag

I have a node that includes a series of embedded views. When displaying, I have to pass a value via URL arguments (http://example.org/node/x?id=y), so that the views can get the appropriate information. The user needs to be able to edit this node, but when they save and return to the node it has lost the id=y part and the display is incomplete.

I know I can use hook_form_alter() to redirect, but I ...

Score: 1
How to determine which password hash is used?
us flag

We have migrated website from a vanilla coded PHP to Drupal, and I have also migrated all the users.

The old website has been using the password_hash() function to encrypt the password.

The website has been running for a month now. I'm looking at the user table, and I want to know determine which users has been encrypted using password_hash() or the default Drupal one.

I have this code

$query = \Drupa ...
Score: 1
Karthik avatar
How do I get the comment ID in a template file?
in flag

I want to show the comment title linked to the comment permalink. This is the content of the comment.html.twig file.

 <div{{ content_attributes.addClass('comment__content') }}>
    {% if title %}
      {{ title_prefix }}
      <h3{{ title_attributes }}><a href="#comment-{{comment.id}}">{{ title | render | striptags}}</a></h3>
      {{ title_suffix }}
    {% endif %}
   ...
Score: 0
spacecraft96 avatar
Programmatically add a taxonomy field to a custom content type
ng flag

I'm familiar with adding fields to a custom content type in the yaml files of the module. I'm unable to find an example of how to add taxonomy fields to a content type at programmatically at install.

What does the field.field.node look like?

What does the field.storage.node look like?

Are there special names for the widgets for core.entity_form_display and core.entity_view_display?

Thank you

Score: 0
scaffolding avatar
Adding Javascript within a hook_entity_type_presave() hook
es flag

I'm trying to add Javascript into a hook_entity_type_presave() hook, but it's not firing.

Is it possible to add within this hook?

I've attempted to with no success -- my code is below -- and this example on Drupal.org: https://www.drupal.org/docs/drupal-apis/javascript-api/add-javascript-to-your-theme-or-module ...describes the process of adding javascript within the context of two other custom modu ...

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.