Latest Drupal related questions

Score: -2
houdy avatar
Is it a best practice to give generally any node an alias?
sn flag

For each node I can create an alias.

I mean to give an alias such as /abc alongside the path /node/1.

Is it a best practice to give generally any node an alias?

Score: 0
Why is language prefix not included in Url::fromUri if the used path is not defined as a route?
cn flag

The issue is with the H5P module when Drupal is set to allow language overrides. Specifically this method.

If the language is set to English and user configuration form has Estonian as the language choice, then this will serve the newly loaded H5P libraries in Estonian, because the call is being made to h5peditor/... instead of en/h5peditor/..., which does not set the correct current language.

It seems th ...

Score: 0
LeJuanChis avatar
Duplicate webform entries
pa flag

I have a problem with my webform. When the form is submitted, the entry is duplicated (see picture) and although I have the option to prevent duplicate entries in the module they are still duplicated. If someone can help me I would appreciate it very much.

enter image description hereenter image description here

Score: 0
Baud avatar
simple view of a custom entity is extremely slow
sa flag

I have created a custom entity to store payment information:

 * @ContentEntityType(
 *   id = "bank_operation",
 *   label = @Translation("Bank operation"),
 *   handlers = {
 ...
 *   },
 *   base_table = "bank_operation",
 *   fieldable = TRUE,
 *   revisionable = FALSE,
 *   translatable = FALSE,
 *   internal = TRUE,
 *   entity_keys = {
 *     "id" = "id",
 *     "uuid" = "uuid"
 *   },
 *   c ...
Score: 0
I cannot get the Autoban module to work from "Access Denied" or "Page Not Found"
cn flag

I must be doing something stupid because there are several thousand users of this module! I need this module badly because just about every night the site gets a hundred or more "page not founds". At present I'm entering them manually in the banned ip address list.

I've searched for documentation on this module without success. What I assume should happen is that, once the threshold level is reac ...

Score: 0
BigChing avatar
Cart update event triggering for every field
sv flag

In Commerce's cart form, I've noticed that the cart update event is fired more than once. (Potentially, it's fired once per field in the form.) Events have the stopPropagation() function, but it doesn't seem to work. The update sends requests to a remote API and the checkout process has been slowed down to a crawl because of multiple requests being sent on each step.

Do you know how to get all fields ON ...

Score: 0
feat.com avatar
How to reset a field formatter settings or layout builder configuration
ca flag

I was settings up an images field through layout builder. Change it from Bootstrap Basic Image Gallery to OwlCarousel.

When I submit the form, the UI does not have any response. and then I refresh the page, the website crash on this configuration page. /admin/commerce/config/product-types/easel/edit/display/default/layout

I wonder if there is any method to reset field formatter settings or the layout ...

Score: -2
arnemichiels avatar
SQL error in Module
bw flag

I'm trying to query the database inside my module, but I get this error.

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM "commerce_product_variation" "cpv" WHERE ("variation_id" NOT IN (NULL)) AND' at line 1: SE ...

Score: 1
Potney Switters avatar
JSON:API fetch reference data
pm flag

I have a content type (MealDiary), which contains a reference to a paragraph multiple times (Meal: date, title). I do get a paragraph uid I can use to retrieve this data, but I would instead like to fetch the field data of the meal withing the MealDiary request. My goals is 1 request instead of 6.

Anybody could help on this?

Score: 1
Jean da Silva avatar
Call to undefined function Drupal\Core\drupal_valid_test_ua()
cn flag

I'm having this trouble while trying to upgrade drupal 8.9 to 9.4. I've followed the steps explained on drupal.org, and I'm using composer to do this. I've already upgraded other D9 sites, but never a D8.

This is the error when trying to access frontpage:

Fatal error: Uncaught Error: Call to undefined function Drupal\Core\drupal_valid_test_ua() in /code/docroot/core/lib/Drupal/Core/DrupalKernel.php: ...

Score: 0
David Pugh avatar
Saving block translation with large amount of text causes PDOException: Data too long for column 'translation'
br flag

I have a Drupal 7 project where I am using a Panel to patch together some Drupal blocks. These blocks have to be translated and I just added some data to the current French translation and apparently there is a limit to how much translated content you can have in a block because after I add the extra french content to the block and try to save I get an error that says: "The website encountered an unexpe ...

Score: 2
Vitaliy K avatar
How to display Media image with alt attribute in paragraph twig template
tr flag

I'm trying to access alt attribute as in given example Get Media Image URL in Paragraphs Twig Template - Drupal 8

But there is an example how to access alt and title...

That's easy, too. You should use the following syntax, switching out the bold for the machine name of your image field: {{ content.field_custom_image['#items'].alt }}

this is not worked for me

Score: 1
levente.nas avatar
Cookie authentication when reguistering users through REST API
kw flag

I am running Drupal 9 commerce 2.0 as headless CMS, and I am trying to integrate the user registration/user login part of my frontend application. I was able to use the user/register REST API to create users. The default (only option without other modules) authentication was cookie authentication. What I am trying to understand is how the cookie authentication works. When running curl -d @data.jso ...

Score: 0
Drupal Learner avatar
Callback Not Firing On Change
gf flag

I am somewhat new to Drupal development. Please bear with me on this.
I am trying to create a popup after a user enters a value in a date field on a node/add form. This is on a Drupal 9 site. To do this I am trying to add a callback function to my field.

I have my form_alter hook that I know is working because I have other changes that already work as well I have a logger to tell me that code is runni ...

Score: 1
Nategamer avatar
Argument 2 passed to Symfony\Component\Routing\RouteCollection::add() must be an instance of Symfony\Component\Routing\Route, boolean given
ky flag

Ubuntu 18.04.6
Apache2, Postgresql 10, Drupal 8.9.6, PHP 7.2.34 (most of the modules require these versions)

I've tried trouble shooting this problem for multiple weeks. I'm attempting to migrate a drupal website to our local server but keep running into this error.

So far I've looked into the Php version issues posted here (switched to php 7.3/7.4 and tried 8.0)
https://www.drupal.org/project/drupal/ ...

Score: 0
Joost avatar
How can I add custom code to Drupals .htaccess and make sure it will stay there
jp flag

For one of my Drupal 9 website I need to add a custom code to the htaccess file to redirect the visitors from one subdomain to another for this I use the following code:

#Custom Rewrite Rule
RewriteBase /
RewriteCond %{HTTP_HOST} ^old-subdomain\.mydomain\.com$ [NC]
RewriteRule ^(.*) http://new-subdomain.mydomain.com/$1 [L,R]

I put this code directly under the RewriteEngine on on line 68.

But I know th ...

Score: 0
Bijan Zand avatar
Redirect page after all nodes save
in flag

I am trying to write a custom module to save special nodes. With my code after first node save, page redirect and other not affected.

I need after all nodes_save redirect to list.

$nidew = [12,34,55,12,66,63];
foreach ($nidew as $nodeuniqe) {
  if (isset($_POST['submit'])) {
    $node = node_load($nodeuniqe); 
    node_save($node);
    drupal_goto('list');
  }
}
Score: -1
a.alshamiri avatar
How to get Webform Element value into Custom Token
za flag

How to assign a value of Webform Element (IP_ADDRESS) to a Custom Token ?

The Step that I did:


use Drupal\webform\WebformSubmissionInterface;

function MODULE_token_info() {
// token info
}

function MODULE_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata, WebformSubmissionInterface $webform_submission = NULL) {
  
  // @var to return IP address of the su ...
Score: 0
liquidcms avatar
Why doesn't form submit callback get called?
us flag

I have a custom page (controller) which embeds a node form. I want to submit this form via ajax but also run another submit handler which opens a modal with some of the values from that form.

My controller function is simple:

  public function createQuote() {
    $node = \Drupal\node\Entity\Node::create(['type' => 'mpep_quote']);
    $form = \Drupal::service('entity.form_builder')->getForm($node ...
Score: 0
Krishna Mohan avatar
Aggregation group by date for datetime field
sh flag

I have a view that outpus like below. Here the "Date" is actuallly a datetime field. (It stores the datetime as "2022-10-31T05:00:00" in the database)

Username Date Distance
Krishna 2022-10-23 23
Krishna 2022-10-23 25

I need to display the result, group by username, date and "sum" of Distance (as shown below).

Username Date Distance
Krishna 2022-10-23 48

I did use aggregat ...

Score: 0
How to return different entity reference fields from multiple bundles using the same name with JSON:API?
cn flag

The Goal

My site structure looks like this:

  • Node content type A with entity reference field groupA pointing to a term with field groupAfield
  • Node content type B with entity reference field groupB pointing to a term with field groupBfield

I want to be able to get content types A and B from a single JSON:API endpoint, and I want this endpoint to return groupB as groupA (rename groupB to groupA for  ...

Score: 0
How to determine entity where image field is housed?
id flag

I need to check if an image media field is housed in a paragraph to remove the alt attribute of that attribute. The same image field could be referenced anywhere. I could remove the alt field it within preprocess_image by checking if the value is set to a particular value.

However I need a more robust method by checking if the field is housed inside a paragraph/belongs to a paragraph. Maybe we  ...

Score: 0
Tek Raj Bhatt avatar
How do I show a dropdown with items on hover in a cart?
uz flag

Currently, I am migrating a Drupal 7 site to Drupal 9. I want to show the added items when hovering the cart icon.

All I want to achieve is this dropdown on hover

Inspecting it, I noticed the c-layout-cart-menu-shown class is added to the c-cart-menu class; I have tried to achieve this with jQuery addClass(), but it's not taking the jQuery I wrote. I defined jQuery in info.yml and libraries.yml file.

Is there any other way to solve this problem? ...

Score: 0
Jean da Silva avatar
PluginNotFoundException entity type does not exist when trying to uninstall any module
cn flag

I've got this drupal website from a client that the another developer created, and they've made a mess with many things in this site. I'm having a problem where every time I try to uninstall a module, this error appears:

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "block_content" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 150 of co ...

Score: 0
gMaximus avatar
How do I retrieve the tokenised path for the Files Directory setting configured via the fields settings?
sa flag

I'm using this code to retrieve a remote file, during the process of creating a new a media entity.

$url = 'https://example.com/example.jpg';
$image = system_retrieve_file($url, NULL, TRUE);
$entity_array['field_example'] = [
  'target_id' => $image->id(),
];

The second parameter in system_retrieve_file() determines that the file is stored in the public:// directory.

How can I retrieve the t ...

Score: 0
thaidrupaler avatar
I can't get rid of duplicates in products view
pw flag

I tried everything. I reduced the number of fields. I set the Query settings to distinct. Product: Variations (variations:delta) is also set to 0.

When I search by SKU I get duplicates. SKU Search is exposed filter for admins.

This is the generated query:

SELECT DISTINCT "commerce_product_field_data"."created" AS "commerce_product_field_data_created", "commerce_product_field_data"."product_id" AS "produc ...
Score: 0
ABHISHEK Joshi avatar
How can I collaborate with multiple developers?
jp flag

I am developing a website on Drupal with 2 other developers. What would be the best way to collaborate? We plan to work on different git branches and there will be a dev and production branch as well. How can we keep in sync with the database structure without overwriting each others' work?

Score: 0
kankari avinash avatar
How to filter list items values based on user roles programmatically
td flag

I am in scenario where I need to filter list elements based on User Roles.

for example.. i have create two roles 1.Vegetable seller and 2. Fruits seller. I have created a list field with values as 'Apples','Mango','Potato','onion'.

Condition is that vegetable seller can only select vegetables(Potato and Onions) not fruits(Apples,Mango).

There are many list fields in our website. This is became a bottlenec ...

Score: 0
#limit_validation_errors not working for reset button?
in flag

I have a page view with some exposed filters (i.e. main content page). Some exposed filters are auto-complete fields (i.e. user references). So if I type some rubbish for user name and submit form I get error that user doesn't exist, which is correct. However if I press button "Reset" instead of emptying all the fields and really resetting the form it gets validated and I get error same as with submitti ...

Score: 0
chtouk avatar
Adding data-attributes in links override theme
ad flag

In the classy theme of drupal I would like to override this code

{% if links -%}
  {%- if heading -%}
    {%- if heading.level -%}
      <{{ heading.level }}{{ heading.attributes }}>{{ heading.text }}</{{ heading.level }}>
    {%- else -%}
      <h2{{ heading.attributes }}>{{ heading.text }}</h2>
    {%- endif -%}
  {%- endif -%}
  <ul{{ attributes }}>
    {%- for item  ...

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.