Latest Drupal related questions

Score: 0
websoft avatar
For specific block use unique template file located in custom module's templates folder
cn flag

Within my custom module 'footermenu' I would like to specify a template file for a specific menu block. I also want to locate the template file within the /templates folder of my 'footermenu' module.

The specific block #id is ‘mainmenu’.

As such I’ve been able to use the function below to change the template file to ‘menu__grid’.

function footermenu_preprocess_block__mainmenu(&$variables)  ...
Score: 4
Joost avatar
Composer not applying patch: exceeded the timeout of 300 seconds
jp flag

Since my update to the new OSX (Ventura 13) I'm having problems using composer. The biggest problem I have is that my patches aren't patched and end up with and exceeded the timeout of 300 seconds after a while. I didn't change my composer.json file or the patches. This only occurs on my local site, the remote sites run smoothly.

What I tried to fix this is updating and reinstalling composer. I'm ...

Score: 0
user3099225 avatar
Set restrictions to nodes displayed after submission
cn flag

I have a content type (AppointmentApplication), which can be used from anonymous users; all the information can be viewed by administrator users.

I don't want all the entered information to be shown right after the node submission by anonymous users in the success page. I just want to show a serial number which can be used from users as their application number. When I restrict the access to this  ...

Score: 1
Raido avatar
Removing orphaned paragraph references from the user
ir flag

Setup

Drupal 9 site has Users and each user has a Paragraph that contains "Phone" data. User => Phone Paragraph connection is made via field $user->field_phone_para.

Issue

Somehow database has gotten "ghost" references for the $user->field_phone_para field. When I load the user and print the phone paragraph reference values/targets, it gets 3 responses. In reality there should be only one.

 ...
Score: 1
Kevin avatar
batch_set results in TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback
in flag

I am trying to set a batch from a confirmation form. When it is submitted, this is the code:

$operations = [];

$operations[] = [
  [UpdateEntity::class, 'execute'],
  ['field_group']
];

$batch = array(
  'title' => t('Updating...'),
  'operations' => $operations,
  'init_message'     => t('Commencing'),
  'progress_message' => t('Processed @current out of @total.'),
  'error_message'  ...
Score: 0
PA4KEV avatar
How to programatically publish content after form validation
mx flag

I have a content type of which its status is set to unpublished and is disabled. A site manager needs to publish the content after approval.

The site manager wants to skip this validation process when creating the same content and immediately publish the content after submitting the creation form.

In my _form_validate function:

  if (in_array('site_manager', $user->getRoles())) {
    if ($given_ ...
Score: -1
sudhan avatar
Why is core installed into the vendor directory?
us flag

When I am trying to upgrade module or theme via Composer, I get this exception.

Fatal error: Cannot redeclare config_get_config_directory() (previously declared in D:\xampp\htdocs\itdlocal_test\web\core\includes\bootstrap.inc:214) in D:\xampp\htdocs\itdlocal_test\web\vendor\drupal\core\includes\bootstrap.inc on line 214

Please let me know on the fix for the error. I have tried removing the lock file an ...

Score: 0
Messenger doesn't display value after user logged out and redirect
kn flag

After my user is submitting a form, I want to logged him out, then redirect to the front page. then, display a message.

public function submitForm(array &$form, FormStateInterface $form_state) {
  /**
   * my logic
   **/
  if ($isDeleted) {
    $this->messenger()->addMessage('Logged out');
    user_logout();
    $home = \Drupal\Core\Url::fromRoute('<front>')->setAbsolute();
    $f ...
Score: 0
Billy Cobin avatar
Image attachment doesn't appear in notification email
th flag

I have an image upload field where a user can attach an image. (This is for the Parts and Service page for a product site.)

On the notification email to the Service Department, the only way the image is accessible is if I display a link to the image, which appears as a broken thumbnail no matter what I do. Attempting to display the image just results in a broken thumbnail, with no link.

Insofar as th ...

Score: 0
Mathieu avatar
When I add an emoji in full HTML with CKeditor 5, I get a PHP error
at flag

I created a custom block with Full HTML text format and CKeditor 5. When I add an emoji, I have a PHP error in my Drupal 9 logs :

Drupal\Core\Entity\EntityStorageException : SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\xF0\x9F\xAB\xB6 V...' for column z33ygz_app_drupal.ymce_block_content__body.body_value at row 1: INSERT INTO "ymce_block_content__body" ("entity_id", "re ...

Score: 1
Brian Gregory avatar
Elasticsearch connector returns too many results
pn flag

We are using the Elasticsearch connector and we noticed some inconsistent results in the search, specifically on acronyms or short words like sts, .net, crm. I set the fuzziness value to 0, and this helped with the results. However, now partial word searches are not working. I played around with the fuzziness value, and even setting to a 1 reverts it back to the old result set of getting too many result ...

Score: -4
levente.nas avatar
How can I use custom HTML/CSS in the login page?
kw flag

I have custom HTML and CSS code for a login page. I want to customize my site's login form to look like the custom login page I have. How can I customize the default login page with the HTML and CSS code I have? All similar questions I saw were either outdated or didn't address this "custom HTML/CSS code" aspect.

Score: -2
TomP avatar
phpstan error installing Upgrade Status module
ru flag

I'm on a freshly updates site running PHP 8.1.12. I followed the instructions on the module page. Worked fine till the final step when it failed.

  Problem 1
    - mglaman/phpstan-drupal[1.0.0, ..., 1.1.16] require phpstan/phpstan ^1.0 -> found phpstan/phpstan[1.0.0, ..., 1.9.x-dev] but these were not loaded, likely because it conflicts with another require.
    - mglaman/phpstan-drupal[1.1.17,  ...
Score: 0
WRD avatar
How do I configure the styles dropdown in CKEditor 5?
br flag
WRD

I've got a fresh, standard install of Drupal 9.5-RC, and have added the Styles plugin to the Basic HTML text editor. The styles are set up like so:

p.test|Test P style
h2.test|Test H2 style
ul.test|Test UL style
ol.test|Test OL style
li.test|Test li style
blockquote.test|Test blockquote style
a.test|Test link style

If I select any text at all except an h2, the styles menu shows "Test P style" and "Test ...

Score: 0
xpersonas avatar
Context Definition for Taxonomy Term Not Working
cn flag

For the life of me, I can not get the taxomony term context definition to work for me. I'm trying to extend the ConditionPluginBase. I can get it working for nodes, but not for terms. I want to show a block on certain node and term pages.

When I just use the node context, it works for nodes.

When I add the term context, it doesn't work at all - not for nodes or terms.

Works

/**
 * @Condition(
 *   id = "b ...
Score: 0
How do I get a DateTime from a timestamp field?
by flag

Suppose I have a timestamp base field on an entity type. I can do $entity->timefield->value and get the UNIX timestamp.

But how do I get a DateTime object from this?

I can see there is a Timestamp::getDateTime() method which does exactly what I want. But that's the DataType class.

The field definition, TimestampItem, defines the 'value' property as a 'timestamp', so that is the Timestamp datatype ...

Score: 0
OH MY DEAR PUFFINS avatar
Database update doesn't work after update from 9.2 to 9.3
ru flag

I have unfortunately not found anything that seems to solve my issue. My Google-fu may be defunct.

I have upgraded a Drupal site from 9.2 to 9.3. This works as expected with composer (I use drupal/core-recommended). But when I proceed to update the database with drush updb, it fails with the following error:

[previous output excluded for brevity]
>  [notice] Update started: user_post_update_updat ...
Score: 0
Baud avatar
How to bulk change the source language of field labels?
sa flag

I have a French Drupal site that needs to be translated into English and Dutch. My question is only about the translation of the content types fields (label/description/...) which are configuration objects.

When I look at the source language of those fields, it is mostly set to English which is wrong. Approx 20% are set to French, which is fine.

I don't know how it comes but I am there... I would li ...

Score: 0
Riley Lutz avatar
Google API callback doesn't work
jm flag

I've created this javascript (delivery.js) that is supposed to take a pre-existing div on a webform page and append a Google Map to it, along with a few circles of differing radius.

Here is my libraries.yml, I reference the GoogleMaps global in the script url to be used as the callback.

delivery:
  version: 1.x
  js:
    js/delivery.js: {}
  dependencies:
  - core/jquery
  - core/drupalSettings
maps:
  ...
Score: 1
Numeroue0111 avatar
How to use Easy breadcrumb module so that breadcrumb reflects the URL path segments?
me flag

For example, if URL ends with /test/flower , breadcrumb should be Home/test/flower.

First time working with this module,and it's not clear to me how to do this. Could you please help me?

Thanks in advance

Score: 0
SomebodySysop avatar
How do I insert migrated file info into a file field?
gb flag

Successfully migrated public and private files to D9 system using core d7_file and d7_file_private migrations.

Now trying to migrate the file info into file fields (entity_reference_revisions:paragraph migration). My source plugin is generating the source fields, but nothing is being migrated to the file fields and there are no messages. All other fields are migrating successfully.

These are the two ...

Score: 0
florian_drupal avatar
How can I delete properly an old translation string?
cz flag

I found an old string into locales_source table, like that:

enter image description here

The associated 8.5.3 version seems outdated. I would like to understand the usefulness of the keep this data in my database ? How to clean it properly ?

Score: 1
user3463733 avatar
How do I import/export menus?
fr flag

I want to import/export all menus of site1 in into site2. Currently I am using the entitysync module to synchronize the content between two sites. I can see there is an option for "Custom Menu Links" but it will import/export only the main navigation items only.

I want to import/export:

Structure -> Menus

  1. Administration
  2. Footer
  3. Main Navigation
  4. Tools
  5. User Account Menu

Can anybody help me on this?

 ...
Score: 0
Decoy_Octopus_ avatar
How can I filter by taxonomy term after the first level filter?
cn flag

I have two content types (Book and Video), each with its own vocabularies: Book Vocabulary with Newspaper, Novel, and Magazine; Video Vocabulary with Movie, TV Show, and Documentary.

I have a view showing all the Book and Video nodes. My goal is to be able to filter by content type first, then by taxonomy terms (of the selected vocabulary/content type).

Score: 1
JBHUTT09 avatar
Create vocabularies with the JSON API
es flag

I found this identical question but it seems to be dead and none of the answers help me. I also don't have enough reputation to ask in a comment, so, since I'm at the end of my rope with this issue, I'm posting my own question.

I'll preface the issue with what I've done as I have put effort into solving this on my own:

I have the additional operations enabled:

I have the additional operations enabled

I'm using the path /jsonapi/taxonomy_v ...

Score: 0
Paige avatar
How do I get my custom module controller logic to trigger on only certain url paths?
rs flag

Hi all I am very new to Drupal and am trying to write a custom module. So my site has a bunch of different urls for example example.com/users/3 or example.com/articles/47. I want my custom module code to run whenever the user is on a path that has exmaple.com/users/.. in it.

The custom code is in the module controller and has some api calls in it using Drupals global user entity. Right now I got it  ...

Score: 0
ThuleNB avatar
Scroll to view's result after applying exposed filter
ca flag

when a user submit the view's exposed form the site is reloaded and the page's focus is not on the view's results but on the very top of the page. I use quite a few exposed filters above a table view. Locating the filters somewhere else is not possible (e.g. sidebar). I am trying to solve this using JS. My attempts:

(function ($) {

  'use strict';

  $(document).ready(function() {
    if( $('.view ...
Score: 0
leducvin avatar
How can I check if a module is enabled in settings.php?
cm flag

I've read How can I check if a module is enabled? and How can we use \Drupal class inside Settings.php and came to the conclusion that I cannot use the module_handler service in settings.php.

How can I check if a module is enabled in settings.php?

Context

I am using docker for a Drupal 9.4 installation. When I initialize a new container from the image, and I install Drupal (initialize a new databas ...

Score: 0
Dickens A S avatar
How do I use CKEditor 5?
de flag

It has been told that Drupal 9 comes with CKEditor 5.

How do I use it?

Score: 0
Print total value in footer but unable to modify footer value using hook_views_pre_render()
bm flag

Using below code to modify footer value in hook_views_pre_render() but it's not working

function hook_views_pre_render(ViewExecutable $view) {
  foreach($view->result as $result) {
    $totalamt = $result->_entity->amount->value + $totalamt;
  }
  $options = array(
      'id' => 'area_1',
      'table' => 'views',
      'field' => 'area_text_custom',
      'relationship' =>  ...

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.