Latest Drupal related questions

Score: 0
Quetzcodecoatl avatar
Trying to filter the results of the entity autocomplete form element
tw flag

Currently, I am working on a module that offers the function for users that belong to specific user roles to be able to write private messages to each other.

In order for the sender to be able to add a recipient to his message, I used Drupal's EntityAutocomplete class and as the #target_type I chose user so that the sender gets to choose his recipient(s) from an automatically generated list of use ...

Score: 1
Pixelstyle avatar
Always charge the most expensive flat rate shipping in an order
vn flag

I have a Drupal Commerce site with two product types. One has free shipping, and the other costs € 3,-. When both products are in the cart, the customer is allowed to choose either of those rates, which is not what I want.

I want to disable the free shipping rate when the second product type is in the shopping cart. On shipping calculation the most expensive shipping should be calculated.

In shipp ...

Score: -2
New Dev avatar
Get MenuLinkContent object values
np flag

get title and link of a menu link object in. I am trying to get title and link of a MenuLinkContent object and below is my code. I want to get title and link value. How I can get the title and Link url without foreach. something like- menu_content[]->title and menu_content[]->link

Defined name spaces

use Drupal\menu_link_content\Plugin\Menu;
use Drupal\menu_link_content\Entity\MenuLinkContent;
 ...
Score: 0
Zoness avatar
How to add an attribute to a paragraph button link?
hk flag

I'm trying to reach a variable with the html attributes of a link in a twig file, which is used for a paragraph link.

If I dump the button content, I can't dump anything past the object array.

{{ dump(buttoncontent['#object'] }}

How can I reach whatever variable is storing the attributes and manipulate them?

Score: 0
Mark avatar
How can I ensure that the Webform module always send emails in the same language as the original submission?
cn flag
  • I have a webform in English, translated into German.
  • I have webform email handlers in English, also translated into German.
  • Different emails are sent based on submission completion, update, and lock.
  • If a user submits the webform while using the site in German, he rightly gets an email in German. GOOD.
  • However, if an admin updates or locks the same submission while using the site in English, the origi ...
Score: 0
Sleepster avatar
How do I display the title of the entities to which the user has no access?
us flag

I created a new content type with entity references to standard pages. I am using the Taxonomy Access Control module to control the access to these pages.

When users view a node of that content type, they unfortunately do not see page titles for which they do not have access (the title is a teaser). I want all entities to be listed (with the links to the pages), even if the users do not have access to a ...

Score: 0
Mink unable to connect to chromedriver
ai flag

I need help from someone who knows about testing web pages with Javascript in Docker containers. I have browser-based testing working and now I have scenarios which don't work without Javascript, so I'm trying to follow the Drupal documentation for running PHPUnit Javascript tests. The problem is that I'm getting

An unexpected error occurred while starting Mink: unknown error: net::ERR_CONNECTION_REFUSED
 ...
Score: 0
How do I programmatically provide an exposed filter value to a view?
in flag

I am validating the creation of a new node in code thus $form['#entity_builders'][] = '_my_node_builder;

In this validation code I would like to check that my_view returns no results when its exposed filter is provided with a string.

In the code at _my_node_builder

  1. how do invoke the view programmatically?
  2. ... providing the view with the exposed filter string?
  3. how do I check the cardinality of the v ...
Score: 0
Darren Whittenham-Gray avatar
Should I "composerize" my installation?
fr flag

So; having been involved with a D7 / CiviCRM build a number of years ago, I started building a D10/CiviCRM build as a project to suggest to my local organisation.

I think I might have caused myself an issue though, as I installed D10 manually, then went on to install CiviCRM using composer.

  • I have D10 installed on my VPS at /var/www/html/[site]
  • I have CiviCRM installed at /home/[user]/

So the questio ...

Score: -1
Argument #1 ($config_factory) must be of type Drupal\Core\Config\ConfigFactoryInterface, array given
cn flag

I'm writing a new module for the community and I have this error and I'm not understand what's going on.

The error:

Mensaje TypeError: Drupal\view_mode_by_owner_role\Functors\ListOfNodeBundles::__construct(): Argument #1 ($config_factory) must be of type Drupal\Core\Config\ConfigFactoryInterface, array given, called in /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.ph ...

Score: 0
JohnC95 avatar
Creating a Custom Content Listing Page based on specific content type or taxonomy terms selected in the node
mc flag

I am trying to create a content type that generates a list of content/nodes based on other content type or taxonomy terms selected within that node in the content type. I have a general content type for Articles and those are tagged with a taxonomy vocabulary for "Category".

This is within Drupal 9.

What I've done so far:

Create a new content type named "Custom List"

Add a field for an entity refer ...

Score: 0
shibasaki_stack avatar
When a custom form is displayed in a custom template, ajax does not work
zm flag

What I want to do

I want to display a custom form with a custom template and use ajax in it to change values in the form.

Problem

Custom template notation prevents ajax from working. I didn't change anything in php, just twig, and tried 2 patterns as shown below. In twig1, when I changed the value of "a", the value of "b" became "hogehoge" and the log was output. However, in twig2, the value of b w ...

Score: 1
user110018 avatar
Why is the service “@url_helper” not found?
tr flag

I am trying to add the query string with the each URL access through the browser. To accomplish it, trying to implement that through the service. But getting no solution in Drupal 9.

mymodule.services.yml:

    services:
      weplant.userlibraryurl:
      class: Drupal\weplant\EventSubscriber\UserLibrarySubscriber    
      arguments: ['@url_helper', '@request_stack']
      tags:
        - { name: eve ...
Score: 0
davidp avatar
Trying to sort rows by a column in views twig template
id flag

I'm trying to sort the rows of a view in the table template but can't figure out how to sort by a particular column. I can only get it to sort by the first column. I'm trying to sort a views global conditional field so I can't use views query alter. Here's the code that sorts by the first column. I've tried various arrow functions without any luck.((a, b) => a.row.column <=> b.row.column).

 ...
Score: 0
xpersonas avatar
Can't Place Custom Block in BrowserTestBase
cn flag

I'm trying to set up a test for my custom module. But I can't seem to place my custom block. I can place system blocks just fine. So I don't know if there's something special with a block I make in my custom module.

If I try a system block, it's fine...
$this->drupalPlaceBlock('system_powered_by_block');

If i try my block, not so much...
$this->drupalPlaceBlock('search_block');

My test code:

Score: 0
Rachel C avatar
Use javascript code in a specific div of the webform page
sx flag

I have a website that was set up using Webforms with page breaks. So on the same URL, there are multiple "pages" and div blocks on each page, with a progress bar on top so you know what "page" you're on.

I want to repeat JavaScript code so I was thinking of using modules and/or blocks.

Can I call the specific block or code from inside the div?

For example if I make a block with js code, right now it is ...

Score: -3
KHALED ALSHEHRI avatar
install Drush on shared server
ax flag

please i need to use drush on shared server

i allready use composer foe install drush,,

but if i use sudo command

sudo mv drush.phar /usr/local/bin/drush

, it is give me this massage

-bash: sudo: command not found

i allready contact the server customer serves

and the answer was

we cannot support and sudo commnds

any IDEAS please for using drush on shaired server

Score: 0
quantumized avatar
Is it possible to have a Search API Facet to expand the results? Basically, querying this facet OR this facet?
ng flag

We have a Search API View (Solr) using facets and our nodes have two separate fields for the facets. One is an address field and the facet is built on the address US States and the other field is a text select list with values Virtual, Physical, National.

We need to build the facets in a way to allow the user to select a US State from facet 1 which narrows the results to node from that state.

Then,  ...

Score: 0
Browser test reports assertion success as an error
ai flag

I am running a Functional test in a class derived from BrowserTestBase. Line 105 of the test method has this assertion:

    $this->assertSession()->linkExists('10000003');

The test output says:

Behat\Mink\Exception\ExpectationException: Link with label 10000003 found.

identifying line 105 as the line where the exception occurred. If it found the link, why does it consider that an error?

Score: 0
Nick R avatar
add user input during webform custom action?
us flag

I have a simple webform with a few basic fields. It also has a private Radios - Other field for status with the following values: pending, confirmed, denied and other for administrative purposes.

These webform submissions are processed by a specific role using a view with custom actions: Confirm Registration action, Deny Registration action. These actions are working fine at the moment.

I would like  ...

Score: 1
When adding new nodes how can I pre-populate the body field with the body of another node?
cn flag

I have a Drupal 9 website with number of nodes that I use as templates, I clone them to create nodes with the same body text.

However, I want to make this process simpler by prepopulating the body field using a token that fetches the node ID from the URL parameter.

I checked the modules:

but as far as I can see, they don't support fetching a field from another node ...

Score: -1
New Dev avatar
Patch not working
np flag

I am trying to apply patch to the core file but none solution work for me. even not able commit core file changes due composer restriction

composer.json

{
"name": "pantheon-upstreams/drupal-project",
"description": "Install Drupal 9 with Composer on Pantheon.",
"type": "project",
"license": "MIT",
"repositories": [
    {
        "type": "composer",
        "url": "https://packages.drupal.org/8"
    }, ...
Score: 0
davidp avatar
Trying to sort a views result by a global views conditional field
id flag

I'm attempting to use hook_views_pre_render in a Drupal 8.9.20 site to sort the results of a view by a global views conditional field and I could really use some help. I've spent some hours searching forums with no luck.

Here's my code so far.

 /*
 * Implements hook_views_pre_render
 */
function mk_timing_views_pre_render($view) {
  if (($view->id() == 'mk_driver_results')) {
    $view->result[' ...
Score: 0
How to get web server error logging output from phpunit functional tests?
ai flag

The 500 errors generated during phpunit tests aren't showing up in the Apache error logs. Where are those errors logged?

Score: 0
phpunit can't find node permissions
ai flag

We have a Functional test class derived from BrowserTestBase which is passing, but the output includes a deprecation notice.

Adding non-existent permissions to a role is deprecated in drupal:9.3.0 and triggers a runtime exception before drupal:10.0.0. The incorrect permissions are "edit any page content". Permissions should be defined in a permissions.yml file or a permission callback. See https://w ...

Score: -2
om62 avatar
Set the canonical link rel via theme's template.php for a specific views page (not a node)
US flag

I do not want to use the D7 Metatag or the MetaTag Quick modules. How can I specify a single canonical link rel for a single URL which is not a node (a view page) via the theme's template.php?

I've tried this but it has a syntax error:

if (isset($_GET['q']) && preg_match("/^products\category/", $_GET['q']) {
  drupal_add_html_head(array(
    "#tag" => "link",
    "#attributes" => array(
 ...
Score: 0
Recommended way to use StringTranslationTrait in PHP8 enums
ru flag

PHP8 has that new cool "enum" feature that should replace all class constants and would make coding easier and safer. One problem I encoutered is that many common Drupal traits (foremost the translation trait) have properties and therefore can not be used in enums.

So what I would like to do is

<?php

use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\Transl ...
Score: 0
Dave Nattriss avatar
Migrating URLs without titles into a link field (where the link title is optional) without them becoming NULL
ph flag

I'm migrating URLs that don't have corresponding titles into a link field, and when I either don't define the title, or use the default_value plugin to set the default value to '', the value actually gets set to NULL, instead of an empty string, which breaks my link formatter, that expects link titles to be strings (even if the strings are empty):

    process:
      field_link/title:
        - plugin ...
Score: 0
ShadowAce avatar
Report comments / Workflow
kp flag

I am trying to implement a functionality that would allow authenticated users to report comments on a forum post. My first thought was to do it using workflows but comments dont have a workflow functionality by default. I am working in a restricted environment so I am not allowed to use external modules.

My current approach is to have a Taxonomy field on comments which can be set to report. And t ...

Score: 0
Farhan Erooth avatar
Fetch redirect alias using the old alias
ng flag

I want to get the current alias of the node using an old alias. I do have the Redirect module installed and all the old aliases of the nodes are mapped to the new ones. But I am not able to fetch the latest alias from the backend. Assume that my old url is "/old_url" and new url is "/new_url". I tried the following code but not able to get any output:

use Drupal\Core\Url;
use Drupal\redirect\Redire ...

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.