Latest Drupal related questions

Score: 0
How to get a menu link UUID from a menu tree item?
cl flag

I'm trying to create a select box like the one that allows the selection of a menu parent on the node form. I might be barking up the wrong tree in my approach. I figured if I can get an array of menu link titles and UUIDs I will have what I need.

I tried this:

$menus = Menu::loadMultiple();
$menu_tree_service = \Drupal::service('menu.link_tree');
foreach($menus as $menu) {
  $id = $menu->id();
  $ ...
Score: 0
esQmo_ avatar
"Most popular" tags of the day
za flag

How can I create a list of the most popular tags of the day, based on the actual date, using view?

The most voted answer for Most popular tags in a list as a block helped me to set a list of the "most popular" tags using contextual filters and aggregation, but I couldn't find a way to show only the tags of the day.

Can you help me?

Score: 0
commonpike avatar
How can you update a single configuration entity using drush?
in flag

Every now and then, if I try to import partial configs using drush, like

drush config:import --partial --source=stuff/is/here

drush seems to understand that some of these config entities exist in the database, and it needs to update them.

+------------+---------------------------------------------+-----------+
| Collection | Config                                                        | Operation |
+ ...
Score: 0
Cascade dropdown list aka dependent dropdown list
cn flag

Is there any way to make a cascade dropdown list aka dependent dropdown list for a "survey" content type?

Apart from the "survey" content type. I have three other content types: country, state and district. Each of these types are linked by entity references.

In the "survey" content I have created 3 dropdownlists, one for country, state and district. I am filling these lists with content types that  ...

Score: 0
Abhi avatar
Solr: Avoid spell check on numbers within the string field
td flag

I've 2 fields title and description in apache solr, both are the text_general field type contains string as well as numbers and I applied the spell check on both field by createing single copy field for both title and description. and applied spellcheck on that field.

Now, I want to avoid the spell check on numbers present in title and description but other string should have the spell check.

how ca ...

Score: 1
Lambic avatar
Returning long-running api response as a "download"
ph flag

I'm working on a REST api endpoint which takes in an array of IDs, loads all of the entities associated with those IDs, does some processing on them, then returns them in a chosen format (csv, xls etc.).

This processing could take a long time with a large number of IDs, so I want to start returning data to the user immediately as if they are downloading a file (which they sort of are) and finish  ...

Score: 0
block_content routes have ambiguous paths
ru flag

I'm trying to convert block forms (the content entity forms) into Gin Admin theme forms. Gin theme provides a hook for this:

function hook_gin_content_form_routes(): array {
  return [
    'entity.block_content.edit_form',
    'block_content.add_form',
  ];
}

This worked fine for new blocks (add_form), but it did not work for existing blocks (edit_form). After digging around, I found out that the cont ...

Score: 0
Libbna Mathew avatar
How to add a relationship in google analytics reports views?
in flag

So I created a custom module and added a .inc file. Inside that file I've defined a hook_views_data() in which I have defined content entity relationship so that it supports GA reports.

Code in .inc file

function custom_module_views_data() {
  $data = [];
    
  // Define the relationship to the content entity.
  $data['google_analytics_reports']['content'] = [
    'title' => t('Content'),
    'hel ...
Score: 0
sidgrafix avatar
Updated/commented date - display permission problem
in flag

I'm trying to get a Comment Statistics (category) - Updated/commented date field {{ last_updated }} which is a date formatted field to be visible to everyone including anonymous users.

The view access is set to Permission | View published content. Every field in the view (except for this field) is visible to anonymous users. If a user logs in (the role does not matter) the field information is displayed.

Score: 0
Md. Shafiq Hossain avatar
File Field client side validation not working
cn flag

I am on Drupal 9.3.x

I just discovered that File Field in node entity form which is marked as required, not showing client side validation fail message. Rather it submitting the form and then showing the validation fail message.

This is causing issue for my modal form. I am loading the entity form's custom form mode into modal. The file field is marked as required, actually its a media field which i ...

Score: 0
Mathieu avatar
Why does the Entity Comparison module throw this exception with Webform submissions?
dm flag

I am using Drupal 10 with the Webform and the Entity Comparison modules.

The goal of the website is allowing users to submit a product as a webform. Later, users should be able to select 2 submissions and compare the entities. This is where I am stuck: The Entity Comparison module gives me an error when I add the webform entity I created.

This is the error that I can see in the logs:

Uncaught PHP Exc ...

Score: 0
Tejas Damre avatar
Query to order by specific item to be first and then to sort the rest with id desc
ng flag

I am into a unique requirement where I need to sort records to show specific data first and then rest sort by id descending. I am able to see records using SELECT * FROM jobs where type='jobs' and status=1 order by field_job_id='J5-00104' desc,field_job_id desc;.

Is there any way to achieve this in Drupal way? BTW I am trying to manipulate a query with the following code.

$query = \Drupal::entityQuer ...
Score: 0
BassPlaya avatar
Example payment always sets the order to "Checkout: payment"
ma flag

I'm using the Example Payment module to test payments for free stuff in Drupal 7 Commerce. It works, but after the last step in the checkout process, the order status is always set to Checkout: Complete and its workflow order state set to Checkout, even though I have rules in place that set the order status and state to Completed (when an order is first paid in full).

When I look at the order revisio ...

Score: 0
Grand Master B avatar
Computed multiplication
us flag

I have a webform where I am using the Twig Computed module to calculate an amount. It is simple and straight forward: I have a field that captures the amount and I'm using Twig to multiply it to find the fee; the fee amount is a fixed rate

The Computed Value/Markup is {{ data['license_amount']|number_format(2) * 0.019 }}. It works when data['license_amount'] is lower than 999; it shows a wrong total w ...

Score: 0
Happy Coder avatar
The specified database connection is not defined: default for Drupal drush
bh flag

I have the following configurations for my Drupal site:

sites/mysite/settings.local.php

$databases['default']['default'] = array(
  'database' => 'mydb',
  'username' => 'root',
  'password' => 'password',
  'prefix' => '',
  'host' => '127.0.0.1',
  'port' => '',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
);

and for drush, I have : d ...

Score: 0
JM John avatar
Caching Views with altered query
mz flag

I have a view showing on taxonomy terms which shows popular nodes from same category of taxonomy terms.

Category - Taxonomy Terms - Nodes

Lets say Term A and Term B both are same category. On Term A page, we display popular nodes from Term B and other terms in same category.

This is done by modifying view query using hook_views_query_alter.

We can't find a way to successfully cache the output of this a ...

Score: 2
pmagunia avatar
How to disable a CKEditor5 package loaded by core?
au flag

Is there a way to disable a CKEditor5 package loaded by core? I would like to disable paste-from-office, but I can see the question here applying to different packages.

In the file web/core/core.libraries.yml we see this code:

ckeditor5.pasteFromOffice:
  remote: https://github.com/ckeditor/ckeditor5
  version: "35.4.0"
  license:
  name: GNU-GPL-2.0-or-later
  url: https://raw.githubusercontent.com/ckedi ...
Score: 0
user110589 avatar
How to write a custom action in Views VBO to print a batch of selected invoices
fm flag

I need a custom action in Views VBO with Drupal Commerce to print a selected group of invoices to a browser print dialog. I have configured this as a src plugin and a custom twig template. Here is an example of the code in the action .php:

<?php

namespace Drupal\my_action_module\Plugin\Action;

use Drupal\Core\Action\ActionBase;
use Drupal\Core\Session\AccountInterface;
use Drupal\commerce_ord ...
Score: 0
tinohuda avatar
How to prepopulate text field with entity reference values
br flag

I have two element:

  1. Entity reference autocomplete, will populate from Username (value from field name in user entity) Views Entity Reference.

By inputing this Entity Reference Outocomplete I can select username followed with field_first_name value.

  1. Text Field (hopefully populated from Users field_first_name).

I know in advamced tabs, we can set default value using tokens, but i can not find any toke ...

Score: 0
ckeen avatar
Extra Block Types (EBT) settings error after push
us flag

I've added and enabled the Extra Block Types, Core and Core Remover Helper, modules on my local site. Enabling them also enabled multiple dependencies including Field and Field Group.

The site works fine locally, but I just pushed it to Pantheon dev and I get an error. Clearing the caches (either the button on dev, or via Terminus) didn't help.

Looking at the error logs, I see these errors.

Uncaught ...

Score: 0
Andrew Morris avatar
Config Export changes to different folder
mw flag

Is it possible to export only the changed configuration files to a specified folder?

When you run drush cex to see the change list of files like this

+------------+----------------------+-----------+
| Collection | Config               | Operation |
+------------+----------------------+-----------+
|            | views.view.frontpage | Update    |
+------------+----------------------+-----------+
Score: 0
Tinto avatar
How can I check if an element has a CSS class that matches a value in an array?
ru flag

In Drupal 9, I'm trying to check if an element has a certain css class using hasClass().

<p{{ attributes }}>Does this element have my css class?</p>

{% if attributes.hasClass('my-css-class') %}
  <p>Yes it does!</p>
{% else %}
  <p>No it doesn't.</p>
{% endif %}

Instead of checking for one class, I would like to check if my element has one of the classes contain ...

Score: 0
Ankit Hinglajia avatar
How can I programmatically save node components?
cn flag

There is a site with number of nodes including layout canvas and site studio components available in a node.

When there will be changes in one of the components (new field added with default value), if I want new component changes to existing page/node, I will need to edit the node, save the component, and save the node. After these steps, I am getting the component change reflected on the node.

Is  ...

Score: 0
bobthebuilder avatar
The Quantity field increments in decimals instead of whole numbers
mn flag

Default installation of Commerce 2.x. The qty field for a product, when you click the up arrow to increase the quantity it goes from 1 to 1.01. I want it to go from 1 to 2 to 3, etc.

Score: 0
fallenturtle avatar
Turn off caching for local tasks menu
au flag

I have a somewhat complicated view that uses multiple displays for showing events. It uses a datepager (https://www.drupal.org/project/date_pager), exposed filters (using better exposed filters), and a local task menu.

The overall issue I'm having is that I want any event view link, be it a local task tab, a pagination link, or activating an exposed filter, to preserve any arguments in the URL. And ...

Score: 0
c..k avatar
Upgrading book module from v7 to v9 - no rows in book table
nc flag

I'm upgrading a site from v7 to v9. The entire site is composed of about 10,000 book pages. All the nodes migrate successfully, but the book tree has no contents and the table 'book' has zero rows. It appears the structure of the table in v9 is different than v7, so I cannot just export / import the contents to migrate the structure.

How can I migrate the book tree from v7 to v9?

Score: 0
somo avatar
Why is
changed to
?
mn flag

After I edit a block in Full HTML form CKEditor on Source mode and save, Drupal changes <br> to <br />.

Drupal also seems to me to unify some HTML tags into one line.

This

<p>
<!-- -->
<br>

Becomes something like this

<p><!-- --><br />

In /admin/config/content/formats/manage/full_html the only filters that are on are:

  • Align images
  • Caption images
Score: 0
user3532287 avatar
Style image is not created
ro flag

I have a D7 (7.72) news website (multi-lingual), it started on 2023-06-07, that no image upload or update could create style in sites/default/files/styles although it uploads to the sites/default/files folder. It is the same on all content types. The path and also itok is being generated but the styled file is not there! Web server is LiteSpeed (php 7.73 , db: MariaDB 10), I have 19968 nodes, 21397 ima ...

Score: 0
Alimba avatar
How to set media library widget so that allows only certain dimension images for each field?
in flag

I'm trying to find a way to set some image dimension limit for the media library widget. That will allow me to restrict on which image sizes can be selected based on the fields they are using them.

I know that you can set a global min and max image size but the problem with this is that if you want to upload 300x300px image sizes for a certain field only and all the other images on the site are l ...

Score: 0
commonpike avatar
Why does Drush:migrate not generate config entities for separate content types?
in flag

When using Drupal 9 with modules migrate, migrate_drupal, migrate_upgrade and migrate_plus, and calling drush:migrate --configure-only with a Drupal 7 source database

  • I see migrations at drush migrate-status, also one for each content type, like d7_node_complete:page
  • I see a lot of yamls appear after drush config:export, but none for content types
  • I see configs appear in the ui at admin/config/deve ...

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.