Latest Drupal related questions

Score: 0
Andrew Morris avatar
Entity agnostic way of retrieving title
mw flag

Is there a way of the Title/Label/Name of an unknown entity type via 1 method?

At the moment if it's a node, I have to use $entity->getTitle(), for a user it's $entity->getAccountName(), for a taxonomy term it'd be $entity->getName()

In my head they all feel like the same piece of information, is there a way of retrieving it without having to write out possibilities for each type of entity?

Score: 1
Joost avatar
How to find module that is updating my node after insert
jp flag

When trying to create a new book i get the following message:

Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '53' for key 'PRIMARY': INSERT INTO "book"

The problem here is the book is added twice. Therefor the book is created once and for the other one I get the message above.

For some reason the node creating is updated directly after cre ...

Score: 0
Andrew Morris avatar
Comparing 'old' values in hook_user_update
mw flag

I've got a function which is running on hook_ENTITY_TYPE_update for the user account, but I want to be able to compare against previous values that may have been on the user account, eg see if the user has changed their email address and be able to react to it.

I can see that if I run the debug on the $entity value that is part of the function that there is an 'original' item within the values arr ...

Score: 0
florian_drupal avatar
How to custom access for entity paragraphs_type?
cz flag

I have a problem with entity paragraphs_type, when I add a paragraphs_type in a node, with paragraph items inside, and I set it unpublish status, anonymous users can still see it. unpublished paragraph type I try to custom access by different way :

/**
 * Implements hook_ENTITY_TYPE_access().
 * ENTITY_TYPE : paragraphs_type
 */
function my_module_paragraphs_type_access(
  Drupal\Core\Entity\EntityInterface $entity,
  $op ...
Score: 0
Raja Chakraborty avatar
How can i get the fields of a view which has contextual filter inside views_view_field hook in drupal 9?
in flag

I have a drupal 9 site. I have a parent view A and a child view B. I am using views_field_view contrib module in order to pass an id from view A to view B. I have added a contextual filter in B to get this id from A. I want to fetch this id in my views_view_field hook and do some modifications based on the id fetched. But i am not able to get inside the view B in my views_view_field hook. If i remove th ...

Score: 0
fombo avatar
Use HTTP_REFERER within a twig template
my flag

I have a FAQ page with five nested bootstrap 5 accordions and I need to have one accordion item or another open depending on the page the user is coming from.

I tried using this:

{% set previousURL = app.request.headers.get('referer') %}

but I get nothing.

Using Drupal 9.

Score: -2
Fayaz Mohammad avatar
How to convert hook_entity_property_info_alter in Drupal 8 or 9?
cn flag

I am trying to convert Drupal 7 custom module to Drupal 9. I came across the function hook_entity_property_info_alter(). How can I convert or migrate this function to Drupal 9?

Score: 0
ACanadianCoder avatar
How do I grab a field from a referenced item in views?
br flag

I currently have a view block called Offerings that shows up on all my Course content-type pages that display all the offerings for the said course. These offerings are their own content type called Course Offerings. The Course Offerings content type has a field_course_reference field so to know which Course the offering is for. In order for it to show the proper courses on my view, I have a Contextual Fi ...

Score: 0
octogone.dev avatar
How do I apply different styles according to content type?
bf flag

in a view I'm filtering content with search API /facets. In the view (field format) i've applied a specific style for the results, some sort of Bootstrap card. IT apply to all content index by search API.

I need to apply different styles according to content type in the results: For the content type "rose" i use a bootstrap card, for the content type "wood" i use full width div with an image a b ...

Score: 0
How to refresh and reload (with ajax?) order checkout panes and order calculation independent from commerce cart refresh (e.g. billing address change)
fr flag

I have following problem:

During checkout, my customer has to fill in his billing address (at least at the first time) to calculate VAT rate and gross price. Further calculation is done via an order processor after that. So far it works fine.

My problem is, that the cart order refresh doesn't refresh the checkout panes (like the order summary) via AJAX, when the billing country (and so perhaps the v ...

Score: 0
Giuseppe avatar
Why don't users with the "Create new content" permission for a custom bundle cannot access /node/add, but they can access /node/add/author?
br flag

If I give to a custom role the Article: Create new content permission, users can access the /node/add page. However, if I give the same permission for a custom bundle, for example Author: Create new content, users can't access that page, but yet can access /node/add/author.

What should I try to address the problem? I've tried to debug NodeAccessControlHandler::createAccess(), but this code doesn ...

Score: 0
How can I programmatically add or remove a new request_path to block visibility?
in flag

It seems like I could utilize the getVisibilityConditions method on the block, which returns a ConditionPluginCollection object with a setInstanceConfiguration method, which is apparently easy enough to use, requiring $request_path and $configuration arguments. But, the current block visibility request path variable is a string, containing paths separated by commas. How can I update that to either  ...

Score: 1
Andrew Morris avatar
Adding sequence item to configuration
mw flag

I have a configuration item in my custom module, part of which is a sequence, basically I'm attempting to create something akin to an array of items

my_module.schema.yml

my_module.settings:
  type: config_object
  label: 'Configuration'
  mapping:
    custom_fields:
      label: 'Custom Fields'
      type: sequence
      sequence:
        type: mapping
        label: 'Custom Field'
        mapping:
   ...
Score: 1
Change the state of a checkboxes field
pe flag

I know how to use conditions with Form API for fields like text-field, checkbox, for example, showing or hiding a field when a checkbox is checked.

$form['lorem'] = [
  '#type' => 'checkbox',
  '#attributes' => [
    'name' => 'field_lorem',
  ]
];

$form['ipsum'] = [
  '#type' => 'checkbox',
  '#states' => [
    'visible' => [
      ':input[name="field_lorem"]' => ['checked' =&g ...

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.