Latest Drupal related questions

Score: 0
May  avatar
Twig templates with lots of classes?
zw flag

I have created a twig template and have added classes like below.

{%
  set title-classes = [
    'title',
    'h1',
  ]
%}

{%
  set subtitle-classes = [
    'subtitle',
    'h2',
  ]
%}

<div{{ attributes.addClass('title-classes') }}>
    {{ content.title }}
</div>
<div{{ attributes.addClass('subtitle-classes') }}>
    {{ content.field_subtitle }}
</div>

What do I do when I ha ...

Score: 1
Kevin avatar
Install newer packages without conflicting with core-recommended?
in flag

Is there a way to install third party packages without conflicting with core-recommended? Example:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - spatie/ignition[1.0.0, ..., 1.0.2] require symfony/console ^5.4|^6.0 -> satisfiable by symfony/console[v5.4.0-BETA1, ..., 5.4.x-dev, v6.0.0-BETA1, ..., 6.1.x-dev].
    - symfony/http-kernel v4.4.35 conflic ...
Score: 0
Steve Siddu avatar
How can I filter based on unique taxonomy term values?
br flag

I have a content type "book". One of its field "field_language" referencing to "language" taxonomy term. field_language can have only one value.

Consider this is the content I Have,

enter image description here

I want, a single book for every unique taxonomy item of "language" taxonomy term.

I want the view to generate a result like this,

enter image description here

How can I implement this using views?

Needs Help!

Thanks

Score: 1
druplash avatar
How do get a value from field in if/else statement
jp flag

In a custom views-view-fields.html.twig I do print a list field (field_status) without issues. The values are:

new|New

old|Old

But if i want to do an if/else statement for printing different div containers i do get always printed the div container from else. Does anybody have an idea what i am doing wrong? I tried it too with module Twig Field Value, but i do have the same issues.

<div class="card ...
Score: 0
Node reference field autocomplete and allow multiple selections in views
us flag

I recently pdated my Drupal core to 8.9 and suddenly a functionality stops working.

I have a "Recipe" content type, it has a field of "Category" (field_category) which is Entity Reference: Node.

I tried to create a View and created a filter criteria field_category, and I want it to be Auto complete and Allow multiple selections.

I know its possible on Entity Reference Taxonomy, but currently its not po ...

Score: 0
Using group module, get SUM from the groups content in a view
in flag

I am using the group module and each group can create "tournaments" content. Within that content is a multivalue paragraph that contains a user id and a number field.

Using views, I would like to display a leaderboard. Basically take all the groups "tournament" nodes and display the user and their total from that number field. I am not very confident that this can be done entirely with views. When I  ...

Score: 2
Hubert avatar
Drupal JSON:API - retrieving nodes tagged by multiple terms
cn flag

Let's say I have an articles content type, and a field_tags reference field (with multiple values referencing a "tag" vocabulary)

To retrieve articles referencing, say, "tag1" or "tag2", I do this:

jsonapi/node/article?
&filter[tags][condition][path]=field_tags.id
&filter[tags][condition][operator]=IN
&filter[tags][condition][value][]=id-of-tag1
&filter[tags][condition][value][]=id-of- ...
Score: 0
jfc avatar
Can I translate a variable using jQuery Drupal.t function in Drupal 9?
us flag
jfc

I am using the REST API in Drupal 9 and am using JavaScript template literals to generate some of the data.

For example, to generate a list of products that are pulled from the API this is my code -

<span class="products">${Drupal.t(object.field_supplier_products)}</span>

This returns what I have under field_supplier_products, so for example "Product 1, Product 1, Product 3", but I canno ...

Score: 0
quantumized avatar
How to make a View's exposed filter value match the Context Filter term name provided in the View path?
ng flag

In Drupal 9 we have a View of Nodes with a Context Filter (Has Term Name to Term ID) and an exposed Filter for the term (called Resource Type). I can go to the Views path (/downloads) and add the term name (/downloads/white-papers) and the results are filtered properly but the exposed filter does not reflect the "white-papers" filter and this shows "- All -" as the selected filter.

How can we mak ...

Score: 0
Helen B avatar
WSOD when clicking on Files tab after updating Drupal 9
de flag

I have done an upgrade from Drupal 9 to 9.1 and subsequently 9.3 but I get a white screen of death error when I click on the Files tab in the Content menu. This is the error I get in the logs

Drupal\Core\File\Exception\InvalidStreamWrapperException: in Drupal\Core\File\FileUrlGenerator->generate() (line 192 of /var/www/drupal9/web/core/lib/Drupal/Core/File/FileUrlGenerator.php)

I've tried applying t ...

Score: 0
pmagunia avatar
How To Show Custom Completion Message Based On Webform Form Input
au flag

I'm trying to show a custom completion message in Drupal 7 using the Webform module.

The message shown after completing the form would depend on what the user enters in the webform.

I found this thread for the Webform 5 module in Drupal 8 but can't find one for Drupal 7:

Webform Message / Custom Module

Does anyone know how I can accomplish this?

Score: 1
El Inoubio avatar
JSONAPI : Patch node path alias
bd flag

I have content on a Drupal site and I want to patch to change their path alias. Here is how I do. It is giving me a 400 error: Syntax Error. I don't see where the syntax is bad. I am using Python 3 and requests

content = json.loads(data)
nodeEndpoint = endpoint.endpoint_url + f"/jsonapi/node/article/{destination_id}"

patchData = {
    "data": {
        "type": "node--article",
        "id": destin ...
Score: 0
Zdeněk Nováček avatar
Disable theme debugging html comments in particular view?
in flag

we are running commerce site, still tweaking some bits, so we have still twig debug set to true, but site is already online.. we have XML feed for exporting commerce products to couple of price comparison sites.. and XML feed is of course marked as invalid, because even in XML views feed are html theme suggestion comments, any chance to turn off those for particular view?

Thank you.

<SHOP xmlns="ht ...
Score: 0
richirm avatar
Where are path aliases stored?
in flag

I know that, in Drupal 7, path aliases are stored in the url_alias table. Which database table does Drupal 8 use to store path aliases?

Score: 0
Changing a node alias to reuse his old url programmatically without be still redirected to the node page
in flag

I'm on a old site on drupal 7. I have a node with alias /url. Now I need to manage that page url programmatically, so I create an item in a custom module using hook_menu() in this way:

/**
 * Implements hook_menu().
 */
function MYMODULE_menu() {
  $items = [];

  $items['url'] = [
    'title' => 'New Title',
    'page callback' => 'MYMODULE_url_callback',
    'access callback' => TRUE,
    't ...
Score: 0
Zdeněk Nováček avatar
Commerce2 product add to cart button with price D9
in flag

I'd like to alter submit button in add to cart form to show "Buy for 9.90 USD"

I made function MYTHEME_form_alter(&$form, $form_state, $form_id) and I'm able to change submit button text (I found a path via dpm($form)) but I don't know how to find a price variable. dpm($variable) does not work, nor is dpm($product)

$form['actions']['submit']['#value'] = 'Buy for.. ???';

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.