Latest Drupal related questions

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           ...
Score: 0
Chandra avatar
Migration entity_lookup not picking up repeating taxonomy terms
jp flag

Background: I am creating new articles in Drupal 9.5 from a source database using the Migrate API. The articles optionally have references to one or more taxonomy terms. I have already created the taxonomy terms in Drupal manually, they look good. I then use the entity_lookup process plugin to lookup the taxonomy IDs as part of the article migration. But when the taxonomy terms repeat, they don't se ...

Score: -3
Tomáš Bažant avatar
Preventing one site from redirecting to www. prefix in multisite
de flag

I am using Drupal 9, multi-site. Generally, for all sites except one, i want to redirect from non-www to www prefix and i'm using the root .htacces file for it by uncommenting redirect rules. But the one site is 3rd level domain such as noha.ruka.cz and i dont want this particular site to redirect to the www prefix. Any idea?

Score: 0
Wayne Foster avatar
I'm unable to run Drush v8.4.12 on PHP 8.1.6 using Bash on Windows11
in flag

I'm on the final two sites to migrate to D9 - but some D9 modules are now needing PHP 8.1 to stay on the latest upgrades. So - I've changed my server environment to use PHP 8.1 - and using XAMPP for Windows 11 - on PHP 8.1.6 - as per the Drupal.org PHP recommendation.

Only issue is - I'm now unable to use drush to update my remaining D7 sites. Has anybody got this to work on Windows 11 - using ...

Score: 1
Pipo Bizelli avatar
How to get Paragraph Changed Time?
nz flag

I know how get User entity changed time ($user->getChangedTime()).
Node has the same value ($node->changed), but I need to get this changed time from a Paragraph.

When I try this method $paragraph->getChangedTime() (the value changed do not exists) i got this:

Error: Call to undefined method Drupal\paragraphs\Entity\Paragraph::getChangedTime() ...

I have this field in my User entity, and I need t ...

Score: 0
Loopy avatar
Troubleshooting issue forks to make core version compatibility fixes
cn flag

During the Drupal 8->9 upgrade, we noticed an issue where module maintainers had abandoned a project or were not responding to merge requests in a timely manner. As you know, composer doesn't care about patches when it comes to compatibility with major versions of Drupal, so you need an actual release which is compatible with the next major version before you can update drupal core in composer. This  ...

Score: 0
Adam888 avatar
Is there a simpler way to sum selected options in Webform computed_twig
ph flag

I want to sum up all values of selected radios (all q_ keys checked values) in a Drupal Webform form. Now I am doing it like this {% set answersTotal = (data.q_1 + data.q_2 + data.q_3 + data.q_4 + data.q_5 )|number_format %} {{ answersTotal }} and it's working fine but I want a more efficient/simpler way to avoid having to type all the data.q_# as there are many q_ in each group. I tried this (in a ...

Score: -3
David avatar
Update entityManager()->getViewBuilder from 5 year old site?
sy flag

I have a Drupal 8 module which hasn't been updated for 5 years. I m trying to update to current version of Drupal.

The error I get is

Error: Call to undefined method Drupal::entityManager()

The code causing the error is below.

      $viewbuilder = \Drupal::entityManager()->getViewBuilder('paragraph');
      $data = $viewbuilder->view($paragraph);
      $array['#cache']['tags'][] = 'node:' . $n ...
Score: 0
Use a different template file for front end and submission view
ng flag

I have defined a custom template file referenced via #theme for my custom webform element.

public function getInfo() {
  $class = get_class($this);
  return [
    '#input' => TRUE,
    '#process' => [
      [$class, 'processWebformElementSeatbooking'],
      [$class, 'processAjaxForm'],
    ],
    '#element_validate' => [
      [$class, 'validateWebformSeatbookingElement'],
    ],
    '#pre_ ...
Score: 0
sudhan avatar
When doing views Rest Export the response has media field where i also want alternate text, how to get them as response
us flag

I am getting rest response through views and when i try to get response with field media i also need to get image/media alternate text.I tried to set through relationship for the particular media field and then fetch the alternate text but i receive in html format with html tags , how to get only the alternate text in plain text format. Please help.

Score: 0
Claudia Burman avatar
Menu from Views page display using contextual filter taxonomy term
im flag

Classified ads site here, Drupal 10.0.7

I have a View page display showing fields from nodes using Taxonomy Term Id as Contextual Filter. So if the URL reads "[domain]/clasificados/8" it shows all fields of nodes tagged with term 8

How can I generate a menu from that vocabulary that points to "clasificados/{id}" ?

Taxonomy Menu generates "/taxonomy/term/{id}"

Thanks.

Score: 0
awm avatar
Prevent last updated property from changing when updating node in code?
mx flag
awm

I have this code that updates a node in a queue worker:

      $changed = $entity->getChangedTime();
      // Don't update the changed time by 
      $entity->setChangedTime($changed);
      $entity->set('my_field', "my_data");
      $entity->setNewRevision(FALSE);
      $entity->save();
      

Here is a screenshot of xdebug showing changed and after_save value with the relevant co ...

Score: 2
Souvik Das avatar
Append new paragraph item to existing node
rs flag

I want to append a new paragraph item to a existing node, which has previously a paragraph item. I just want to add another paragraph item with the previous one. But my script only updates the previous added paragraph item with the latest data, not appending with the previous one.

$nid = \Drupal::entityQuery('node')->condition('title', $product_name)->execute();
        $nid = array_values($n ...
Score: 0
Jaypan avatar
Programmatically render block content render array with wrappers
de flag

I'm trying to render a custom block, created through the UI, programmatically with a wrapper. I can do this:

$block = \Drupal::entityTypeManager()->getStorage('block_content')
  ->load($bid);

$output['header'] = \Drupal::entityTypeManager()
  ->getViewBuilder('block_content')
  ->view($block);

And the block is rendered, but only the fields of the block - the block wrappers are not rendered. ...

Score: 0
AllisonC avatar
Twig output not styled correctly
cn flag

In one of my twig templates, I have:

<pre>{{ dump() }}</pre>

Twig output looks like:

Sfdump = window.Sfdump || (function (doc) { 

enter image description here

Controller (partial code):

$renderable = [
  '#theme' => 'child-profile',
  '#profile' => $records,
];
$output = Drupal::service('renderer')->renderPlain($renderable);
return [
  '#type' => 'markup',
  '#markup' => $output,
];

How can I get this  ...

Score: 0
awm avatar
How to make a traditional entity field excluded from revision?
mx flag
awm

Is it possible to make an entity field excluded from revision? I want to avoid creating revision table for the field if possible. Otherwise, just excluding creating revisions is fine.

I tried to alter the field definition in code:

function mymodule_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
  if ($entity_type->id() === 'node' && isset($fields['field_my_fi ...
Score: 0
Best practice for user specific data related to specific nodes
in flag

I have a content type travel_locations wich contains multiple fields (such as title, body, geolocation, etcetera). Now I would like the user to reference nodes of this content type when for example he has visited this location, together with specific data about this visit (traveldate, rating, textfield for travelnotes etcetera). The specific travel data will probably be collected trough paragraphs modul ...

Score: 0
Kevin avatar
Apply Context/Conditions to a Views result item?
in flag

If you are using Context for a node, the node itself typically comes from the node page you are on. In some cases, you may want to apply the same context to views results on a node as well - but they are getting the same argument instead of the node of the result. How can you supply the result item as the context argument to conditions?

Score: -1
Sundar Raj Ponnulingam avatar
How do I set a plain text field value to be empty?
to flag
<?php
function MY_MODULE_node_update(NodeInterface $node)
{
    if ($node instanceof \Drupal\node\NodeInterface) {

        $nid = $node->id();
        $nodeType = $node->getType();
    
        $vid = \Drupal::entityTypeManager()
                ->getStorage('node')
                ->getLatestRevisionId($nid);

        $comments = $node->get('field_workflow_comment')->getValue();

   ...
Score: -4
Jimmy avatar
What is the correct procedure for creating multi-instances and websites?
sk flag

I have installed Drupal 10 and it is working with no issues. I can create my first multi-instance with a single website with no issues.

The problem I have is when I create my second website in the default instance; all of the links in the second website point back to the first website by default. I am assuming the method I am using to create Drupal 8 websites is not the same as it is now in Drupa ...

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.