Latest Drupal related questions

Score: -2
razor avatar
Errors Thrown by Composer and Drupal Core
us flag

I'm working as a part of a development team where my colleagues (team members) work in separate Git branches created out of and then merging their branches into a common development branch, develop.

After fetching, checking out and pulling the latest changes in one of their branches and clearing the cache using Drush, I get the below errors in Git bash. These errors also started appearing when I visited ...

Score: 0
somasundaram avatar
How can I add drupalSettings values with the #attached array?
fo flag

In D7, we have used drupal_add_js with DrupalSettings for accessing php variables to javascript files, for that we have used in D7 in my custom function like below

function custom_function($data)
{
   drupal_add_js(array('test_ajax_responders' => $data), 'setting');
}

But for D9, we need to use #attached property to replace this, but how i need to pass this $data related in to $attachments. Seems t ...

Score: 0
Anwar avatar
Unable to admin login due to CAPTCHA validation error: unknown CAPTCHA session ID. Contact the site administrator if this problem persists
iq flag

When I try to admin login, I'm getting following error. Screencap attached. Is it possible to disable google recaptcha from database? enter image description here

Score: -4
Surya kiran avatar
Can I use the Devel Generate module?
pr flag

I have content type with the Product ID, Name, Image, Description, Category, and Price fields.

Will the Devel Generate module create sample products?

I have tried using it, but it generates some data which is not related to this, some random images, and data that is not in English.

Score: 3
BlondeSwan avatar
Why are CSRF Tokens not required on these REST Web Services endpoints?
br flag

I am using the miniOrange API Authentication module to handle API Key Authorization for my custom Rest Endpoints built by extending the REST Web Services module.

I notice that my POST and PATCH methods work perfectly fine without a CSRF token provided by the /session/token endpoint. Does API Key Authorization remove the need for CSRF tokens or why am I able to make successful POST/PATCH requests w ...

Score: 0
Altering paragraph field within revision using preprocess hook
dk flag

I'm using a hook_preprocess function (hook_preprocess_entity_print) to alter the content within a paragraph field prior to rendering (replacing some strings based on a regex). This works great when I'm working on the node, but not when I'm trying to do the same on a revision of the node.

This works for the node:

/**
 * Implements hook_preprocess_entity_print().
 */
function mymodule_preprocess_enti ...
Score: 0
Dodoto avatar
How to import unknown number of images with drupal feeds from xml file?
bl flag

I am trying to import a gallery of images for a specific content type. The XML file looks like this:

 <img1>
 https://xml.....
 </img1>
 <img2>
 https://xml.....
 </img2>
 <img3>
 https://xml.....
 </img3>
 <img4>
 https://xml.....
 </img4>
 <img5>
 https://xml.....
 </img5>

The node has a different and unknown number of images. I'm using Que ...

Score: 1
haidar avatar
Why does core create RSS feeds for taxonomy terms?
az flag

Drupal 9.5.8 standard installation; I never did anything about RSS feeds in that website.

In Google Search Console, under Crawled - currently not indexed section, I was surprised to come across this webpage:

example.com/taxonomy/term/NUMBER/feed

In /admin/modules I read that the (deprecated) module Aggregator isn't on, and I don't recall ever turning it on.

What may cause the RSS feed webpage to be cr ...

Score: 1
Chris avatar
How to output file upload date (of a file field) in a JSON-view?
bl flag

I have rest_export view to generate json output of nodes. I'm trying to output a the upload date of files in a multivalue filefield, but can't find a solution. I tried to use the "rewrite results" option of the filefield in the view using twig as follows:

{% for item in field_myfiles %} {{ item.entity.timestamp|date("Y-m-d H:i:s") }} {% endfor %}

But it just does not work. Any hints how to achieve t ...

Score: 0
pvh avatar
Embedded images are not working in CKEditor 5
kr flag
pvh

While migrating CKEditor 4 to 5, images added through entity embed ( E ) option in CKEditor 4 is not appearing after switching to CKEditor 5. Any idea how to make it work in CKEditor 5?

in CKEditor 4

in CKEditor 4 In CKEditor 5

in CKEditor 5

The image added in CKEditor 4 is disappearing after swithing to CKEditor 5 as in ckeditor 5 entity embed is not there and using drupal media.

Score: 1
phpcs: How to ignore Drupal's 80 char line length limit
ru flag

I want to use PHP CodeSniffer with the default Drupal and DrupalPractice rulesets to check my custom modules. But I definitly don't want the 80 char line length limit, and phpcs is spamming the report with those warnings. I've created a phpcs.xml in my project root (taken from this blog)

<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="my_drupal10_phpcs_configuration">

  <rule r ...
Score: 2
Adamssef avatar
Using Drupal's Core classes as services
in flag

I have rather a general question that would help me to undestand using services in Drupal 8+ and when it is worth to do so.

I have found a useful method createFromRoute which is part of

namespace Drupal\Core;

It is defined in Link.php file.

I have found plethora of examples in code when it is just called like this

Link::createFromRoute(... parameters here)

But, is calling this method like that a  ...

Score: 0
haidar avatar
How to know what installed modules are contrib modules from the GUI?
az flag

I wish to remove all contrib modules so I could upgrade my core from version 9 to version 10.

I have installed several contrib modules, some time has passed and my problem is that for some modules, I may not recall if they are contrib or core, when looking at example.com/admin/modules/uninstall.

How to know what installed modules are contrib modules from the GUI?
If this can't be done from GUI so I gue ...

Score: 1
Patoshi パトシ avatar
Using REST API services to create content with field entity references that do not yet exist
kr flag

I'm using Drupal 9.4 and trying to create content via the REST API web services where one of the field's in this content is a reference to a taxonomy term that doesn't exists until the current node is created.

My goal is to import content that looks like a multi paged forum thread with the 1st page being the "parent" of the group. This special field I call: "Parent Page" which is a entity referen ...

Score: -1
Free Radical avatar
How to learn the context for using methods provided by the Drupal API
kz flag

I am trying to use the code example provided by this accepted answer – and failing. In this particular case it seems that it is necessary to know two things in order to successfully use this code, that is not included in the answer:

  • The parent class to declare for my class in order to make the method provided by Drupal available.
  • The "use" statement(s) required that make my class load this parent class ...
Score: 1
Ricardo Castañeda avatar
Configure the visibility permissions of single specific block inside Context (not using reaction)
at flag

I have a question about Context module and Block permissions.

The project has a context with a reaction that adds blocks. There are many blocks. I want to hide a single block for anonymous users.

My question is, can I configure individually the visibility permissions of the block?

I know that I can configure the context by a condition that does what I require, but this context have multiple URL, a ...

Score: 1
Free Radical avatar
How to use dependency injection to load node data?
kz flag

In a basic Controller class, I tried to load node data using the code from this accepted answer. I.e:

$nid = 1;
$node_storage = $this->entityTypeManager()->getStorage('node');
$node = $node_storage->load($nid);

However, this answer does not have sufficient detail to help me. Just putting it inside my very simple controller class, I get a WSOD with this error:

Error: Call to undefined method Dru ...

Score: 1
Modify text for inserted link with CKEditor Linkit plugin
za flag

I would like to modify text that is being converted to a link within CKEditor, using the Linkit plugin. Eg. When linking to a Media Document, append the file type and size.

I am using hook_form_editor_link_dialog_alter in order to modify the dialog form and capture and populate additional attributes on the resulting a element. But there does not appear to be a field for modifying the text.

I tried to s ...

Score: 1
Jahid avatar
How can I add a CSS class to a #type table render element?
br flag

I was trying to add a custom classname to the table in my custom module. But for some reason it's not working (Drupal 9). I can not get the table class name added into the HTML. Any help would be appreciated.

Edit: I was following this post below, but no luck. Add a class to a Drupal table cell containing ['data']

    '#type' => 'table',
    '#attributes' => [
       'class' => ['table-class ...
Score: 1
MarkDQ avatar
TypeError: realpath() PublicStream.php
uy flag

After installation of Drupal9 recommended project (using composer), I had this error on the homepage:

TypeError: realpath(): Argument #1 ($path) must be of type string, array given in realpath() (line 133 of core/lib/Drupal/Core/StreamWrapper/PublicStream.php).

I changed PHP 8.1 to 7.4, the error disappeared, but [website]/admin returned "no access rights to this page"

composer.json in project root:

 ...
Score: 1
AppLEaDaY avatar
Only webform administrators are allowed to access this page and create new submissions
br flag

I first realized unprivileged users couldn't access webforms and I made a support request elsewhere for that, as suggested. Only today I noticed an administrator sees the form and above it an info box that says Only webform administrators are allowed to access this page and create new submissions.

Please consider I get the mentioned message both with webforms built before the upgrade of Drupal and t ...

Score: 1
mbomb007 avatar
Can a view be accessed if there's no page or block?
nl flag

The following question may seem contrived, but I have custom access controls besides roles and permissions, so I can place view blocks on pages that are viewable by users in a list, for example.

If I create a view with a default and a block display that has "role: authenticated" access requirement, then I place the block on a page only admins can see, is there a way for regular "authenticated" us ...

Score: 1
Find content with missing entity reference
za flag

I have nodes that have embedded Media (images) and also links to other content (nodes and media). Through hooks I populate custom fields to store those references, this is a multi-value entity reference. Also, since the entity reference is an int, the default filter is equals, between, less or greater, etc - 'not in' is not even possible via the UI.

What I would like to do is create a View that ...

Score: 0
user agent avatar
Webform get submission details after or during submission
eg flag

How can I access the form data during or after submission?

Am using Webform REST for the submission of forms, but I don't seem to be able to retrieve the form data.

For now, I tried the following which gives me empty results:

function module_webform_submission_form_alter(array &$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  \Drupal::logger("module.webform.data")->notice(jso ...
Score: 1
How to invalidate custom block which use Cache Tags and Cache contexts for authenticated user?
pe flag

I'm working on an application where authenticated user data mostly comes from an API. Performance is significantly better since I'm using the API cache. Before, to be sure to have up-to-date information, I used '#cache' => ['max-age' => 0,] but it's really not ideal.

I have a question, however, about the custom block cache for authenticated users.

If I add user context and tag it works fine ...

Score: -2
MrSnrub avatar
Is there a way to allow entering a value in a node's field if inserting a new node, but make the field disabled if updating that same node?
in flag

I'm using Drupal 7 and I have a standard text field in my Content Type. If the user with role "Standard User" is adding a new node then they should be able to set the Status field text value. However, if the node is already created and they are editing/updating that same node, it should be grayed-out (disabled). Is there a way to do this?

Score: 0
Giuseppe avatar
Why sensitive information Webform information exposed with jsonapi and custom access check?
br flag

I'm on D9.3.x with Webform 6.1.4. Some sensitive information is exposed when adding a custom access check on webform submissions.

E.g. with no custom code, when GETting jsonapi/webform_submission/my_webform without right permissions the site returns:

    "jsonapi": {
        "version": "1.0",
        "meta": {
            "links": {
                "self": {
                    "href": "http://json ...
Score: 0
Farhan Erooth avatar
Node template suggestion based on date field
ng flag

I am trying to get different templates for events node based on the date of the event. The content type used will be same for both, ie. Event.

This is what I have done so far:
Created a content type: Event
Added a date range field: field_date

This is what I need to get:
If the date of the event is greater than the current date, template suggestion will be node--upcoming.html.twig
If the date of the ...

Score: -3
João Soares avatar
Trying to set drush
mg flag

First, I installed Lando which also installs Docker Desktop. After installing Lando, I opened the Windows Terminal and created a folder called "Sites". Inside the "Sites" folder, I created another folder named "my-first-drupal10-app". Then, I navigated to the "my-first-drupal10-app" folder and executed the following command: lando init --source cwd --recipe drupal10 --webroot web --name my-first-d ...

Score: -2
Владимир Помелов avatar
How do I remove duplicate taxonomy field values in the paragraph display mode template?

How to remove duplicate values in this code, if they are in "{{ post.entity.name.value }}"?

{% block paragraph %}{% block content %}

    {% for post in paragraph.field_post %}
        {% if loop.last %}
            {% set separator = '' %}
        {% else %}
            {% set separator = ',' %}
        {% endif %}
        {{ post.entity.name.value }}{{ separator }}
    {% endfor %}
    
{% endblo ...

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.