Latest Drupal related questions

Score: 1
Alejandro avatar
How can I modify/edit/change the media video controls?
fj flag

I was wondering how could I modify the controls from a media video. In my particular case, I want to remove the "Download" button from the controls, see: Screenshot of a video player with the control options opened

Score: 0
user14409370 avatar
how to create commerce product attributes which gets it's values from a view
nr flag

I want to fill the product attributes select list with data like:

location1 location2 location3

These locations are general and gathered using a custom module. In views I can create a list with these values, but I'm unable to use them as attributes.

Score: 0
How to get the parameters from a URL and a route that is not the current one?
mx flag
JFK

Route from a custom module :

custom.route:
  path: /the/{id}/path

Hypothetical url : /the/53/path

The goal is the get the id value ("53").


So far, I managed to get the route name from the url with

$url = "/the/53/path";

$route_provider = \Drupal::service('router.route_provider');
$found_routes = $route_provider->getRoutesByPattern($url);

In $found_routes, I can find the "custom.route" route na ...

Score: 3
Notd avatar
How to get the current running Drush command?
tk flag

I would like to detect from code the current running drush command. I have some hooks that will be run when I exec some drush commands and want to detect which command is triggering the hook.

I manage to get the info from input() but I want to know if there is a more appropriate way:

  if (PHP_SAPI === 'cli') {
    $command = \Drush\Drush::input()->getArguments()
  }

I would like to have something sim ...

Score: 2
Victor Núñez avatar
I am trying to add a simple pager to my controller, I have managed to get the row limit (5) to be printed but not to see the next or the previous
no flag
<?php

namespace Drupal\drupal_block\Controller;


use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Database\Connection;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Database\Query\PagerSelectExtender;

class DrupalBlockController extends ControllerBase {
  protected $connection;

  public function __construct(Connection $connection) {
      $this->connecti ...
Score: 0
Pin avatar
Change icon style by field value in Leaflet map view
cn flag
Pin

I would like to have different color markers depending on a field value in a Leaflet Map view.

I try to use Replacements Patterns in format > style options > Map Icon:

enter image description here

but I get a "not valid json format" error. What I'm missing? (I know this is possible with OpenLayers module, creating different layers, but not possible to change to it now).

Score: 0
Can a Rules action send an email to all users that have set a flag?
pe flag

I've found some older Drupal 7 info on this, but not much for Drupal 8+ yet. What I want to do:

  • Give users the ability to set a 'notify me' flag on nodes
  • When a comment is added to the flagged node, all users who have flagged it get an email notification

So far...

  • I have the rule set up correctly to allow users in role x to set the flag. It has another action on it that is tested and working.
  • I  ...
Score: 0
rfmarcelino avatar
Add a text field value with AJAX
cn flag

Problem: After an AJAX callback, the text is not inserted in the body field.

Description: I created a fresh Drupal installation. Added a field 'Type' | field_type | List (text) to the Article CT. The goal was that a change in that select would add text to the body field. Here's the ajax_test.module code, inspired by the documentation:


use Drupal\Core\Form\FormStateInterface;

/**
 * Implements hook ...
Score: 0
A-WRI avatar
How can one use the value of one field to enforce a minimum value on another field?
pl flag

I'm making a registration form for an event that will have a "sliding scale" fee system, but with minimum contributions based on the size of their organisation.

I want users to be able to set the size of the organisation that is paying their fee (from very small/volunteer led up to very large, well funded organisations) via radio buttons, and then to choose their contribution using a slider. Idea ...

Score: 0
tcnolan7 avatar
How to compare node and node_unchanged field values in Drupal 8 Rules?
mo flag

I'm trying to compare the value of a custom field, the unchanged value and the saved value.

Basically... if myfield value was "Not Started" and if myfield value after updating the node is "Pending" then send an email to the node author

The event is "After updating a content item of type". I add a condition for "Entity is of Bundle" and a condition Data Comparison with the specific field and value I ...

Score: 2
gzwg avatar
How can I check with if my site is running?
cx flag

Is there a way with Drush or something else to check if a specified Drupal site is still up and running, means fully normal functioning, after automated maintenance/updating in an external script?

Sometimes an update can fail in a script and then there is a none-functional site left. I want to detect that situation. So have a command and the output is the status of the site? E.g.

drush <command> ...
Score: 0
Font style isn't applied on PDF (entity print)
kn flag

I'm using Entity print with my webforms. I've followed those steps https://www.drupal.org/node/2706755 to add the css into my PDF.

My classes are applied (color, padding...), but for some reason, the fonts are never applied on the generated PDF, but is applied on the debug : https://.../print/pdf/webform_submission/10/debug

Font are not applied with CDN @import url('https://fonts.cdnfonts.com/css/apho ...

Score: 1
MSNOP avatar
How to add groupBy option WITH ROLLUP
so flag

With Drupal 9.5.3, a group by like this:

$query->groupBy("myfieldname WITH ROLLUP");

will result in

(...) Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'myfieldnameWITHROLLUP' (...)

... since spaces are stripped.

Is there any other proper way to add the "WITH ROLLUP"?

Score: 0
user3099225 avatar
Run custom php code or file in drupal content type form submission
cn flag

I have this drupal site, there is a candidate registration page where anyone can fill the details (name, gender, address, mobile no etc) and submits and a success node page is displayed with all details applicant fills, then at admin side applications will be used for further offline processing. Everything is working fine.

What i am trying to do now is, after filling the details - like mobile numbe ...

Score: 2
isin avatar
Why does “ Nesting level too deep - recursive dependency?” occur in a compiled template?
pk flag

After upgrading from 9.4.8 to 9.5.3 a problem came up (see below) so when I add more than one image in articles media field node-image, I get a 500 error.

PHP Fatal error:  Nesting level too deep - recursive dependency? in /home/www/sites1/mysite.gr/astrosnews/web/sites/default/files/php/twig/63dee130963f5_field--field-node-image.h_OFwaH9BedIr0dxUMjz2WTf6If/M-GDNVdt5tDdsesr-7jYR7Xyr_xWOPal71qHp-7K3 ...
Score: 3
leymannx avatar
How can I change the development version of a module?
ne flag

Originally, the Link Allowed Hosts module, which I'm a maintainer of (with "administer releases" permission), started with a default branch of 1.0.x. This branch was released and appeared since then as development version 1.0.x-dev.

This was wrong, the default branch needs to be 1.x. So I created a 1.x branch, set it as default on the project's GitLab page and also released it. Still the developmen ...

Score: 0
quantumized avatar
Is it possible to "group" a Views field when using the "Content" display format?
ng flag

We have a View using the Content display format (not Fields) because we're using a theme template to output the nodes. This works great but we also need to group to nodes by a field on the node (category). When using the Fields display output for a View it gives you the "group by" field option but (for obvious reasons) not when using the Content display format.

Is there a workaround to allow grou ...

Score: 0
Is there a block visibility condition for entity types?
cn flag

By default, Drupal core's node module provides a "Content type" visibility condition for node content types.

Is there a similar "Entity type" visibility condition to restrict block visibility by entities?

It seems like an obvious use case, so I tried searching but haven't been able to find anything-- it seems there's no such thing in core itself, or in Ctools, or in the Block Visibility Conditions c ...

Score: 0
hotwebmatter avatar
Dynamically generate Form API select list of routes to page displays of a known View
nr flag

Given a known View, how would one dynamically generate a Form API select list of the routes to its Page Displays?

In my case, I have a Search API View (view.search) with a default site-wide search page (view.search.page_1) and separate search pages for different site sections, or "micro-sites" (e.g., view.search.page_2, view.search.page_3, etc.)

I have coded a custom block to replace the Drupal cor ...

Score: 0
user3108268 avatar
Alter all webform fields
us flag

If we want to alter webform item e.g. add a colon : to a label of a specific field, we use this:

$form['submitted']['my_form_component']['#title'] = $form['submitted']['my_form_component']['#title'] . ":";

But what if we want to apply that colon to all field labels and not just that one my_form_component?

Current code:

function MYTHEME_form_alter( &$form, &$form_state, $form_id ){
  if (str ...
Score: 0
River Liver avatar
How do I link to a Views Page from a systemAdminMenuBlockPage page?
je flag

I have a custom module that I have a systemAdminMenuBlockPage in that I'd like to link to various content administration Views pages from. I basically have a custom Configuration menu item doing this using custom_module.routing.yml and custom_module.links.menu.yml like:

Configuration > My Site > Content Administration Views

On this page I'd just like to create menu items that link to individual  ...

Score: 2
Jorge Luis Arzola avatar
get the value of a drupal token inside a twig code
pl flag

does anybody knows how to get the value of a drupal token inside a twig code(global text field) block in the views's header? I can get the value of the token outside the twig code block, but not inside ...

[view:page-count]/*token works outside*/

{% set count = [view:page-count]  %} /*does NOT work*/
{% if count == 1 %}
    <p class="text-danger">Atención: en esta región sólo debe haber u ...
Score: 0
"Missing class doc comment" when using attribute on class
cn flag

I recently updated PHP from 8.1 to 8.2.

This resulted in a bunch of deprecation notices about use of dynamic properties in PHPUnit tests.

So, based on the docs, I added the AllowDynamicProperties class.

/**
 * Unit tests for the myModule class (timing).
 *
 * @group myModuleSuite
 *
 * @coversDefaultClass \Drupal\myModule\Class
 *
 * @property \DateTimeZone $timezone_utc
 * @property \DateTimeZone $timezo ...
Score: 2
mbomb007 avatar
Difference between ContainerInjectionInterface and ContainerFactoryPluginInterface?
nl flag

Both ContainerInjectionInterface and ContainerFactoryPluginInterface provide a create() function and are used for dependency injection.

I would like a clear description of their differences and their use cases, such that it's clear which interface a class should implement.

  • Which should I use if I only need to use injected services in a class?
  • Which should I use in a service class that will be in ...
Score: 0
Rajat Bhardwaj avatar
Why does this code to create a dependent dropdown not work?
tc flag

I am trying to implement the dependent dropdown option in Drupal 7 from this URL http://w3shaman.com/article/creating-ajax-dropdown-drupal-7. When changing the first dropdown value, it is showing the loading indicator but no value is fetching in dependent dropdown.

Here is the code I have tried so far.

This is the code of form alter module

function xyz_mod_alter(&$form, &$form_state, $form_ ...
Score: 0
techenzie avatar
PHP Error: Drush\Application::setLogger(Psr\Log\LoggerInterface $logger) must be compatible in two given files | How to fix this error?
lc flag

I was trying to setup a local environment of a website created on Acquia cloud platform. Everything was done properly including the database import. But now, when I execute drush commands, it gives me the following error.

PHP Fatal error: Declaration of Drush\Application::setLogger(Psr\Log\LoggerInterface $logger) must be compatible with Psr\Log\LoggerAwareInterface::setLogger(Psr\Log\LoggerInterface $ ...

Score: 1
Jipi avatar
How to calculate the sum of duration in a view?
cn flag

How to calculate the sum of duration in a view ? I would like to know the total duration of an album after having entered the duration of each track on the disc. I use the Duration field and Views Aggregator Plus modules. The "duration" format is native in excel spreadsheets for example. Thank you in advance for your help.

Score: 1
thiokol avatar
How to redirect to a specific page after submitting password reset?
cn flag

When a logged in user resets their password at /user/password and clicks the submit button, they are being redirected to the frontpage.

How can I redirect to /user instead?

I've tried the second answer here: How to redirect users after password reset from first time user, but the redirect doesnt happen.

function myModule_form_user_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_stat ...
Score: 0
Alexdezark avatar
Shipping configuration for x items or more
br flag

Using Drupal9 and Commerce2 I'm trying to configure shipping for a specific variation type : tires.

If you order one or 2 tires, you must pick them up on site. if you order 4 or more, they can be shipped for free. there is no intermediate possibility, no possibility of shipping with postage if you buy less than 4.

So I configured the type of variation by not checking the "shippable" box.

Now in a CartE ...

Score: 0
Pankaj Sachdeva avatar
format_p config not working with CKEditor
us flag

I am using D9 and using CKEditor for a formatted long field. Currently enterMode = 1 is set which means by default we will have <p> tag in every new line. We only have 3 enterMode in CKEditor:

enterMode = 1 -> p
enterMode =2 -> br
enterMode = 3 -> div

I have a requirement to convert this <p> tag to <span> tag. I have tried to set achieve this by using

function it_common_e ...

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.