Latest Drupal related questions

Score: 3
user780 avatar
How can I override the node template for one multi-site instance?
gb flag

I have several Drupal 9 sites on multi-site setup. currently all these sub sites use one theme placed in /themes/MyTheme folder.

now i need to theme few nodes on site A and site B and this is only difference between all sites. if i use page--node--x.html.twig convention to change layout of node x on site A, it changes layout of node x on all sites.

what is easiest way to apply page--node--x.html.twig ...

Score: 1
How to send a contact form via JSON:API?
cn flag

What are the requirements for submitting the contact form using JSON:API?

I enabled the core Contacts module and set up a custom site-wide contact form. I gave permission to anon + auth users to submit the form.

Next, I enabled JSON:API. I can see the contact form at /jsonapi/contact_form/contact_form:

"data":[
   {
      "type":"contact_form--contact_form",
      "id":"d97e73f1-7d06-4bf0-b05b-1c654 ...
Score: 0
0711master avatar
Bibcite: How to sort publications by last name of first author?
cn flag

Bibcite module: I have a view which shows all publications and I'm using the citation field. But every publication is shown as many time as many authors it has. When I'm using aggregation (count distinct) on one of the sorting items only one publication per year is shown. Also sorting the list by "Contributor: Last name" doesn't work. What is the "official" way to sort publications by the last name of t ...

Score: 1
elneto avatar
drush configuration import export order of the yml
in flag

I recently upgraded some minor versions of modules and upgraded Drupal core-recommended to 9.3.3 from 9.2.9. I followed the usual drush updatedb, drush cim -y drush cr and everything looks fine.

In my local env, everything is fine. However, in my dev environment in platform.sh, drush cim keeps importing ALL 860 config files. It doesn't matter how many times you run drush updatedb, drush cim -y an ...

Score: 0
How to extend core block class SystemBrandingBlock
ph flag

Please advice how we can extend the core block class Drupal\system\Plugin\Block\SystemBrandingBlock to add custom method.

In my case, I want to include function buildToArray() to get the block data in array format rather than rendered array.

Existing build() method:

public function build() {
    $build = [];
    $site_config = $this->configFactory->get('system.site');

    $build['site_logo'] = [
  ...
Score: 0
Jim D avatar
Publishing Options for Content Type Not Showing
kh flag

I am on version 9.3.2. When I change the Publishing Options for any content type, nothing changes on the node's edit page or the new content page. Not sure when this changed, but a year ago it was working.

Any idea how to get the publishing options to show up as expected once again?

Score: 1
How do I display field from one content type in another content type
cn flag

I am working with Drupal 9. I found other questions similar, but I do not understand what they are saying to do, and they are 10+ years old so I do not know if they still apply.

Maybe the best way to describe this is how a SQL JOIN might handle it in a query. I created a simple scenario to explain this. In SQL it might be:

SELECT Children.ParentID, Children.ChildID, Children.Name, Parents.Name FROM  ...

Score: 0
Problems with core update from 7.83 to 7.8x
us flag

Since a few weeks I have problems with the drupal core update. I am on version 7.83 and as 7.84 was released I've tried to install it as usual, (clear everything beside the sides folder an some theme files, then ftp the new files on the server and update the database with update.php) but the database update allways shows the message "no pending updates" which should not appear according to the UPGRADE.t ...

Score: 0
smeys avatar
Do something when a content is saved
lc flag

I'm a total beginner in module coding and i'm trying to adapt a simple D7 module which is updating a field from a content type from an external API when the content is created or modified.

On an fresh D9 install, i've created a module named : edu_module

Created a folder /custom/edu_module in the module directory

Created a edu_module.info.yml

Activated the module => OK

and at last created an edu_modu ...

Score: 0
Lambic avatar
Entity route requirement not working
ph flag

I'm trying to get the following route working but the entity bundle requirement won't work. If I switch requirements to _access: 'TRUE' it works but entity checks are not working. I've traced it to EntityBundleAccessCheck.php where the node parameter is a string containing the node ID instead of the loaded entity, but I'm not sure why.

entity.node.send:
  path: '/node/{node}/send'
  defaults:
    _ ...
Score: 0
0711master avatar
ERROR 1062 (23000): Duplicate entry '/-de' for key 'PRIMARY'
cn flag

When importing a dump from a production site with mysql in a xampp environment I got this error:

ERROR 1062 (23000): Duplicate entry '/-de' for key 'PRIMARY'

These lines are affected:

ALTER TABLE `redirect_404`
ADD PRIMARY KEY (`path`,`langcode`);

Strangely when importing the sql file into another database on the production server, it doesn't show any error.

Score: 0
How set html 'lang' to match node 'langcode'?
id flag

I would like to change a node's html 'lang' from site's default to the node's 'langcode'.

For example, if I create a node and while creating I select French as the language, I would like the page's html 'lang' to "fr"

So far I have this:

  /** @var \Drupal\Core\Template\Attribute $html_attribute */
  $html_attribute = $variables['html_attributes'];
  $node_langcode = $node->get('langcode')->value;
 ...
Score: 0
Filter Entity Queue by Taxonomy Term ID
cn flag

I am loading am entity queue and placing it on a node as a block. Using contextual filters in a view I am getting the term ID from the current node. I need to use that term ID to filter down my entity queue. My current code loads the entire queue. Is it possible to filter nodes in the queue by the current tid?

This is how I am loading the queue within hook_views_query_alter

$query_subqueue = \Drup ...
Score: 0
Josh avatar
Aggregation causes problems with a computed field
yt flag

I am running a Drupal 9.3.3 site and I have created a computed field in my custom module. After adding the computed field, I can no longer save a view if I also have aggregation turned on. I get this error when trying to load data or save the View.

Drupal\Core\Entity\Sql\SqlContentEntityStorageException: Column information not available for the field_computed_poc field. in Drupal\Core\Entity\Sql\Default ...

Score: 0
Drupal 7 and/or CKEditor adding paragraphs to code breaking styling
th flag

I've recently started a new job where I'm managing a Drupal 7 website for the first time. We will be moving away from this platform soon, but I have to maintain this site for the time being.

I'm trying to add a new form to one of our pages, but paragraph tags are being added after saving the code in the CKEditor which is breaking my styling.

Here is the relevant code added to CKEditor with rich text ...

Score: 3
Drazen avatar
Which is better way of injecting service to controller with __construct or $instance = parent::create($container)
ru flag

I'm always using this way of injecting service to controller:

<?php    
namespace Drupal\TestModule\Controller;
    
    use Drupal\Core\Controller\ControllerBase;
    use Symfony\Component\DependencyInjection\ContainerInterface;
    
    class TestModuleController extends ControllerBase {
    
      protected $testModule;
    
        public function __construct(TestModule $testModule) {
       ...

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.