Latest Drupal related questions

Score: 2
Dynamdilshan avatar
Is it possible to run Drush commands during the build stage of a deployment pipeline?
in flag

Apologies in advance for the long questions.

Background:

We are building a 4-step AWS pipeline to deploy our site to an ECS container.

The stages are as follows:

  • Source
  • Build
  • Deploy
  • Post-deploy

At the moment we have ECS commands running on Deploy stage to execute the Drush commands(drush cim -y/drush updb -y/ drush cr)

Due to some reason the ECS commands execution is not consistent and we need t ...

Score: 0
Delford Chaffin avatar
Order item entity/field definitions
gg flag

On my Status Report (Drupal 9.4.8), I see the following error.

Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.

Order item

  • The ID field needs to be installed
  • The UUID field needs to be installed
  • The Order item type field needs to be installed
  • The Order field needs to be installed
  • The Purchased entity field needs to be installed
Score: 0
How can I setRequired() for a BaseFieldDefinition per entity bundle?
cn flag

I have an entity type animal with the following bundles:

  • cow
  • pig
  • sparrow
  • anteater

In the Animal.php entity type definition, I create some base fields, one of which is an entity reference to Habitat.

BaseFieldDefinition::create('entity_reference')
  ->setLabel(t('Habitat ID'))
  ->setCardinality(1)
  ->setSetting('target_type', 'habitat')
  ->setDisplayConfigurable('form', FALSE)
  ->setDi ...
Score: 0
How to set up search_api to search short words with special characters
us flag

I was trying to set up search_api but I feel like I have tried all the settings and nothing seems to work. I need to search for names of products, e.g. "T+A M 40 HV". When I apply the search, "T+A" gets split into "T" and "A" and the "+" sign is ignored. "M" is also ignored because it's only 1 char and I have a setting where the search only starts searching if the word is min. 2 chars.

Can I some ...

Score: 0
af_elkb avatar
How to set the default value for media entity in content type in a user friedly way?
in flag

In a new content type (Drupal 9) I have an Entity Reference field for Media (Image). I already chose and saved a default media entity in the field settings.

Unfortunately when creating a new node of this content type a user needs to remove the default media entity first before being able to upload his/her image. Since this seems not very user friedly I wonder whether there is a way to avoid this. ...

Score: 0
Jaswin Singh avatar
Why are Nightwatch tests failing in this Lando environment?
jm flag

I'm setting up Nightwatch for drupal 9 in Lando based project. When executing the lando nightwatch --tags core. All the test cases are failing (even the core). Below is the lando.yml file.

name: night-watch-test
recipe: drupal9
config:
 webroot: docroot
 xdebug: false
 php: '8.0'
 composer_version: '2'
 config:
   php: .lando/php.ini
   mysql: .lando/mysql.cnf
proxy:
 appserver:
   - site1.lndo.site
   -  ...
Score: 0
Stefan Gofferje avatar
Get all taxonomy terms from one vocabulary used by articles with a term in another vocabulary?
cf flag

15+ years Joomla user but Drupal newbie here. Taxonomies are causing me a little bit of a headache. For my articles I have set up 2 taxonomy vocabularies: Category and Tags. Each article can (must) have exactly one Category but can have multiple Tags.

What I would like to have is a block which shows all Tags used in all articles which are in the same Category as the article which is displayed. I  ...

Score: 6
How to override the typehint for entityTypeManager with a more specific one?
cn flag

I'm often frustrated by entityTypeManager because when I load entities, the typehint for the return value of the load methods is EntityInterface, but I want it to be a more specific interface (which I know it will be because I am loading a specific entity type with getStorage).

So, for example, consider this code adapted from the Flag module:

  /**
   * Loads flagging entities given their IDs.
   *
    ...
Score: 2
How can I sort results by contextual filter value?
do flag

I have a set of pages that use path information to - amongst other things - create view of relevent news articles.

eg:

mysite.com/city-service
mysite.com/country-service
etc

I have an existing view that uses a contextual filter to extract the relevant portion of the URL and then look up relevant news articles that are tagged with an organisation tag that maps to each service.

This works great, but ...

Score: 0
Sarah C avatar
Use term id token in Display Suite expert field template
za flag

I have a term field that I want to display on my content type. I want to customize the Display Suite field template to use the token [term:tid]. So I use the expert field template and put the token where I want.

However, the token is simply not showing up. If I go back to check the field template, it has reverted from Expert back to default.

I have Display Suite enabled by giving the view mode a  ...

Score: 0
Entity queue: Can I use entity browser for selection but keep a draggable table for re-ordering?
cn flag

On a Drupal 9 site we have an entity queue. We would like to use a draggable table for re-ordering but when the editor clicks "Select entities" they would like to use a modal entity browser using a views display so that they can see multiple fields, use a few exposed filters etc.

Is this possible? If so what are the configuration steps? Do I need to have a custom admin theme? I am currently using ...

Score: 0
Ian avatar
Why does adding data- attributes to JavaScript libraries prevent them from being aggregated?
pa flag
Ian

I'm having an issue with adding a data attribute to my preprocessed / aggregated javascript within my theme.

When I have preprocessing disabled, I am able to add a data attribute to individual files within the .libraries.yml file as suggested within the Drupal docs. {attributes: {data-example-attribute: true}}

However once I enable ['js']['preprocess'] = true; to the settings.php file instead of my them ...

Score: 1
Vitaliy K avatar
How to use field value to set custom class and apply it to a html element in node.html.twig without using attributes and addClass()
tr flag

I have tried to apply my custom class to an image tag

I have set classes for it

{% set imgClass = [
        'img-shape-' ~ (node.field_image_animation_shape.value|clean_class)
      ] %}

and have tried to apply to image as attributes

 attributes.addClass(imgClass)

that is renders all attributes for the node which duplicating on main node div so i need to avoid using attributes... How do i do it?

 ...
Score: -2
user108425 avatar
How can I get the field value from preprocess_field?
je flag

I would like to get the content of the field with is formatted text to manipulate it a bit (strip from HTML tags and limit) and display it as another variable in twig.

How can I get the value of the field?

This is what I've written so far, and I tried to output the value in the "if statement", but no luck so far:

function bootstrap4grow_preprocess_field(&$variables) {
  if ($variables['field_name'] = ...
Score: 1
TheScripterX avatar
drupalTranslations is not defined
ec flag

I'm an Angular front-end developer. I work with a team that uses Drupal for content.

The scenario is that we use Drupal.t() to translate the strings.

When I translate the word from the back-office, it works, but I can't see the change on my page. So I tested it with another laptop from a colleague, and it works.

My colleague has drupalTranslations(), which gives him the translated strings.

When I ru ...

Score: 0
TomP avatar
How to display entity reference field in User Profile Twig
ru flag

I asked this over on the Drupal.org forum, but I thought I'd give it a try here too.

I am using an taxonomy entity reference field to display author names on our site. I added a 'published_name' field and referenced it to the Author taxonomy. What I'd like to do is make a custom user profile twig that shows that entity reference field value on the author's profile page, including it's link, so w ...

Score: 0
Sam Bara avatar
How can I append a field to the body field?
ua flag

I have a content type (Press releases) with three fields: field_date, field_location, and body.

I am trying to create a template override for this content type based on this design.

screenshot

As you can see in the image, the date and location fields are appended to the body field.

I have tried adding all the fields in a single <div> and setting its display property to inline, but nothing has happened ...

Score: -3
thaidrupaler avatar
What is the template code for order date and telephone number
pw flag

In our invoice that is printed, the date of the order and the telephone of the customer is missing. How can I print those into the template?

Score: 0
Nelkan avatar
How can I have my own custom invoice number pattern?
zw flag

Hi Im trying to make different pattern for the invoice in Drupal 9. I have products with two kind of price one is for particular and the other one is for profesional.

i would like to have two pattern number for the invoice, for particular 22-ES-00001 and for profesional 22-ES-P-00001. I already create the two kind of pattern number and i have two kind of invoice type and also asign each pattern n ...

Score: 0
trzczy avatar
Single Page Website module - anchors not displayed in the browser address bar
gb flag

I installed the module https://www.drupal.org/project/single_page_website in Drupal 7. When I click the menu items it scrolls to the pages as it is expected, but then the anchors are not displayed in the browser address bar. All the time the adress of the site is displayed without anchors. So the address is not changing during scrolling to the pages. ('Pages' is the Panels element so I do not mea ...

Score: 0
Tobias Kulvik avatar
How would I go about making a view showing contact information of a user refrenced in the account field?
ki flag

How would I go about making a view showing the contact information of a user referenced in the account field? I am making a site which will be offering several services where customers will get an account and a on their user page show a card (view block) with the contact information of the person to contact regarding their services. I was thinking of an entity reference to a user and using that to deter ...

Score: 1
Patoshi パトシ avatar
Is there an equivalent of "drush dl pathauto --select" using "composer require module" name?
kr flag

Coming from drush 7. I used to install modules using "drush dl module_name --select" and I get a list of module versions I can select to download. Is there an equivalent for this for drupal 8/9 when using compose require to download modules? Currently I need to goto the module page name and copy the composure require line.

Score: 0
lee avatar
Send email to author after every numbers of flags?
cn flag
lee

I want to let node author receive emails when his node flagged by others, but I don't want to bother him too much for email for every flag, so if his node get flagged let's say 5 times, then he will receive an email for this. is this possible ? I was told probably I should set a rule condition to check the flag nums, but seems I can only set the total node flagged nums, but I can't set something like em ...

Score: 0
did avatar
Problem with refreshing the access token
in flag
did

I am building an app which uses Drupal (9.4.8) as the API. I am using the Simple OAuth module to authorise the client. I have got almost everything working fine, I am receiving the Access Token and the Refresh Token as expected. But, after a lot of searching, I still can't find out which path I need to refresh the tokens.

According to this video tokens can be refreshed on the path "/simple-oauth/ ...

Score: 1
Baud avatar
How to invalidate config or service cache
sa flag

I have a service wich is loading a config at construct time:

class MyService {
  public function __construct(ConfigFactoryInterface $config_factory) {
    $config = $config_factory->get('my.config');
    ...
  }
...
}

There is a config form to fill in the my.config's values.

In the submit function of this form, I obviously save the config but after that, I would like to use MyService. Unfortunat ...

Score: 1
Ganesh Chaudhari avatar
show "My billing information is the same as my shipping information." option when creating order from admin
us flag

I am using Drupal version 9.3.14. Option "My billing information is the same as my shipping information." gets available on checkout page automatically. But when creating order from Admin side this option is not available resulting into filling same address twice in shipping and billing address.

How can I make this option available on admin side also?

Score: 0
Juc1 avatar
html.html.twig Template Name for content type
eg flag

https://www.drupal.org/docs/theming-drupal/twig-in-drupal/twig-template-naming-conventions gives the example of html--node--[nodeid].html.twig for an individual node - what template name can I use for html.html.twig for a content type such as Article?

Score: 0
Eluchel avatar
How do I resolve these update errors?
so flag

Edit: I removed a couple modules that I thought might be causing the issue and uploaded the new error code. Edit 2: I cut some of the error code stuff to have the room to fit my composer.json file contents in. Edit 3: the composer require line was the wrong one, fixed that.

I am trying to update my site to drupal 9 following the Upgrading from Drupal 8 (or later) to a newer major version article on drupal ...

Score: 2
divspan avatar
Redirect doesn't work for .pdf file
fm flag

Is it possible to create a redirect for documents using the Redirect module? I can't seem to find a solid answer. Basically I'm just trying to create a redirect from https://www.example.com/default/files/2022-05/map.pdf to https://www.example.com/default/files/2022-10/map.pdf.

If this isn't possible, what would be a good recommendation other than modifying .htaccess as this is something that people w ...

Score: 1
levente.nas avatar
How to automate the creation of product types?
kw flag

I'm using Drupal 9 with Commerce 2. I have a large number of product types that need to be created. I have for each product type which fields need to be added. Let's say this information is stored in a json (I can vary this if the solution requires it). I was wondering if there is a way to create a module or something that iterates through this json file, and it creates all the product types. If there i ...

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.