Latest Drupal related questions

Score: -1
Alireza Tabatabaeian avatar
How to handle different output for a same block (Caching Problem)?
cn flag

I have a theme which has two different appearance for main menu block, so I wrote a theme suggestion like this:

function MYTHEME_theme_suggestions_menu_alter(array &$suggestions, array $variables) {
  if ($variables['menu_name'] == 'main' and Drupal::service('path.matcher')
  ->isFrontPage()) {
    array_splice($suggestions, 1, 0, 'menu__main__front');
  }
}

so that I can theme main menu for fr ...

Score: 0
quantumized avatar
Is there a way to pass a value to a hidden field to multiple blocks printed from a template file?
ng flag

The scenario is a template (tpl) file outputting a list of contact forms where each one is unique to a term ID in it section on the page. I need to generate a custom options list per printed Webform block using a tid passed from the section it's in in the template. So far I don't see any way to do this.

sample.tpl.php

<?php
   $block = module_invoke('webform', 'block_view', 'my-block-3581');
   pri ...
Score: 0
Using memcached and ip_ban simultaneously?
us flag

Memcached is by no doubt an essential tool to speed up Drupal websites. Is there a way to use the ip_ban module in order to block certain countries from accessing my website before the cached content is delivered to each visitor?

I know it's somewhat counter-intuitive, and I know there's Cloudflare WAF that may resolve this issue on the DNS level, but I wonder if there's any Drupal way of resolvin ...

Score: 1
Sergey avatar
Display breadcrumbs on the front page
us flag

I installed Easy breadcrumb module and added Breadcrumbs block to my Block Layout. However, I can not make breadcrumbs appear on the front page. Block settings do not contain any that specify block display/hide on a specific pages. I have breadcrumbs on all other pages.

I am using a subtheme of Tara theme but I have no hooks that affect breadcrumbs. I have custom modules but they do not do anythi ...

Score: 1
shelane avatar
Creating default content on site install with related entities
cn flag

We use the Default Content module to install default content on each new site of our multi-site Drupal platform. Version 2 changed to only use UUID of the content you are exporting (done from the local development environment to generate content). However, some of our default content are items like vocabulary terms which are then related to the node. But this is no longer exporting the ID, so the ID  ...

Score: 1
shelane avatar
How do you display social media feeds in a unified design?
cn flag

Our designer has asked us to create a section for the home page that will display the Twitter, Facebook, and Instagram feeds side-by-side. From her design and the discussions that followed, she would like the feed displays to all look similar. She brought up Smash Balloon for Wordpress. One, we're on Drupal and not on Wordpress and that does not exist for Drupal. Two, it's a paid plugin so I can't even  ...

Score: 0
shelane avatar
Is the content moderation "log" data available via token?
cn flag

I have several workflow states with content moderation on a Drupal 9.2 site. I use the Workbench Email module to send notifications on workflow transitions.

One of the states is Rejected; the author is notified when this state is set. I'd like to include the content moderation log message in the email template so that the reviewer can state why it was rejected and the author would get that in the email. ...

Score: 1
vyshnavi avatar
AJAX callback is fired only once
eg flag

I am using hook_form_alter() hook to add an Apply button to the node edit form.. When users click on that button, an AJAX callback replaces the text field value.

It works fine the first time, but the second time it doesn't replace the value.

function course_form_node_items_edit_form_alter(&$form, FormStateInterface $form_state) {

  $form['apply'] = array(
    '#type' => 'submit',
    '#value' ...
Score: 1
When there is a Drupal.org issue with patches on it already what is the best (most polite, easiest, most technically sound) way to make a GitLab fork?
cn flag

Scenario: There is an issue with a patch. Perhaps the patch edits a module's composer.json for Drupal 9 compatibility such that the recommended way to use the patch is as an issue fork.

What is the best way (most polite, easiest, most technically sound) way to make a GitLab issue fork with the latest patch included? Or maybe more specifically i'm wondering:

  1. There's no automated "Create issue fork fro ...
Score: 0
Is there a way to make a single type Paragraphs field not required?
sr flag

My Content Type has a Paragraphs field that is Not required. The Paragraph type has a required field for when it is added, but until it is added, this shouldn't trigger "required" for my field. Since my field only has 1 paragraph type option, it is ALWAYS added! I can Remove the paragraph from the field, and required doesn't get triggered. But every time the form loads to add a new node, it always adds  ...

Score: 0
shelane avatar
How do you batch process a path alias change for nodes that includes a menu placement change?
cn flag

We have an annual reporting sites that contains approximately 200 nodes each year. When the next year's reports are complete, all of the current year's nodes move to a path like /archives/fy2020/*. Not only do their paths change, but the menu items change as well to 1) create a new entry year 2) move menu items to the new entry year as the parent.

I am looking at what type of batch process I can used to ...

Score: 0
codesmith avatar
How do I change the main channel url?
cn flag

I've created a Feed display using a view in Drupal 8. Up at the top of the feed results I see this:

  <channel>
    <title>My Title</title>
    <link>https://www.mydomain.com/</link>
    <description></description>
    <language>en</language>

How do I change the <link> value?

Score: 2
shelane avatar
What is the proper process to customize htaccess files?
cn flag

We have custom redirect links that use the RedirectMatch rules that redirect based on a root path. We'd rather handle these at the web server level rather than using the Redirect module (if it can even do match based rules), so we put these rules in the .htaccess file, e.g.:

RedirectMatch 301 ^/computing/hpc[/]?(.*) https://hpc.our.domain/$1

Since the .htaccess file is updated with a composer in ...

Score: 0
shelane avatar
How do you provide the true last modified date header?
cn flag

We recently discovered that our internal search engine (using elasticsearch) was picking up a last modified date from the header that did not match the actual date the node was last updated. It was way off. We use Cloudflare, and I speculate that is is putting out the last cache date instead.

How do we provide a true last modified date header?

Our current work around is to use a preprocess function  ...

Score: 0
How to implement conditional shipping costs?
cn flag

I am running Drupal 8 with Commerce 2.

I have a flat-rate shipping option set up for multiple regions and I now need to increase the shipping costs under certain circumstances, eg.:

  • Order contains a specific product but not another specific product
  • Order contains a product from any category except a specific one
  • Order contains products from a certain category totaling over price x

The "rules" in the s ...

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.