Latest Drupal related questions

Score: 0
bigboy avatar
Filter views by field value equals another field of curent node
gu flag

D9.3. All fields are not referenced, they are just simple integers. All data was pulled from a huge external API and it was not possible to create all references.

Just for ease of understanding, imagine a book database website with books and characters. But each character is presented in one book only.

So, book node has field_book_id, which is numeric, unique, but not NID. Also it has a multiple  ...

Score: 0
Steve Siddu avatar
How do I dynamically add filters?
br flag

I have a view_block with the following filters,

enter image description here

I want to change the product tag, Release tag, Document type values dynamically based on url.

if the url is, example.com/mars/21.43.00/ProductGuide, then the filters should change like this

enter image description here

I don't know how to achieve this, any suggestion would be helpful

Thank you!

Score: 1
Altering custom template from code
pt flag

How can I programmatically remove blocks and other elements from a single custom template ?

In my custom modle I have defined a route to a controller which then loads a template which is also contained within the same module. I am successfully loading data from the controller into the template.

My issue is that the template inherits blocks and menu from the active theme which I need to remove but on ...

Score: 1
Make Title field "not required" or workaround how to prefill and hide it (drupal 9.2.8)
ug flag

On my site (drupal 9.2.8) users add content and there is no need to put any information to 'Title' field. I was trying to make this field not required via form_alter in custom module but it did not work:

function yourmodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id){
  if ($form['#form_id'] == 'node_somenode_form' or $form['#form_id'] == 'node_somenode_form') ...
Score: -5
Is by design, Drupal headless?
es flag

If I understood correctly, "decoupling" a content management system means separating backend from frontend (having two "modules" for each under the same "program").

If I understood correctly, "headlessing" a content management system is making it to be possible to supply content to at least two different front-end interfaces at once ("two different programs" as may appear to an end user).

I would as ...

Score: 1
Can't save value of custom datetime field
in flag

I'm reaching out because I just can't find out why my custom datetime field isn't saving its value after I submit.

Context:

I've created a field containing two datetime fields. I will use it to add or remove events from an event list, depending on whether they have passed or not (for example if a festival is scheduled from the 12 to the 14 of December, the event will be removed after the 14th).

Events in  ...

Score: 0
Can't upgrade Webform from 5.x to 6.x: "Entities exist of type Webform submission and Webform"
vn flag

I recently updated my site from Drupal 8.9.19 to 9.2.8, and from Webform 8.x-5.28 to 6.1.0.

I'm now trying to deploy this update to my test server, and I'm getting the following error when running drush cim:

 [error]  Drupal\Core\Config\ConfigImporterException: There were errors validating the config synchronization.
Entities exist of type <em class="placeholder">Webform submission</em> ...
Score: 0
Joost avatar
Is it possible to see which modules grants access rights?
jp flag

Working on a Drupal 9 website the module Permissions by term gives an unexpected behaviour.

Trying to find the problem I got stuck. I think there might be another module overwriting the permissions. But I can’t find out which one.

Is there a way to see which module grants what right to a node/user?

Or is there another step I should do to debug these node permissions?

Thanks a lot!

Score: 0
Lambic avatar
Migrating an array of values into multiple entities
ph flag

I'm using migrate/migrate_plus modules to import CSV files and generate entities.

One of the columns in the CSV can contain multiple values like 1|2|3, which I'm converting to an array using:

_jurisdictions:
  plugin: explode
  source: jurisdiction
  delimiter: "|"

I'm then using the array to generate taxonomy terms with this:

field_political_district:
  -
    plugin: entity_generate
    source: "@_ ...
Score: 0
sndr avatar
Load view form with ajax missing ajax functionality
us flag

When clicking an element I get a form which is generated by a view (using https://www.drupal.org/project/editablefields module). The problem is that the ajax functionality of the form is lost (no ajax-processed classes are present). This is the working js code to retrieve the view:

(function($,Drupal) {
  Drupal.behaviors.MODULE = {
    attach:function (context, settings) {   
      $('#test').cl ...
Score: 0
Baud avatar
Drupal::messenger() not working in shutdown function
sa flag

Some time I need to use a shutdown function. Here is a stupid example:

...
drupal_register_shutdown_function('display_message');
...

function display_message() {
  Drupal::messenger()->addMessage('Hello world');
}

Is it possible to display this message as for now, it is not working (even at the nex page refresh)?

As requested I will explain why I need to use shutdown function.

My use case:

We are in ...

Score: 0
Steve Siddu avatar
How to add contextual filter?
br flag

I am working with books in drupal 8. I want to display a specific page("table of contenets") on the sidebar whenever any page of that book is accessed. "table of contents" is a book page. every page of book has two id's.

  • page_id
  • book_id

Page_id is unique for every page but book id is same for all pages. I believe contextual filter based on book_id might solve my issue. but I don't know how to add c ...

Score: 0
Giuseppe avatar
How get the referenced entity inside a field link?
br flag

I'm on D9. I've a paragraph with a Link field. I need to get the referenced entity programmatically.

What I've managed so far is:

       $nid = NULL;
       $field_link = $paragraph->get('field_link')->first();
       $route_params = $field_link->getUrl()->getRouteParameters();
        
        if(isset($route_params['node'])) {
          $nid = $route_params['node'];
        }

       if($ni ...
Score: 0
Hide and unhide custom block programatically drupal 9
cn flag

Hello I have created a module to display a block. I would like to set the block visibity to visible and hidden in the homepage based on a condition.

like this:

edit:


//fetch status from database then check condition
if ($status = 1){
//make block visible
}else{
//hide block
}

I have searched all over the internet and could not find how to make it work.

I have a form that is used to add contents to a ...

Score: 0
Amine avatar
Time spent with custom module
us flag

Can anyone help me with this, I want to activate time spent module on my custom form module, and store the time spent on a field on my form. I think that I could do it on the file timespent.module here.

function time_spent_init() {
  //if user has a role who is going to be tracked, add javascript code
  if (time_spent_user_has_role()) {
    $timer = variable_get('time_spent_timer', TIME_SPENT_TIMER);
   ...
Score: 1
SomebodySysop avatar
How to add view filter programmatically using hook_views_pre_view()
gb flag

I want to add a simple filter to an existing view in Drupal 9. It appears that I can achieve this with hook_views_pre_view(). In every example I can find, including all the "Similar questions" links that come up when entering the title of this post, I see that $view->add_item() is used. See: Add views exposed filter programmatically

However, when I try to run this code:

function sbn_views_pre_view($vi ...

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.