Latest Drupal related questions

Score: -1
Ali Rizvi avatar
How do I port this event subscriber?
cn flag

The following code works fine with Drupal 9.


namespace Drupal\vl_login\EventSubscriber;

use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
// use Symfony\Component\EventDispatcher\Event;
use Drupal\Component\EventDispatcher\Event;

/**
 * Event subscriber subscribing to KernelEvents::R ...
Score: 0
Alternate Paragraph row output in paragraphs.html.twig - output index
US flag

How do I alternate output specifically in the twig template paragraph.[myfield].html.twig? Is there any way to return the row id of a Paragraph row? My goal is to achieve something like

IF row index = 1
Show div X
IF row index = 2
Show div Y
IF row index = 3
Show div Z

...but am unsure how the for loop would look.

paragraph.[myfield].html.twig:

{#
/**
 * @file
 * Default theme implementation to d ...
Score: 1
liquidcms avatar
Modal form opened from modal form doesn't submit
us flag

I have a user form mode (like node view mode except for forms) opened in a modal. When this form is submitted the user entity is updated and the modal is closed. This works fine. I now want to extend this where the user is updated, the modal is closed and a 2nd modal is opened with another custom form.

In my original AJAX response call I have simply added this:

  // Get the modal form using the form b ...
Score: 1
Can I use entityQuery() in a Drupal 10 site to query entities from a Drupal 7 database?
br flag

Can I use entityQuery() to query entities in a Drupal 7 table?

I know it's possible to change the active database and then use a dynamic query to access the database, but can I do that also with entityQuery(), or does it only work with the default database?

Score: 0
Jake13 avatar
How to set a webform default value for anonymous user?
us flag

I have been using hook form alter for a webform, to set a default value for a webform added as a block to a page. Below is the code, the code only works for users who have logged, but for anonymous or non logged in user the field is not working with a default value even with else condition or with anonymous check. what is wrong in the code below?

function mytheme_form_alter(&$form, \Drupal\Core ...
Score: 0
liquidcms avatar
How to place 2 blocks on same page which are based off page's rendered content?
us flag

To be honest, not sure of a good title for this. This is the issue:

I am using the TOC API to create a block. This API requires parsing the node content to determine the heading structure (H2s, H3s, etc). The module does not include a block for this as it is just an API module. I wrote a custom block to use the API to create this block. This works fine.

I now have a use case where I need to put multiple  ...

Score: 0
Brian McGovern avatar
Is a php filter available for Drupal 10.1.2?
bh flag

Its been a few years since I've used Drupal (pretty much missing version 9), but I'm coming back to it with 10.1.2. I'm hoping to get a PHP filter installed for content, as I historically like to use PHP to include dynamic contents from non-Drupal sources.

Unfortunately, chasing down how to do this has been leading me in circles most of the morning, from the original filter in the 6/7 timeframe t ...

Score: 0
Gary avatar
Group and Group content menu
sz flag

I'm trying to display menu from Group page. All is ok with the module Group content menu. But when I'm trying to display the same menu on a subpage of the Group, there is no menu as if the context is not passed and it don't know wich group menu to display. Do you know how can I make this? Maybe with a view but I don't know wich field to diplay ? I'm using Drupal 10.0.9 Thank you for your help I don't kn ...

Score: 0
Ali Rizvi avatar
Why don't these Composer dependencies allow upgrading to Drupal 10?
cn flag

I'm currently on Drupal Version 9.5.10, and I cannot update to Drupal 10 due to some depdendancy conflicts.

I updated my database, cleared cache, ran a cron. It doesn't fix.

How can I upgrade to Drupal 10 ? I am currently on Drupal 9.5.10

[root@vlstage22 master]# 
[root@vlstage22 master]# composer require drupal/core-recommended:10.1.1 drupal/core-composer-scaffold:10.1.1 drupal/core-project-message:10.1 ...
Score: 0
tinohuda avatar
How can I display @total in view display rest export in json format?
br flag

In a block or page display view i can put Result Summary @total in header. But in rest export display view does not use header plugins.

How can i get @total in rest export json format?

I have search in drupal.org and StackExchange, but no luck.

Is there a way to get @total Drupal 9?

Score: 0
jtjones avatar
How can I correctly use an if-condition along with a for-loop in Twig 3.x?
cn flag

The Upgrade Status module tells me this code is no longer valid for Drupal 10 but I'm not sure how that needs to be changed.

{% for paragraph in card_page.entity.field_paragraphs if not break %}
  {% set _paragraph = paragraph.entity %}
  {% set _paragraph_type = paragraph.entity.type.entity %}
  {% if _paragraph_type.id == 'landing_hero' %}
    {% set break = true %}
    {% set image_id = _paragra ...
Score: 0
Webform Create node, send email when webform is submitted
us flag

I'm creating a node when a webform is submitted and adding the webform submission id to an int field on the node so the node is linked to the webform submission. I'm also sending an email when the webform is submitted.

Here's the node creation handler code.

<?php

namespace Drupal\my_module\Plugin\WebformHandler;

use Drupal;
use Drupal\Core\Form\FormStateInterface;
use Drupal\node\Entity\Node;
use ...
Score: 2
Kevin avatar
Disable core path based breadcrumb only for the frontend theme
in flag

I want to disable path based breadcrumbs if the current route is not a registered admin route. The front end of the site is driven entirely by Menu Breadcrumb, but in some cases the URL path is generated dynamically with Pathauto based on a combination of field values. This results in sometimes the parent paths generated cause path based breadcrumb in core to return a breadcrumb when it should not (if  ...

Score: 0
Santam avatar
How to filter webform nodes with a contextual filter that restricts webforms to those which have not been answered
in flag

I have a webform node display page that shows webform nodes that are available to individual users. Individual user accounts have a field called Project which has a Project name. This allows users to be segregated into projects. The webform nodes also have a taxonomy field that allows the project to which these webform nodes will be assigned to. I have setup a view which shows the list of webform nodes  ...

Score: 0
Ben Alan avatar
All variables invisible to twig files
do flag

I created a theme whose minimal.theme file contains the following lines (among others).

/**
 * Implements hook_preprocess_HOOK() for node templates.
 */
function minimal_preprocess_node(&$variables) {
  // Declare the test variable and set its value.
  $variables['test_variable'] = 'Hello, this is a test variable!';
}

The following is the content of the template file.

{#
  This is a custom Twig ...
Score: 0
user42221 avatar
How can I search for existing nodes with "Text format" = "undefined"?
cl flag

I've upgraded to Drupal 10 from an earlier release, which used the PHP module (not yet available for Drupal 10). Therefore, I had to uninstall the PHP module before upgrading, leaving the "Text format" undefined for any node originally using that input filter.

How can I search for existing nodes with "Text format" = "undefined", so that I can fine-tune those?

(I have direct access to the database, a ...

Score: 1
David avatar
Can I populate a select form element with options in separate file?
sy flag

I have a text file which is a list of 100s of rows. Which I am trying to turn in to a select list.

I have created a module, in mymodule/src/form/mymoduleform.php. I am trying to load the items from the file and turn the file content into an array which can be used as options for the form element.

The form element is created by the following code.

$form['mymodule_select'] = [
  '#type' => 'sele ...
Score: 1
jreinholdt avatar
Help with migration needed - entity_lookup of multiple taxonomy references
ke flag

I am trying to fetch nodes with multiple taxonomy references from Drupal 9 instance A to instance B. B already has the vocabulary terms, so i want to use entity_lookup in the process for this field to get the correct ids on B. The vocabularies on A and B have slightly different names (A: 'schulstufe' B: 'schulstufen')

My YAML:

item_selector: data/
source:
  fields:
    -
      name: school_levels
     ...
Score: -1
D10 avatar
View with reference entity type
tz flag
D10

I have a View entity reference type and I want to get the fields along with fields I m using relationship Field to cal referenced type entities

I have content type with name product Field 1: title Field 2: description Field 3: listing & it's a paragraph entity refenced field

I created a View and called fiels But Field 3 contain multiple fields

But saw the title & description fields repeated num ...

Score: 0
micbay avatar
How can I pass existing variables to a custom module template?
ua flag

I'm having trouble working out how to pull existing variables into my custom module TWIG template.

I can create my own variables and pass them, but do not know how to expose variables that already exist from the theme or other entities and then pass them to the template in my custom module.

I'm working in Drupal 10, and my general goal is to create a custom module that will build a custom landing pa ...

Score: 0
Kevin avatar
Custom field type that has an array property won't save unless serialized, otherwise get "This value should be of the correct primitive type" error
in flag

I have a custom field type with two properties I am storing on it. One stores a string. The other I want to store an array. The array should be serialized in the field value table of the database, but it should be an array when exported to YAML (default value setting of the field instance configuration).

I am having trouble getting this to work. In my head it would be similar to 'allowed formats' ...

Score: 0
Jeffrey1862 avatar
GET /sites/default/files/js/js_xxxxxx.js - No such file or directory
gi flag

This is my first post, I just started to learn and use Drupal, and I wish to install a fresh new site on my local Windows machine using composer. The issue is that it has a file not found error from the path "/sites/default/files/js/js_xxxx.js", I have searched through some forums and some of the users said that it is related to permission, but in my case, the file doesn't even exist in the directory. T ...

Score: 0
Sevenfish avatar
How can I choose an attribute?
us flag

A product has Size and Pickup Location as attributes; Size can be S, M, L, and XL, while Pickup Location gives 10 choices.

The Pickup Location value does not affect the product price; that is only influenced by Inventory and Size.

When a product is created, I have to create 40 variations, even though the price changes only when Size has a different value. The Pickup Location value is just shown as refe ...

Score: 0
GeorgeCiesinski avatar
How do I aggregate the number of posts for each selection of a specific field?
mv flag

Background

I have a custom content type "Change Request" that has an "Urgency" field which is a list with three options to choose from:

  • Low (3 or more days)
  • Medium (Less than 3 days)
  • High (Emergency)

I created four change requests with sample data and tried to create a view with an unformatted list that shows how many change requests there are with each selection.

When I try to create this view, the re ...

Score: 0
AlastairHoward avatar
Changing order of execution of hook_preprocess_html
ru flag

I have 2 custom modules in Drupal 9, let's called them module A and module B.

Each module has a fully working hook_preprocess_html function defined in the .module file. The hook_preprocess_html function in module A runs first, followed by the function in module B.

How can I update Module A so the hook_preprocess_html function in there runs after the one in module B?

I have tried to implement hook_modu ...

Score: 1
CocoSkin avatar
The website encountered an unexpected error after the media module was uninstalled. The "media" entity type does not exist
cn flag

This is a Drupal 9.5.10. After uninstalling the Media module. The website encountered an unexpected error. The error message only shows a little information, as I know. It mentioned the "media" entity type does not exist.

The website does not have the Media Entity module. Of course, the Media module and Media types(audio, document, image, remote video, and video) should not be there because I jus ...

Score: 0
user3891775 avatar
Adding role to a user after login - after simplesamlphp/externalauth
mx flag

Adding more context to my question

here is the scenario: a) the organization has different departments b) actual Drupal roles are not assigned through simplesaml role attribute but through simplesaml attribute: IsUnit_A => value: yes or no c) all members of UnitA >> 'isUnit_A=yes', get 'unitA' role; which is assigned through suggestion #1 of the below answer "Assign them via the module's co ...

Score: 0
Ricardo Castañeda avatar
Condition that deletes rows older than 30 days
at flag

How can I query a condition that deletes the rows with column Date older than the last 30 days in DBTNG format?

I have tried this, but it's wrong.

$connection = \Drupal::database();
$connection->delete('my_table')
    ->condition('Date', now() . ' - INTERVAL 30 day', '>');
$connection->execute();

Screenshot of table with nid and Date columns

Score: -1
user3480098 avatar
Custom module routing is going to page not found
in flag

I have a custom module that i'd like to display my webform on a certain page but it keeps sending me to a 'Page not found'.

folder structure is;

modules/custom/custom_webform_display
-custom_webform_display.info.yml
-custom_webform_display.module
-custom_webform_display.routing.yml
--src
---Controller
----CustomWebformDisplayController.php
--templates
---custom-webform-display-page.html.twig

info.yml

 ...
Score: 0
GeorgeCiesinski avatar
Why is my pie chart showing multiple labels and incorrect count?
mv flag

Background

I have a site where users can submit change requests. I created a custom content type "Change Request" which has numerous fields in it, some of which I want to generate charts for.

One of these fields is a list called "urgency" which includes the options "Low", "Medium" and "High". Only one option can be selected per change request.

Goal

I created 4 change requests with sample data which I am  ...

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.