Latest Drupal related questions

Score: 0
Override a access check but also pass control back to the primary controller under certain conditions?
cn flag

I use a contrib controller that has a _custom_access function that I need to override.

I add a RouteSubscriber, and point the access check to my own controller. Now I want something like:

if ($condition) {
  return $new_access_decision;
}
return $original_controller->accessCheck()

so I can contrinue to rely on the original logic for most cases, and just override for a small subset of cases.

I don't kn ...

Score: 0
Middle part of a page disappears and appears again after flushing all caches
cn flag

Sometimes middle part of some page at our website may disappear and only header and footer are still displayed. The problem is always solved after flushing all caches.

Our html.html.twig loads templates a way like

{% include '@themename/header.html.twig' %}
{{ page }}
{% include '@themename/footer.html.twig' %}

And our page.html.twig loads an appropriate template depenging on the page path like

Score: 2
Programmatically get a full page html rendering of a route/page
cn flag

We provide our content via APIs. At times we use the Views Restful approach, and at times the JSONAPI.

We need to add an API field on nodes that is a full HTML rendering of that node's page according to the theme (technically I just need ... but I'll take the whole doc if I can get it).

I have tried a number of approaches:

I tried using the renderer service. It renders full html from the html.html.twig ...

Score: 0
How can I load a template from a custom module on a certain page?
cn flag

I have a page at path /user/{id}/module, and I'm trying to have Drupal load a custom template from my module when this page is accessed.

The twig debug output shows suggestions for the template name like below, but it doesn't seem to pick the template up even after cache rebuilds. The page needs to show for all users so cannot pin it to a specific id, but html--user--module.html.twig is not respected ...

Score: 1
How migrate rich text fields from outside Drupal without converting html tags to entities
pe flag

I'm working on a migration from a non-Drupal site into Drupal 9. So far, I'm using migrate_plus, migrate_tools, and migrate_source_csv modules. The data I'm importing has <br> and other tags in some fields. When these import, the <br> tags are visible on site pages after the migration completes.

The source is a tab delimited file.

Looking at the page code, these are rendering as html entitie ...

Score: 0
zanvidmar avatar
Redirect existing file url to url
sa flag

I have existing file with url: https://example.com/sites/default/files/public_files/pages/example%20documents/document.pdf

and I want to redirect it to: https://example.com/en/new-url

I did not find the modul that could do this (and AFAIK Drupal is not even fiering when public file is accessed directly) and I tried with adding .htaccess rule in docroot.

RedirectMatch 307 sites/default/files/public_f ...
Score: 1
Disable certain rows of a Entity Reference Source view
in flag

I have a field that is an entity reference on a piece of content. I created a view that is an Entity Reference Source and set the reference type on the field to that view. When editing the content, I see my list of checkboxes using that Entity Reference Source view.

The data in the list are tournaments. Once a tournament is completed, I do not want the user to be able to uncheck that tournament when  ...

Score: 0
elektrorl avatar
Transform the view mode of a content type into the class of the body
cn flag

I want to add the view mode of my content type as a class to body and I use Display Suite so $node['view_mode'] is not available.

In MYTHEME_preprocess_html(&$variables), I injected the service \Drupal::service('entity_display.repository') and \Drupal::service('entity_display.repository')->getViewModes('node') returns the list of all view modes for this content type.

How can I find out what ...

Score: 0
Delford Chaffin avatar
Composer Remove leaves files and references in composer.lock
gg flag

I'm trying to update my site from D8 to D9 and there are a few modules I no longer need and am trying to get rid of. I run composer remove drupal/varbase_core and it removes it from my composer.json, but leaves several references in composer.lock. I look in the file system and the files are still there and the next time I run composer update, the files are restored.

How can I actually get rid of thes ...

Score: 0
Andrew Morris avatar
Creating tabbed config settings
mw flag

I'm trying to create a tabbed configuration page for my custom module, although I can't see a lot of information on exactly what is supposed to be done.

I've seen this page but it's not exactly in depth

I've got my pages listed in my my_module.routing.yml file

my_module.api_form:
  path: /admin/config/system/my-api
  defaults:
    _title: 'Configuration'
    _form: \Drupal\MY_MODULE\Form\APIConfigur ...
Score: 0
Michael Anello avatar
Change order of elements in a Webform Variant
to flag

I am trying to figure out if it is possible to change the order of elements in a webform variant.

Using a very simple example form with two elements, I created a new variant and then overrode the "Elements" yaml two different ways, neither which changed the order of the elements on the form.

First, I simply switched the order of the elements in the yml, which didn't change anything. Second, I added  ...

Score: 1
Greg Sims avatar
Error: Call to undefined function drush_shift()
us flag

We recently moved to Drupal 9.3.0 with a composer file layout and Drush 11.0. We make use of Drush Scripts to execute website functions from Crontab. One specific case is sending a newsletter email early each morning.

I receiving the subject error from a Drush Script that has been running for years. The script is executed by moving into the webroot directory of the website and running drush scr em ...

Score: 0
Product parameters on add to cart form which not changing product variation
ng flag

I have a phisycal product with many many combinations. E.g.: a mug which is available in 20 different colors and with 30 different prints. This means 600 combinations. We don't have stock. We don't have different SKU for different color-print combinations. We don't have pictures for all combinations, prices are same etc so there is no reason why the 600 products should be upload one-by-one as 600 differ ...

Score: 1
Referencing disabled users during migration
in flag

I have migration that creates files. For file owners I'm trying to find existing user by email and if don't find I create one on fly. Problem is that those users I'm creating must be disabled (I don't want them to login to site). But if I disable them and I try to use them as file owner I get the message:

"This entity (user: 187) cannot be referenced."

I can disable validation for that migration fil ...

Score: 0
Mark Edwards avatar
Passing parameters to view blocks in Twig
pl flag

Running Drupal 8.9.18

I have a string that I want to pass to a Drupal block for use in a contextual filter. In a twig template I have a view that creates a simple list of the terms to use. I extract the string from the result array, map the required string to a variable that I pass as a parameter to another view block:

{% set view-output = drupal_block('views_block:view1-block_1') %}

{% for item in v ...

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.