Latest Drupal related questions

Score: 0
Why is the Cache-Control always "no-cache" and "X-Drupal-Dynamic-Cache" UNCACHEABLE on this site?
kn flag

I have a production website for quite a long time now. By digging, we found that the Cache-Control was always to "no-cache" and "X-Drupal-Dynamic-Cache" is UNCACHEABLE

enter image description here

My settings.prod.php look like this

# ================================================================
# Performance settings
# ================================================================
$config['system.logging']['error_level'] = ER ...
Score: 1
How to use bundle classes with config entities (vocabularies)?
ru flag

I'd like to use bundle classes with taxonomy vocabularies. Vocabularies are bundleable config entities inheriting from EntityBase just like nodes, term and other content entities. The doc states bundle classes should work with all entities that are a subclass of the base entity class, but I can't get it to work with config entities.

works:

// in my module file
function foo_entity_bundle_info_alter(& ...
Score: 0
How can I prevent a specific node type from caching for anonymous users (when using hook_node_access)?
bv flag

I am using hook_node_access to decide the whether a node should be visible to anonymous users based on their IP address. To prevent this being cached I am using \Drupal::service('page_cache_kill_switch')->trigger() within hook_node_view_alter, but if access is forbidden then hook_node_view_alter is not run and so the cache is not killed.

Where should I put \Drupal::service('page_cache_kill_switc ...

Score: 0
Counting by rewritten element
kn flag

In my view, I'd like to group my row by values.

The initial data look like this.

enter image description here

In the field configuration in the view, I rewrite each value like this {{ field__value |split('-')[2] }} to get only the last part (CB, VISA...).

How do I group each row by the rewritten value? The idea would be to have this.

enter image description here

Score: 0
Aurora avatar
Contrib module service overriding not working
cn flag

I am using the ‘Path Redirect Import module along with the Redirect module. I am trying to override its service ‘path_redirect_import.importer’ To do this, I have added a service provider and a custom class that extends the service class that I want to override. however, the overridden function is not getting called. Followed this tutorial:

Any suggestions?

  1. inside my custom module's src folder, I ...

Score: 0
Hometoy avatar
View connection info from Webforms to SMTP
in flag

I have a Drupal 8 site with webforms and the site is configured to use our Office 365 for mail.

The site's SMTP settings are right because I have been getting auto-generated emails about out-of-date modules.

The webform fails to send, with the meat of the error message:

SMTP Error: data not accepted.SMTP server error: DATA END command failed Detail: TenantAttribution; Relay Access Denied [ValidationStatu ...
Score: 0
Geat avatar
How do I add cusom settings for the "Rendered entity" view mode?
de flag

When using the "Rendered entity" field formatter for an entity display, there's a dropdown where you can select the View mode.

Is there a way (programmatically or otherwise) to add settings to a particular view mode? I want to add a checkbox that will display or hide a particular section of the rendered output.

I know I could create another view mode, but that does seem overkill for something that's ...

Score: 1
Drupal root not found on multisite setup after upgrading Drush 10 to 11/12
br flag

This is a (25 sites) multisite setup running smoothly on Drupal 9.4 with Drush 10.x still. Upgrading to Drupal 10.1.x and Drush 11 or 12 however makes Drush unusable.

Dir layout as installed by drupal/core-recommended:

/var/www/projectroot/
├── composer.json
├── composer.lock
├── config
│   └── mysite.com
├── vendor
│   ├── asm89
│   │   └── st ...
Score: 0
ChumKui avatar
Can I set default access settings?
mx flag

The Webform module defaults to allowing anonymous and authenticated users to submit a form.

The vast majority of the webforms we use are for internal staff that have a particular Drupal role.

Is there a setting for defaulting to a particular role/roles when creating a new form? There seems to be for everything else.

We are using Drupal 9.5.x and Webform 6.1.x.

Score: 0
Aambro avatar
How to prevent empty field wrapper from rendering in views
cn flag

In views I display fields for specific content types. One field is referenced to taxonomy term. Not every node has the term reference. I need to style this field with paddings and colours so I would want it not to be rendered at all if term reference is missing. I have chosen under "no result behaviour" in field settings in views to "hide if empty" and "hide rewriting if empty". However, the two divs st ...

Score: 0
Book child title containing html tags is escaped
it flag
MMT

I have a Drupal 7.97 with a book e.g. node 1 that has three children nodes of e.g. nodes 2,3,4. In one of the children nodes title e.g. node 3 title I'm using an simple html tag:

Node 3 sample title <em style="color:blue;">highlighted text</em>

All the nodes are of type book page.

When displaying the page site.com/node/3 everything is fine, the html title is stripped of the tag as it should  ...

Score: 0
Ricardo Castañeda avatar
DBTNG sentence that sums a column from all rows of a specific user and dpm the total
at flag

This is my table test_sum_expression with columns:

uid (int) Stores the UID of the user.
points (int) Stores a number.

enter image description here

I have this SQL sentence which SUMS all points from user with uid 1.

SELECT uid, SUM(points) AS total_points 
FROM `test_sum_expression` 
WHERE uid = 1
GROUP BY UID;

Which produces
enter image description here

How can I produce this same sentence in DBTNG (Database: The Next Generation) format? I mean somethi ...

Score: 0
Eluchel avatar
How do I get a media entity image's url/src in a block twig file?
so flag

I have a custom block type that has a media entity field that is an image. I want to extract that image url and set it as a div background image in the html.twig file, but I can't get it to work. The twig file is block--inline-block--hero-w-title.html.twig If I do

{{ content.field_hero_image[0] }}

it will display the rendered image with all the divs and stuff, but I can't figure out how to get the imag ...

Score: 0
Tyler avatar
Updated Google Analytics breaks website
de flag

I uninstalled the Google Analytics module and installed a newer version for Drupal 8. Now the website crashes with this exception error.

Uncaught PHP Exception Symfony\Component\Routing\Exception\RouteNotFoundException: "Route "view.google_analytics_summary.page_1" does not exist." at /opt/drupal/web/core/lib/Drupal/Core/Routing/RouteProvider.php line 208

I have no idea how to fix this since I can' ...

Score: 0
Ricardo Castañeda avatar
Database addExpression SUM: Call to a member function execute() on string
at flag

I need to get the sum of all points values of the user with uid 1 from the test_sum_expression table. But when I try to execute I get this message Error: Call to a member function execute() on string.

If I don't execute, I get the count 6 of the word points, as if it were counting the characters from the string points.
enter image description here

$queryPoints = $connection->select('test_sum_expression', 'n')
    ->fields('n' ...
Score: 1
Mike Burman avatar
Is Drupal Commerce compatible with Drupal 10?
us flag

Don't see this answered anywhere. I have Drupal 10 installed, as a dev site cohabiting with a live Drupal 7 on the same server. I don't use composer for the D7 install, but can't get it to work on the D10 install since the "php.composer.phar" (in an attempt to make modules installs and updates) command jumps to server root over which I have no control & can't update. If commerce isn't compatible ma ...

Score: 0
Basil Vlasyuk avatar
Using Geofield, how do I create links that would center the map on required point?
pk flag

This appears to me as a rather basic requirement, but surprisingly enough, I can find no information on how this can be done.

You know how when you search something on Google maps, apart from just a map with points on it, you are also given a list of those points on the left side, and you can choose any of the names, click on it, and the map will get centered on this point?

So I have a few hundreds  ...

Score: 0
Alex Sh avatar
Migrating content from production to development
de flag

I have a multilingual site built on the Glazed Drupal CMS installation profile (Drupal 8).

It was upgraded to Drupal 9, but the upgrading process lasted around 3 months, and now new content from the production site (Drupal 8.9) needs to me be migrated to the new Drupal 9 site.

I can't just use the production site database - it was a lot of changes when switching from Glazed CMS to DXPR and these ch ...

Score: 0
CKeditor 5 generic block level styles
ru flag

Is it possible to define generic block level styles in CKeditor5, instead of targeting a specific HTML tag?

E.g. I can define this in editor.full_html.twig

settings:
  plugins:
    ckeditor5_style:
      styles:
        -
          label: 'looks like header 1'
          element: '<p class="h1">'
        -
          label: 'looks like header 2'
          element: '<p class="h2">'

But with this ...

Score: 1
steven avatar
How can I copy a field to another field?
br flag

I have an Article content type for which I want to change the machine name of its fields. I created new fields with a different machine name.

How do I copy the old fields to the new fields?

Score: 5
Cedric Lenders avatar
Prioritise condition in QueryInterface
ky flag

I have an overview with a search field. The query should search on both the title and description, but I would want to show my results that have the search parameter in the title first in the list. I am using a QueryInterface and have following condition group

 $group = $query->orConditionGroup();
 $group->condition('title', "%" . $searchString . "%", 'LIKE');
 $group->condition('field_des ...
Score: 0
Giuseppe avatar
How can I combine filter values?
br flag

I'm on D9.5.x.

I'm styling the default Glossary view. It works, but on the site some of the node titles start with a character that is not alphabetic, for example - My awesome title - or @ My Work. Therefore, the exposed title filter shows the alphabetic and non-alphabetic characters.

Instead of an option for each of the non-alphabetic characters, I would need to show a single option, for example # ...

Score: 0
Ajay Reddy avatar
How to add Rules "Context variables" based on node fields?
ge flag

I am doing a Data comparison in rules condition. But while adding "Context variables -> Data Selectors", I am unable to add node fields like "node.ABC.value" or "node.ABC". It's throwing errors like Data selector "node.ABC" for context Data to compare is invalid. Any suggestions?

Score: 2
bacteriaman avatar
Deleting entities using Batch API without a form or user interface
us flag

In a custom Drupal 9 module, I need to delete entities using Batch API without a form or user interface. The list of entity IDs are generated and the batch is built in hook_views_post_execute(). When the View path is accessed, I can confirm the batch is successfully created by noting the new record in the "batch" database table. However, the batch is never processed and none of the entities are deleted. ...

Score: 0
somo avatar
How to know how many nodes my website has?
vu flag

In /admin/content no specific number of nodes is available.

How to know how many nodes my website has, preferably without installing a module?

I want to know how many nodes I have in general, not of a specific content type.

  • I didn't find any native Drush command.
  • I personally would prefer Bash or JavaScript over PHP to count if I can.
Score: 0
EvilArgest avatar
Solr autocomplete does not work for Product Variations
uz flag

I am trying to create a sitewide search using Solr. For this, I indexed Product Variations and Content entities as Rendered HTML Output. When I try to search for a content entity, the autocomplete works and gives me the results, but it fails to give the results for Product Variations. The search itself works both for Content and Commerce entities. I am using Search API Solr with version 4.2 and Search A ...

Score: 0
monster_energy avatar
How do I add new fields to the sitemap.xml file generated by the XML Sitemap module?
mp flag

Is there a way to add extra fields to the sitemap.xml file created by the XML Sitemap module?

By default, it has these fields: URL, last modification date, change frequency, and priority. I'd like to add language, as I'd like to have one sitemap.xml file and not one file per language.

Score: 0
Zatigem avatar
How can I change the label of the title field "Name" of my taxonomy?
gr flag

I want to customize the title label of my taxonomy, the name field. By default, its value is "Name".

I know I can use the mymodule_form_alter hook and do as followed:

$form['title']['widget'][0]['#title'] = t('My Custom Name'); 

But I want to do it in the UI and export the configurations like any other fields. Also, I want to be able to translate my custom name.

Score: 1
seventh_sniper avatar
How to access the node/term field-values in a cleaner way?
ph flag

My code is filled with methods like these to access field values:

\Drupal::entityTypeManager()->getStorage('node')->get('field_name')->getValue()[0]['value'];
\Drupal\taxonomy\Entity\Term::load($tid)->get('field_name')->getValue()[0]['value'];
\Drupal::routeMatch()->getParameter('node')->get('field_name')->getValue()[0]['value'];
\Drupal::routeMatch()->getParameter('node' ...
Score: 3
seventh_sniper avatar
Is there a way to sync file naming across environments?
ph flag

I have 3 environments with version control. Dev, staging and production.

Now, say I create a new node in staging and create a corresponding file with the name: page--node--28.html.twig

On production environment users keep posting articles, so it will already have a node 28 which messes up the version control.

Is there any way to manage this seamlessly.

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.