Latest Drupal related questions

Score: 1
Francesco Marchetti-Stasi avatar
Use CSS preprocessor on CKEditor 4 contextmenu
iq flag

I had to customize the look and feel of the CKEditor 4 context menu for our (internal use only) module. So, I copied core/assets/vendor/ckeditor/skins/moono-lisa/editor.css to my_module/css/contextmenu.css, I changed it to my liking, and then I added the following line in src/Plugin/CKEditorPlugin/CustomInternal.php:

    $config['contextmenu_contentsCss'] = '/CLS/modules/custom/my_module/css/context ...
Score: 0
commonpike avatar
How do I programmatically assign a new book when a new node is created?
in flag

For a given content type, if a new node is created and no book is assigned, I'd like to create a new book and assign the new node to that book.

(some background - that content type is the book cover, and for editors to create a new book I ask them to create a cover first. this makes more sense for them. The 'add child page' links will then appear automatically. I know they can select 'new book' o ...

Score: -1
user108721 avatar
Getting old node field value in update hook
kp flag

Hi I'm using the node update hook in my custom .module file in my Drupal 9 site. I have a field called field_amount. And I was wondering if I can access the old value of that field within my update hook and the new value too?

function custom_module_node_update(\Drupal\node\NodeInterface $node) {
  //access the old value of field_amount and the new value
}
Score: 1
somo avatar
What is the meaning of "fields pending deletion"?
bo flag

I have a Drupal 9.5.3 installation which is not customized in any way; no custom modules or themes.

I want to remove the Comment core module but I can't and the reason that is given is:

Fields pending deletion

That's strange because I have already deleted all comments, all comment fields in any content type and all comment types and I can't think of anything else relevant to delete.

What is the mea ...

Score: 0
York Bishop avatar
How to use microsoft graph toolkit within a custom module?
in flag

I am creating a custom module and want to use microsoft graph toolkit, specifically the file-list component (https://learn.microsoft.com/en-us/graph/toolkit/components/file-list). I've created a my_module.libraries.yml file which looks like this:

mgt:
  js:
    https://unpkg.com/@microsoft/mgt@2/dist/bundle/mgt-loader.js: {}

file-list:
  js:
    js/file-list.js: {}
  dependencies:
    - core/drupal
    ...
Score: 0
jacksparrow avatar
Views posts not displaying correctly until clearing the cache
ve flag

I have an issue with a Drupal 8 website. I have some pages that have views listing some contents ( text and images). The websites uses CDN and varnish. The problem is that sometimes, the contents like images in the views display two times bigger on the page and things are scattered all over until I clear the cache (refreshing the page does not solve the issue) and only then everything displays correctly ...

Score: 0
user108721 avatar
Converting date in field-created.html.twig
kp flag

node-created.html.twig to override some html. That works fine. Although the date is being displayed as Thu, 04/28/2022 - 11:39 which I want to be something like May 2, 2023. Is this possible within this piece of twig code?

{%
  set classes = [
    'field',
    'field--name-' ~ field_name|clean_class,
    'field--type-' ~ field_type|clean_class,
    'field--label-' ~ label_display,
    'created-label',
 ...
Score: 0
Why isn't this configuration saving?
us flag

How do I do change configuration when there is a dash in the yml file?

The configuration is the following one.

source:
  plugin: url
  data_fetcher_plugin: http
  data_parser_plugin: xml
  urls:
    - 'private://migrations/migration.xml'

I need to change it to the following.

source:
  plugin: url
  data_fetcher_plugin: http
  data_parser_plugin: xml
  urls:
    - 'private://migrations/2023-05-01/migra ...
Score: 0
Md. Shafiq Hossain avatar
I can't uninstall any module after I uninstalled deprecated modules
cn flag

I have Drupal 9.5 installed and running. I have uninstalled 3 deprecated modules (Aggregator, Color, and RDF). After that, I can't uninstall any module using the user interface. It gives the following error.

LogicException: Missing bundle entity, entity type comment_type, entity id comment. in Drupal\Core\Entity\EntityType->getBundleConfigDependency() (line 885 of web/core/lib/Drupal/Core/Enti ...

Score: 0
ilechcod avatar
Can an installation profile have service.yml files?
in flag

I have a dxp_installer installation profile. I want to use the container injection for a service which I use in hook_install_tasks_alter() to verify the installation requirements. Note that I inject this service in one of my custom install forms construct, and not directly from the dxp_installer.install file.

I have defined this service in the dxp_installer.services.yml file. Now when I add containe ...

Score: 0
Madam Adam avatar
Single product with multiple variation types: set-up for a product (book) that's available as hardcopy and as downloadable file
mx flag

I'm searching for an approach for selling printed books as well as e-books in different file formats with Drupal Commerce:

  1. Hardcopy (variation type 1)
  2. PDF file (variation type 2)
  3. ePUB file (variation type 2)

While variation type 1 works fine as a regular product variation, variation type 2 is working with commerce_license and commerce_file: Product option 1 (hardcopy) will be shipped and will NOT i ...

Score: 0
alphex avatar
Entity select element - referencing taxonomy, displaying and submitting from fields on term
cn flag

I have a form, with your normal suspects of fields... First Name, Last Name, Email, A text area.

But I want to submit data to this form that will help the CRM that receives route it to the right sales person.

This data is in a taxonomy vocab we're gonna call "Service Level"

The terms in this vocab have 3 fields.

  • Name (the normal drupal field you put the term name in)
  • Searchable Label
  • CRM Email Address ...
Score: 0
Trudog avatar
Need to pass $variable from validateForm back to form even if validation fails
ru flag

It is a multipage Ajax form and I need to alter elements in a page based on form validation . This means, even if validation fails and the form stays on the same page, I need to visually alter that form page. Setting a field error with $form_state->setErrorByName is not sufficient for me so I'm exploring other options that I can't seem to find :)

I've tried using $form_state->set() and $form_stat ...

Score: 0
pierostz avatar
User form twig overwrite breaks after the submission doesn't have the current password
na flag

I am overwriting the user edit form using this code.

function demetra_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if ($form_id == 'user_form') {
    $form['field_first_name']['widget'][0]['value']['#title'] = t('');
    $form['field_first_name']['widget'][0]['value']['#placeholder'] = t('Enter your name...');
  }
}

This works fine except when the user doesn't ...

Score: 0
How can I collect shipping information?
cn flag

I can't figure out how to get the shipping address information to be collected on checkout in Commerce on Drupal 10.

My setup

  • Created a Manual payment gateway that collects billing information.
  • Installed the Commerce Shipping module (version 2.6).
  • On /admin/commerce/config/order-types/default/edit, set Workflow to Fulfillment, checked the box Enable shipping for this order type, and set the Chec ...
Score: 1
Adam888 avatar
Naming standard for long webform elements keys/options for simpler resuable coding
ph flag

I have a long multi-pages webform with mostly different groups of questions as radios, checkboxes, and likert types. I use computed_twig on some and jQuery on others for mostly either counting (how many of certain options/keys are selected) or summing up (the sum of keys values) selected values.

What's the most efficient strategy I can use and stick to so I can use less code/ re-use my code and n ...

Score: -2
Using Webform Submission, update a custom field attached to a user
za flag

EDIT: After working more on this, the user cannot be blocked and must be active / authenticated.

Using webforms, I have a form that has a field that a new user (blocked) needs to fill out to tell the admin what area they belong to. Is there a way that I can add the field value to the user (blocked, but currently filling out the form) account?

I have tried:

function helper_form_alter(&$form, FormStateI ...
Score: 0
May  avatar
search api views, sort by most viewed?
zw flag

I have a view of content. I have enabled the statistics module and in the view I can add Sort: Statistics: Total Views.

I am now trying to make a similar view page but using search api.

Have enabled search API. and followed these instructions. https://www.drupal.org/docs/8/modules/search-api/getting-started/search-forms-and-results-pages/searching-with-views/creating-a-search-view

I now have a vi ...

Score: -2
Saili Jaguste avatar
Set variable for drupal 9 website
sx flag

I need to get the hostname and then define a variable which is going to be used in all controllers of the website. I am able to call the code in controller as follows:

$host = \Drupal::request()->getHost();
\Drupal::logger('host')->notice($host);

switch($host)
{
  case 'A';
    $var = "A";
    break;
  case 'B';
    $var = "B";
    break;
  case 'C';
    $var = "C";
    break;
  case 'D';
   ...
Score: 0
Rahul.In avatar
How to enable Font Family, Font Size, Font Colour, and Justification?
jp flag

I have installed Drupal 10.0.08. on my Windows 10 PC .It is running on XAMPP framework locally.

When I want to create content (either a Basic Page or an Article node) using CKeditor 5 on Drupal 10.0.8, the menu looks like in the screenshot.

screenshot

I have enabled the full HTML option at the bottom.

I am not able to find any options for:

  • The text font
  • Justification options (right, left, center, justifi ...
Score: 0
Chike avatar
Set default values of a webform element from a field on a user account
cn flag

On a user account I have field field_hourly_rate which is a price field (I can also use a number field for it) and I am trying to set the field as default value of an element for a webform placed on the user account page.

I have tried [current-user:field_hourly_rate], [current-page:query:field_hourly_rate], [webform_submission:user:field_hourly_rate], [webform_submission:source-entity:field_hourly_ra ...

Score: 0
Chandra avatar
Option to export path alias not showing in view (pathauto is installed)
jp flag

On my new D 9.5.x site, I have pathauto installed, and it is working well. That is, neat alias URLs get generated for my articles as expected. I am now trying to export articles from the site. I have the views data export module installed, but when I create the export, I don't see the alias path available as a field to choose (as 'Content: Path' or anything else. The other article fields are availa ...

Score: 0
Patrick Man avatar
How to add "all" option to exposed filter?
cn flag

I see this discussion for Drupal 7 but am trying to do something similar in Drupal 9.

My view is called "content_display" and the display I am trying to affect is called ct_list (see screenshot). enter image description here

Currently an exposed form sorts by title(screenshot).enter image description here

The All option is defined in the view and going to path/all shows all just like path/a shows articles starting with the letter a.

Seems like I need a hook ...

Score: 0
FrankieD avatar
Multiple Custom Module Event Subscribers Override Each Other
et flag

I've been working on custom modules that alter RequestEvents based on the entity type provided by the route.

The functionality from one entity to another doesn't change, but the data does, hence I split the module. The working example extends a class provided by a base module that holds the core functionality.

I'm not sure if it matters, be it run order precedence or what have you, but the names  ...

Score: 0
How to programatically update a field for a revision?
br flag

What is wrong with this approach for updating a field value in a specific revision:

public function myTest() {

  $test = 'mytest33';

  $node_revision = \Drupal::entityTypeManager()
    ->getStorage('node')
    ->loadRevision(10364);

  $node_revision->set('field_my_field', $test);
  $node_revision->save();

  return [
    '#markup' => 'Test page.',
  ];
}

When I load this simple test  ...

Score: 0
Commerce 2 - switch variation ajax error
ng flag

I'm building a commerce site, one problem that I have is that the variation switch that works with ajax is having problems on the production server.

I have analyzed the network tab of DevTools, the situation is the following:

  • I go to a product and can switch between its variations.
  • If I add a product to the cart, then I cannot switch to another variation, the ajax request is made but instead of returning ...
Score: 0
Install Drush Launcher on MacOS Ventura on a Apple Silicon (M2) machine
pe flag

I know this is not really a Drupal question but rather Drush. Maybe a Mac user can help me.

I installed drush launcher under MacOs Ventura on a Mac M2 by following the procedure.

Running drush st (for example) after sudo mv drush.phar /usr/local/bin/drush gives me this error.

zsh:permission denied:drush

I changed the permissions but I still get the error. Can you give me any advice?

Should we pu ...

Score: 2
How to programmatically grant access to view unpublished content with a special query string?
br flag

In my application, I want anonymous users to be able to view an unpublished node but only if they append a special code to the URL. For example:

www.mysite.com/node/123?code=Hx23ufG38

I figure I can do something in a preprocess function to check if the code is appended to the URL and, if so, allow the user to view the unpublished node. (This clearly is not for a use case where the content is sensiti ...

Score: 0
Can't get real field value from paragraph
in flag

I need to get value from exact paragraph type in paragraph reference field in node, so I can use it in Twig.

Here's my current code:

function my_theme_preprocess_field(array &$variables, $hook) {
  if ($node = \Drupal::request()->attributes->get('node')) {
    if ($node->getType() == 'page'){
      foreach ($node->get('field_sections') as $paragraph) {
        if ($paragraph->entity ...
Score: 0
Ken Williams avatar
Trouble upgrading 7.90 to 7.91
cn flag

I'm trying to keep a D7 site up to date, it's currently running 7.90. I tried to upgrade to 7.95, but I ran into trouble, and eventually figured out that it's the 7.90->7.91 transition that's breaking.

The symptoms of the breakage are that a bunch of files can't be loaded, which causes the styles to break:

console logs

In drush ws, I'm seeing a bunch of errors I don't understand:

 ID       Date           ...

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.