Latest Drupal related questions

Score: 1
Avoid group of revisions history view duplication
us flag

My taxonomy View lists all revisions grouping by different columns, by adding revision fields for each value, and get the filter "published" removed. The only filter is: city name (not null).

For example:

| London | Roma |

| value 1 | value 1 |

| value 2 | value 2 |

As you can tell, people can add different city data by making new revision of the taxonomy. It wo ...

Score: 0
How to make an entity reference field only load a rendered entity, when clicking on it? (ajax load on click)
cn flag

I want to mimic a zettelkasten system, by starting in a very simple way:

An entity of type 'Note' includes a body and an entity reference field, that can reference another note (of the same entity type) as fully rendered embedded entity.

I like to make the viewed note only display the entity reference field as link, but when I click on it the referenced link must turn into a fully rendered entity. ...

Score: 0
Tomáš Bažant avatar
How do I configure sites.php for a multi-site with fixed IP and subdir?
de flag

I have just installed clean minimal Drupal 9, created a sites/sites.php with the following line

$sites['10.0.0.133.drupal.web.foo-bar'] = 'foo-bar.com';

and the following subdir sites/foo-bar.com with settings.php that includes the correct database settings. After entering http://10.0.0.133/drupal/web/foo-bar into the browser, the default site respond which means the site alias has not been recogni ...

Score: 0
How to limit the depth of embedded referenced entities
cn flag

Using Drupal 9 or 10 Using a node type Page with one entity reference field, which is displayed as rendered entity, displaying the same Page content type.

When viewing a page, how do I prevent the page from having endless nested pages in it, leading to infinite loading? I like to limit the nesting to 4 levels deep.

Score: 0
Kurucz István avatar
Logged in user data, after logout
US flag

I need the ID of the logged in user, after logging out. I tried to use a session variable, but all data is lost on exit. Is there any method to use, other than the query parameter?

┌──────────────┐                        ┌──────────────┐
│              │                        │              │
│  Page        │       ┌─â ...
Score: 0
0711master avatar
Views: How to filter content by taxonomy terms that are not selected?
cn flag

I have a view of a specific content type that can be filtered by two different taxonomies A and B. Some nodes that have the taxonomy term A1 also have the term B5. Now when I filter only by the term A2 I also want all the nodes to be listed that have both the term A1 AND B5, irrespective if B5 is selected or not. Is there a possibility to do that?

Score: 1
Jennifer avatar
Custom event from existing event
cn flag

I've been reading for days, trying several examples but I'm just not getting it.

I have the Rules module as well as the H5P module. I'm attempting to create a Rules event from the existing H5PFinished event (which may or may not be the way to go about this).

Their function constructs an array of five fields, which then update in the GDB.

// which fields to update
$fields = [
  'content_id' =>  ...
Score: 0
Add js library to custom ckeditor4 plugin
pt flag

How can an external JS library be integrated into Drupal for use within a custom Ckeditor4 plugin?

My custom plugin needs to set a javascript cookie each time I click on the plugin icon and unset when I close the plugin dialog.

I attempted to use JQuery which didn't work and when I googled the issue, I found a post saying the jquery-cookie is being replaced with js-cookie.

I attempted to install js-coo ...

Score: 0
Vikram8888 avatar
How to change date format of exposed filter input value?
in flag

By default view exposed filter ,filtering the data in such way. http://mydomain.docksal.site/events?combine=&field_event_categories_target_id=All&field_start_date_time_value=&field_start_date_and_time_value=2023-01-07. When we inputs the date field in such format 2023-01-07

But customer wants to filter the date in dd/mm/yy When we pass the date in exposed filter in such format 07/01/2023 ,the ...

Score: 1
milawithict avatar
Passing preprocess function variables to a template
er flag

I am trying to include another template file with pre-process's theme hook variables in a template file but it failed. I checked theme debug and it does not include example's pre-process theme hook. Can you give me guidance?

I added {% include 'example--p1.html.twig' %} in the page--front.html.twig file. The example--p1.html.twig file has one variable, {{ test }}. Also, I created a pre-process funct ...

Score: 3
TwoMice avatar
Custom module name conflicts with unsupported contrib module -- how to avoid "This project is no longer supported" warning?
pl flag

This Drupal 9 site runs a fork of the search_file_attachments module, modified for custom purposes, and for Drupal 9 compatibility.

For some time now, the Available updates report has shown, for this module, the warning "Project not supported: This project is no longer supported, and is no longer available for download. Disabling everything included by this project is strongly recommended!"

I inten ...

Score: 0
Commerce migrate and upgrade
cn flag

I'm going through the process of migrating from commerce 1 -> 2 and everything works from the product / order /payment perspective but I can't figure out how to re-map other content types that reference the old product node type.

This is my old structure

node -> node -> product review -> book -> product

New Structure node -> product review -> book

I have all of my migrations e ...

Score: 0
Adrained avatar
Webform entity reference view?
gb flag

I want to have a field to select a webforms within a paragraph using an entity reference field in the "Views: Filter by an entity reference view" reference mode, so that I can reduce the number of options particular authors see.

However, "webform" is not a valid selection when I go to create a view. I see "webform submissions" but not "webform." Is there a different webform submodule that I have  ...

Score: 0
Ivan Ginovski avatar
How to reset cache on a specific page by a given URL?
jp flag

In Drupal 7, I found a way to reset cache on a specific page with:

$url = url('<front>',  array('absolute' => TRUE));
cache_clear_all($url, 'cache_page');

What is the equivalent way in Drupal 9?

Score: 1
S.Gou avatar
Node edit form - Is it possible to load entity reference field data on click after the form has finished loading?
us flag

I have a custom node type (let's call it Project) with many fields. Three of these fields are of an Entity reference type, referencing other related nodes (let's call them Project Attachments A, B, and C).

There are sometimes hundreds of A, B, and C Project Attachments. This puts considerable load on the Project node edit form due to many DB queries being run, sometimes causing timeouts. I have a ...

Score: 1
user1470118 avatar
Programmatically add new fields to content type
jp flag

I have a custom module that has a form that allows the user to select various content types. I would like to create fields for those content types programmatically so that after the form is saved, it will add the fields for all of the content types that the user selected.

So my question is, is there a way to programmatically create fields and then save them to the content types? Any direction (tu ...

Score: 0
How to use a Controller method inside a service with dependency injection?
cn flag

I'm using the diff module for a project, this module has a method inside a Controller that I want to use in a service to reuse code. As this time I'm just calling the method like PluginRevisionController::getRevisionIds() but this give me the message:

Deprecated function: Non-static method Drupal\diff\Controller\PluginRevisionController::getRevisionIds() should not be called statically

So, I want  ...

Score: 3
Lurnobis avatar
Looping through child elements in Twig 2.10 without using if
na flag

Currently I need to loop through child elements in my Twig to render dynamic grids properly. I have achieved this by using code similar to this

{% for key, child in element if key|first != '#' %}
  <div>{{ child }}</div>
{% endfor %}

This works exactly how I am needing it to work. However in Twig 2.10 using an if inside of a for is now deprecated and it is now recommended to use eith ...

Score: 1
How can I get a rendered node field value with filters applied?
cn flag
blu

I'm trying to use a REST resource that accepts a node title and returns a JSON interpretation of a single field. This requires raw HTML that I can then use in DOMDocument. To get the rendered value of a node programmatically with filters applied I tried:

$field_value = $node->get('body')->getValue();

However this doesn't apply any of the filters such as converting newlines/carriage returns into

Score: 0
paulvc avatar
Unable to turn on alternative maps styles using Leafleat More Maps
bf flag

I'm trying to change the map style in a Drupal 10 site that I'm building locally.

I have installed and enable the 'Leaflet' and 'Leaflet More Maps' modules.

However when I navigate to the properties of the geofield in admin/structure/types/manage/property/display the 'Leaflet Map Tiles Layer' setting menu only shows OSM Mapnik as an option.

What steps am I missing?

Screenshots:

geofield properties

Leaflet More Maps settings

Score: 1
donbuche avatar
How to translate a link defined in javascript with Drupal.t()
cn flag

I have a template string that contains a link, which I want to translate afterwards throught the Drupal UI:

var html = `<p>${Drupal.t('<a href="/node/16">Check this out</a>')}</p>`

Two questions about that:

  1. What is the correct way to build links in JS that could be translatable, (both the anchor text and the href)?

  2. What should I do with these double quotes? Should I escape them? ...

Score: 0
zack cv avatar
How to get "user pictures in posts" to not be greyed out/ disabled?
eu flag

Setup: Drupal 9 with Claro admin theme and Olivero default theme.

Scenario: When I navigate to admin>appearance>settings>global settings, under the first section "page element display", the first two options ("user pictures in posts" and "user pictures in comments") are both selected but greyed out and unable to change. The second two options below are both selected as well but aren't greyed o ...

Score: 0
Fareed Fattal avatar
How can I dynamically change the default value for views exposed filter based on the terms weight?
mh flag

I have an exposed filter in a view is referencing taxonomy terms from specific vocabulary. The operator allows selecting a term as the default value for that filter. What I want to achieve is to dynamically select the default value when the term weight = 0.

This should allow less privileged roles like Content Contributors to set the default value for the exposed filter by changing the order (weig ...

Score: 1
How can I add term's vocabulary name as body class?
us flag

I already had following codes added, which adds term ID as body class. However, how can I change the ID to term's vocabulary name?

For example:

<body class="term-type-cameras">

/**
 * Implements template_preprocess_html().
 */
function MYTHEME_preprocess_html(&$variables) {
  if (\Drupal::routeMatch()->getRouteName() == 'entity.taxonomy_term.canonical') {
    // Load the term entity and ...
Score: 0
ringitupwiththedongtea avatar
Date filter not working with start date
cn flag

I wish to filter view for node type 'event' by start date > today, or alternatively by >= YYYY, if relative date is not possible. Neither is working. The view SQL see below doesn't apply the filter regardless. In the case of a relative date the filter isn't saved. I am using Date 7x-2.13 and Views 7.x-3.28.

What am I missing in the configuration? Or is this a bug?

enter image description here

enter image description he ...

Score: -1
lynxlynxlynx avatar
How to determine the cause of sudden "content encoding error"s for logged-in Drupal users?
hu flag

One day last week or so, seemingly out of the blue, logged in sessions started to throw content encoding errors. The site still works fine for anonymous users.

useless error

There's nothing in error_log, clearing caches and sessions didn't change anything and throttling the page loading speed shows it actually manages to draw the admin (and CiviCRM) toolbar and part of the page before giving up. The running PH ...

Score: 0
In views, how can I make unpublished comments invisible to users who do not have permission to view unpublished comments?
pe flag

I have a view that lists recent comments. Problem: If an unpublished/unapproved comment is on a published node, the comment is visible in the view even if the user looking at the view does not have permission to view unpublished comments.

I could filter all unapproved comments out of the view, but I want moderators to be able to see them.

How can I make the view respect the permission to view unpubl ...

Score: 2
tahaniau avatar
When does system_requirements function runs?
eh flag

When does Drupal call system_requirements(), which hardens permissions for files and for directories containing them?
Does Drupal call it in each cron run?

Score: 2
Joseph Scoggins avatar
How do I add a query condition to the QueryPluginBase in hook_views_query_alter()?
bd flag

Using hook_views_query_alter() for a view configured as a REST feed, I'm attempting to add an additional filter value to the query, based on the presence of multiple filters passed via the URL.

I need ensure a URL query like /my-feed/?field_my_term_target_id=2761,3101 returns content tagged with 836, for example, as well as the other two terms. So, figuratively speaking, my task is adding or field_my_ter ...

Score: 2
checking route access for authenticated role
by flag

I'm outputting a link, made using Url::fromRoute(). If the current user is anonymous, and the route is not accessible to them, I'd like to show a 'Log in to use this link' text instead, simular to what comment module does.

But I want to show that link only if logging in would actually allow that. So I want to check $url->access() for an authenticated user.

I've tried making a temporary user entity with ...

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.