Latest Drupal related questions

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 ...
Score: 1
CanardPpc avatar
Migrate Medias update : entity_lookup process error
de flag

I'm trying to update Medias already existing in my Drupal using Migrate and the process entity_lookup.
The field field_uuid was designed specifically as a matcher for my .json original datas and the already imported Medias. The process inside my .yml migration file looks like this :

process:
  mid:
    plugin: entity_lookup
    source: uuid
    entity_type: media
    bundle: audio
    value_key: ...
Score: -2
New Dev avatar
get node id from entityQuery('node')
np flag

I want to get the node id from entityQuery('node') the below query give me array vid = nid

$nids = \Drupal::entityQuery('node')
->condition('status', 1)
->condition('type', 'account_content')
->condition('field_account_id', $accountid)
->execute();

When using array_keys($nids) // getting vid which is revision id

When using array_values($nids) // getting nid which is node id

I want the n ...

Score: 0
How to render a Taxonomy Term in twig without the term name?
au flag

For some reason, I am writing my own controller that needs to include a taxonomy term.

I want to render everything of a taxonomy term (except the name / title) in the template I wrote.

My controller is like this:

use Drupal\Core\Controller\ControllerBase;

class MyController extends ControllerBase {

  /**
   * Drupal\Core\Entity\EntityTypeManagerInterface definition.
   *
   * @var \Drupal\Core\ ...
Score: 1
Patoshi パトシ avatar
Exposed Views Filter of Usernames in a list instead of autocomplete
kr flag

I have an exposed filter with a relationship to a reference field in my content type to users. Currently this exposed filter lets me filter by inputting a username, but its only autocomplete. Is there a way to have a select list of usernames I can pick from?

enter image description here

Score: 0
Patoshi パトシ avatar
Views Exposed filter can't input username to filter. Only works with User ID
kr flag

I created a custom View, where it shows all of a specific content type. In this content type I have a field that is a user reference called "Assigned to". In this view, I want it exposed so one can search by a username, but this exposed filter only takes in the User ID, but not the user name. What am I missing to make this work?

I added a relationship of User:Assigned_To and that didn't seem to w ...

Score: 0
tsitsi avatar
Taxonomy field not displaying in a Node built with Paragraphs
ao flag

I have a node type called Profile. It includes a paragraph type called Person. The fields in that paragraph type are:

  • Name (text)
  • City (taxonomy field)
  • Brief (text).

Whenever I look at a published Profile page without logging in, I can see name and brief the taxonomy field is not displayed. However, when I log in, I can see the full node with the taxonomy field.

It feels like a permissions issue,  ...

Score: 0
Chuck Norris avatar
Perform an LDAP search from a module
ua flag

I am trying to perform an LDAP search from hook_form_validation() in a webform using Drupal 9 and drupal/ldap 4.3.

I have configured the LDAP module on my site, but I am not using it for authentication. I can however use ldap query and perform a test of the ldap server on /admin/config/people/ldap/server successfully.

At the bottom of API usage they say you can use the following code.

$factory =  ...
Score: 1
Why does this custom CKEditor plugin produce the toolbarview-item-unavailable error?
pt flag

I have 2 modules in active development with the purpose of learning how to develop custom plugins for the Ckeditor5 wysiwyg.

On both modules, I am stuck on the following problem. The error pasted below is from the second module :

ckeditor5-dll.js?v=35.4.0:5 toolbarview-item-unavailable {item: 'testPlugin'} 
Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-toolbarvie ...
Score: 0
jackrabbithanna avatar
JSONAPI - limit list of included referenced entities via filter
ke flag

I'm using JSON API and JSON API Include modules, in Drupal 9.5

I've got a node type, "article" with a entity reference revisions field referencing a paragraphs, field name, field_variant. So this call works great, gives me all information: https://mysite.com/jsonapi/node/article?include=field_variant&jsonapi_include=1

What I'd like to do is have a filter, which returns all nodes of the type,  ...

Score: 0
tawellman avatar
Converting Node Type to New ECK Content Type
us flag

I have a site with several different Node Types. With some of them having different types within them created with a Text(list) fields.

For Example:

Node Content Type: Chemicals
Label: Chemical Type Machine Name: field_chemical_type Field type: List (text)
  Allowed Values list:
      fertilizer|Fertilizer
      fungicide|Fungicide
      herbicide|Herbicide
      insect ...

Score: 1
Travis avatar
Form builder not getting checkbox values
cn flag

I cannot determine why the form state seems to fail to get the values of the checkboxes on a form I'm building.

In my buildForm(), after submission, I am returning a result set. Each result that is built includes a checkbox form element.

$form['main_container']['grid'] = [ 
  '#type' => 'container',
];    

foreach ($title_list as $title => $row) {

  //...some code here...
  
  $form['main_c ...
Score: 0
Pankaj Sachdeva avatar
Entity Print - Getting error while clicking on View PDF
us flag

I am using Entity Print module and I didn't change its default configs. enter image description here

I am using Dompdf library for generating PDF on node. I have enabled View PDF from Manage Display page. When I am clicking on View PDF to generate, I am getting this error:

Error generating document: Failed to generate PDF: file_get_contents(http://dots-eco-drupal.docker.amazee.io/sites/default/files/css/css_Hj6dvEdQZTchfggjP ...
Score: 0
Fetch select label via GraphQL
cn flag

My nodes have an "articleType" property, which is a select field with ~10 options ("article|Article", "training|Web based training" etc).

Fetching the property via GraphQL (8.x-3.1) works, but this gives me the key of the selected option (training):

    [...]
    results {
      entityLabel
      ...on NodeArticle {
        fieldArticleType
      }
    }
    [...]

I would like to retrieve the label of  ...

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.