Latest Drupal related questions

Score: 2
shelane avatar
How do you display a version number on a footer file?
cn flag

When I deploy my Drupal code, I build an artifact with BLT. I would like to write a file of some kind with the version number (tag provided to the artifact) that could then be read and displayed in the footer.

Where is the best place to write this file in a Drupal directory?

What is the best method to read from the file and display on the page safely?

Is there a different/better method altogether that  ...

Score: 0
quantumized avatar
Is there a way to not render blocks for mobile devices that works for anonymous users?
ng flag

I'm trying to dynamically render a block on for desktops. I've tried detecting in a page preprocess and using the set variable to dynamically render the block in the page template but there seems to be an issue with anonymous users and caching the value.

There's a module called Mobile Detect that is supposed to accomplish this but it seems to be plagued with the same issue for anonymous users:

htt ...

Score: 0
Mike Burman avatar
Add to Cart button shows in Product/Views But not anywhere else
us flag

Add to Cart button shows up only in Product/Views/blocks, But not anywhere else. It doesn't show anywhere else either logged in or not. There are variations, skus, price in most products, but no button. Appreciate advice, thanks Mike B.

Score: 0
Lambic avatar
Using #states on an inline paragraph form
ph flag

I have a field on a custom content type which is a reference to a paragraph type, using the Paragraph (EXPERIMENTAL) widget. I'm trying to modify that widget to show and hide a field based on another field on the paragraph. Here is my widget alter code:

$field = 'field_supporter_form_fields';
$id_field = 'field_primary_custom';
$delta = $element['#delta'];
$id = sprintf('select[name="%s[%d][subform ...
Score: 1
Ryan Brownell avatar
Display WYSIWYG editor group names to endusers modifying content
gw flag

When one is editing the Toolbar Configuration in a Text Format in Drupal 8, group names can be added to the editor as part of grouping the buttons in the toolbar.

Is it possible to expose those group names to endusers who use the editor to edit content? If so, how?

Score: 0
Drupal hubspot forms with Varnish
br flag

I have a Drupal 8 hubspot form built in a custom module which holds many fields among which a "Favorite Pizza" field coming from hubspot and this field is rendered as a required fieldset. The code is very long so I decided to explain to you the process instead:

  • In the Drupal buildForm function, we call an external hubspotbuildForm function
  • Inside this function, I collect the following cookie in php ...
Score: 1
Neograph734 avatar
Can I use the session service directly instead of via the request?
co flag

The Drupal documentation on sessions mentions that sessions can be accessed via the Request object:

Session data is accessed via the \Symfony\Component\HttpFoundation\Request::getSession() method, which returns an instance of \Symfony\Component\HttpFoundation\Session\SessionInterface. The most important methods on SessionInterface are set(), get(), and remove().

However I've also dicovered there is ...

Score: 0
How to assign css class to an image in CKEditor
cn flag

I migrated a site from Drupal 7 to 8. In Drupal 7, there was the Image2 module, which isn't available in Drupal 8.

I inserted an image in a block I created and assigned the CSS classes to the block. It didn't work.

How can I configure/extend CKEditor that Editors are able to assign (different) CSS classes to (different) images?

Score: 0
quantumized avatar
How can I get a list of all languages translation that a node has?
ng flag

I'm trying to get a list of language translations that a node has in theme_preprocess_node(). I have the node object and can check for a translation on a one-by-one basis, if I have the list of languages. What I need is a list of all the translations for the node.

Score: 0
PHPUnit throws error: \Drupal\Tests\DocumentElement class not found
fi flag

I have added some phpunit tests to my custom module. When trying to run them in I get this error: Class '\Drupal\Tests\DocumentElement' not found I have copied core/phpunit.xml.dist to core/phpunit.xml and edited the URL and DB values but nothing else.

The command I'm running is vendor/bin/phpunit -c web/core/phpunit.xml web/modules/contrib/my_module/.

It seems that the classloader is not working. What  ...

Score: 2
Ed Coakley avatar
EntityQuery where multi-value field contains a value
de flag

I've been programming for 15 years, 10 with PHP, but on my 1st Drupal project. Using Drupal 9.

I'm trying to retrieve an entity (custom content type) that has 2 multi-value entity (user) fields. If the value I have is in one field I want to get the other one. The problem is I can't figure out how to ask for the entity when the scalar value I have is in the list. Here's what I've got:

return \Drupal::e ...
Score: 1
liquidcms avatar
How to build core test database?
us flag

Fifteen years writing Drupal code and yet I have never written unit tests. I have recently posted a couple core patches which require tests to be written for them - so good time to learn how to write PHPUnit tests.

I have a test environmnet set up and am able to successfully run core unit tests. I need to extend these tests which I can see is not very difficult; but I need to run against the "tes ...

Score: 0
Using root source property within migrate sub_process plugin
gb flag

I'm performing migration from Drupal 9 into another Drupal 9 project. Let's say "content features" migration.

In a node migration I'm trying to create stubs for media items.

The media source has two id keys: mid, langcode. The mid key is getting from field's target_id property. But there is no language property on field's level and I'm trying to pass node's language as second id value for the medi ...

Score: 1
Leeroy avatar
Redirect directly to the payment provider page
ca flag

I'm building a store with Drupal Commerce and creating my own off-site payment gateway. On the review page, after selecting payment method, the user can click the button to pay and finish the order. After that he's redirected to a page that tells him to wait to be redirected to the payment provider.

Is there a way to redirect the user to the payment provider without needing to go to this useless  ...

Score: 0
Павел Герасюта avatar
Override the field template in the view
br flag

I have a view that outputs the fields needed and I would like to change the template of one field in this view. I need exactly override the views-field-field-product-color-field-color-color field template as field.tpl.php , but I can't do it in any way. Can anyone help? enter image description here

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.