Latest Drupal related questions

Score: 0
Pass parameters from block to a JSON endpoint using taxonomy term from URL
pk flag

I've been searching for a solution to being able to pass a taxonomy term on a views block that is on a given page using the term name that is in the URL. I agree with my team that it would be a best practice to have one block that can be placed on multiple nodes to pull relevant data from a JSON endpoint, on another server, rather than have a proliferation of one block for term.

Example endpoint  ...

Score: 0
john Smith avatar
FieldItemList::getValue always returns a string, even for a Boolean field
gr flag

Supposed I added a custom Boolean field, whose cardinality is 1, to a content type. I create a node of that content type, enter a value for that field (for example, TRUE), and save the node.

When I get the field value with $value = node->get('field_custom')->getValue(); $value contains the following array.

0 => array (1)
  value => string (1) "1"

Is there an way to get the field value ...

Score: 0
Alimba avatar
How to translate content but not backend interface?
in flag

I'm trying to set up an English administrator back-end and a URL based front-end (anonymous user content) translation. I follow a guide on the subject, but I haven't been able to achieve what I wanted.

I also tried to set up /admin/config/regional/language/detection using various combinations of settings, but either I have the back-end in English along with the rest of the site, or everything is  ...

Score: 0
tonytheferg avatar
How to get access to a $form in hook_entity_view_display_alter?
cn flag

In Drupal 9, I added a views_add_to_cart_form view mode to be able to render a product entity with only the Variations field formatted as add to cart form being displayed. That all works as expected, but I am trying to remove the quantity widget on the commerce add to cart form for that specific view display by using unset($form['quantity']);.

I am not sure if it is better to bring the view display info ...

Score: 0
Filtering on child properties in GraphQL
hu flag

I am using GraphQL to get a list of upcoming events. I am having trouble finding the correct way to filter on the date value which is a child of my date field.

The query, which works:

query getUpcomingEvents {
  nodeQuery(
    filter: {
      conditions: [
        {operator: EQUAL, field: "type", value: ["ain_event"]},
        {operator: EQUAL, field: "status", value: ["1"]} 
      ]
    }
  )
  {
 ...
Score: 1
Md Eqbal Ahmad avatar
Fatal error: Cannot redeclare Drupal\views\Routing\ViewPageController::getTitle()
gh flag

I have updated Drupal 9.0.1 to 9.2.2 via Composer. After updating, I am getting a fatal error.

Fatal error: Cannot redeclare Drupal\views\Routing\ViewPageController::getTitle() in /var/www/html/docroot/core/modules/views/src/Routing/ViewPageController.php on line 98

drush updb outputs the following.

 -------- ------------------ ------------- ------------------------------------ 
  Module   Upda ...
Score: 0
fin avatar
How is the cache invalidated?
th flag
fin

Using the following code, are all the cache bins consider when invalidating a content piece?

$variable['#cache'] => [
  'keys' => ['key string here'],
  'tags' => ['tags string here'],
  'max-age' => 'max age'
];

For example, If max-age is set to 15 minutes, is the content invalidated every 15 minutes? Does any change to the cache tags invalidate the content?

Score: 2
Baud avatar
How to create a view filter which display nodes if "field1" - "field2" < $amount
sa flag

I have a content type with 2 fields: field1 and field2

I would like to create a view filter which display node based on a calculation on those two fields.

The filter should display only nodes if field1 - field2 is lower then a given amount.

Here is my try: At the end of the code, I don't know how to create the query

 class Myfilter extends FilterPluginBase implements ContainerFactoryPluginInterface ...
Score: 0
ACanadianCoder avatar
SOLR displays "submitted by username" only for the Article content type. How do I stop this?
br flag

No matter what I do, I can't seem to remove the Submitted by [username] from popping up in my search results for the Article content type. I'm using the Apache SOLR module. If you visit the article page itself, I never actually display this information, so showing up on the search results page is confusing me.

When I go to manage fields for my search results, I've got the following for content (I  ...

Score: 0
Dorian Winterfeld avatar
What is the correct way to load a JavaScript library?
ae flag

I am trying to display form data as a line chart. I am running Drupal 9 in Lando. I am using Charts 5.0.x w/ the Highcharts submodule. I installed the Highcharts JS library using composer. This is the relevant code.

.libraries.yml

highcharts:
  js:
    /libraries/highcharts/highcharts.js: {  }
  dependencies:
    - core/jquery

.module

function stats_degrees_theme() {
  return [
    'mychart_templ ...
Score: 0
How do I change a display plugin class
vn flag

I'm attempting to modify the definition of a view display plugin to use my own custom class. I used hook_views_plugins_display_alter(), but it doesn't seem it's invoked at all. I've searched in core code where the hook is invoked, but I didn't find it.

Does anyone know an example of using this hook, or another way to override the class for a view display plugin?

Score: 0
Jean da Silva avatar
Cron is running but not saving entity
cn flag

I am trying to create a simple hook_cron to connect with an external API, return some data and update some fields in some entities. I'm creating like this to understand better how cron works, so I will upgrade it later to a queue.

The problem is that the cron is running, but even without errors the entity is not saving or updating. If I copy the code and try to execute it with a route (not using  ...

Score: 0
Thiery avatar
How to get a delta value from a composite with ilimited values?
vn flag

I have this webform with composite field where I add a file and a field where I add a number. print

What I wish is using the token, to rename the file with number inputed in the number field. But the thing is I have a composite with multiple ilimited values and I can only do it if I declare a delta number as the following token: [webform_submission:values:element_key:delta:sub_element_key]

How can I do  ...

Score: 0
khadidja avatar
Views Infinite Scroll class wrapper goes away when filtering using facets, changing my CSS styling
cn flag

I have a page with custom css that uses display:grid for content output from my view. The limit I have for what my view outputs is 30.

Since the views infinite scroll contains a wrapper around my content, my css grid styling is all there, however when I use my facet to filter anything with an output less than 30, the wrapper vanishes as does all the styling. The wrapper then becomes a different c ...

Score: 1
scaffolding avatar
Add a hero image and text when a node goes from unpublished to published
es flag

I'm trying to add a hero image and text when a node goes from unpublished to published. The things include:

  1. Add an image from my media library to a media field on the node
  2. Add a page title to the node, drawing upon a field already saved on the node

I'm attempting to build a hook on hook_node_update() but it's not working. I'm not sure why.

The code I am using, part of the running_event_adding_header. ...

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.