Latest Drupal related questions

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.. ???';
Score: 0
Karolina Lencina avatar
I'm writing a node migration (D7 to D9) module but only the title gets migrated
in flag

How can I get the body migrated as well? When I compared this with other working migrations, there didn't seem to be any differences in the code/anything wrong with mine. I also looked for alternative process plugins but "sub_processes" seems to be working for everyone else just fine.

label: Generic - Node
migration_group: edweb_gen
migration_tags:
  - 'edweb_generic'

source:
  plugin: d7_node
  k ...
Score: 0
Is there Drupal Twig built-in ability to get content of page
cn flag

Is there built in Drupal Twig ability (tag) to get content of another website's page like file_get_contents() or cURL do in PHP? Under "built in" I mean without adding a PHP code to a controller for example a variable to hook function of a theme?

Score: 0
liquidcms avatar
Why do some Drush commands only run from docroot?
us flag

Wondering if anyone knows why some Drush commands (with file parameters) only run from the docroot and won't run from the project/composer root?

Commands such as drush sql-query and drush locale-import are among these.

For example, with standard Drupal folder structure:

/ (composer root)

  • composer.json
  • vendor
  • translations
    • translations.fr.po
  • web (docroot)

running from composer root:

  • vendor/bin/ ...
Score: 0
Image compression problem
be flag

I keep on running into an issue with image compression on Drupal.

I have a set of good quality, clear images, that I'm resizing down to 100px by 100px in CSS.

When I resize, the quality worsens and the images look blurry. The site uses GD2 compression enabled at 100%, but this setting doesn't seem to have any effect.

The image style is set to scale and crop at 365px by 365px.

Anything I could be missing?

Score: 0
Matoeil avatar
How to compare the original file and replacing file to upload prior to the action of physical uploading?
za flag

Exploiting the file_save_upload functions options, i would like to give a different treatment to the file on media replace.

https://api.drupal.org/api/drupal/core%21modules%21file%21file.module/function/file_save_upload/8.6.x

  • if the new file to upload has the same uri than the existing, i would like to use FILE_EXISTS_REPLACE
  • if the new file to upload has a different URI, i would like to use FILE ...
Score: 1
How to migrate files from outside Drupal, with files already where they need to be, creating file entities
pe flag

I'm doing a migration from a non-Drupal site--so far, for test purposes. I have all the data in CSV files.

Since I'm brand new to migrating into Drupal 9 from outside Drupal, I'm learning this in small, somewhat simple phases.

The source data includes a bunch of records, many of which have attached files. Some files are attached to more than one record. Some records have multiple files attached. "At ...

Score: 0
quantumized avatar
How do redirect a user after login to a route that requires the UID?
ng flag

I know, this seems like a basic question:

In Drupal 9 how do I redirect a user after logging in to a path/route that requires the UID in the path?

I've researched and tried different implementations but none of them support tokens (Rules, Redirect After Login, etc.)

For example, after a user logs in they should land on "/homebox-page/dashboard/UID" <- numerical value from current user ID.

I was hoping ...

Score: 0
mauzilla avatar
Loading a field value within a twig template
cn flag

I'm building a multi-country website using Drupal 8. The company would like to have each region manage their website independently but still have a "global" site. I'm building a theme which has some hardcoded areas (telephone numbers, copyright notice etc) which I want each region to be able to modify themselves. My thinking is to create a content area for say "copyright".

How do I render a field ...

Score: 0
pofk999 avatar
Node coloring by taxonomy
cn flag

My site has a node and a "tags" taxonomy that contain the color field. One node can have multiple tags, but I need to select one main tag. The color from the main tag must be passed to the node. How do I implement it?

Score: 0
Search file attachments module and drupal 9
do flag

I have a website that uses the search API module to generate search results for sets of pages and for files - mostly pdfs. To help do this I use the search_file_attachments project.

In the process of upgrading this site to drupal 9, I have discovered this module has not been upgraded and it appears it may have been abandoned. The issues page list a number of drupal 9 issues to be resolved and an offic ...

Score: 1
Greg Sims avatar
drupal-scaffold composer append robots.txt
us flag

We recently upgraded to Drupal 9.3.0 with the composer layout. Each time we execute composer update the contents of robots.txt is overlayed with the file located in core/assets/scaffold/files/robots.txt. We would like to append the default robots.txt with project unique data.

I included the following in composer.json per the documentation I found:

    "extra": {
        "drupal-scaffold": {
       ...
Score: 0
create subtheme: permission problem Bootstrap5
fr flag

It is not possible to create a subtheme in Bootstrap5 in Drupal 9. An issue was opened on Drupal.org and it is supposed to have been resolved, but comments continue to arrive from users who continue with the same problem: https://www.drupal.org/project/bootstrap5/issues/3219767

drupal 9.3.2 fresh install with composer on Centos server

composer require 'drupal/bootstrap5:1.1.x-dev@dev'

if i press SUB ...

Score: 0
Drazen avatar
Get class on item.below (child item of menu) inside
  • tag in menu--main.html.twig
    ru flag

    Hi I can't insert class in child item of main menu and remove existing. Part of my code looks like this:

    {% for item in items %}
      {%
        set item_classes = [
        'menu-item-edot',
        item.is_expanded ? 'dropdown',
        item.is_collapsed ? '',
        item.in_active_trail ? 'is-active',
      ]
      %}
      <li{{ item.attributes.addClass(item_classes) }}>
    
        {%
          set link_classes = [
          'nav-link' ...
  • Score: 0
    Override a access check but also pass control back to the primary controller under certain conditions?
    cn flag

    I use a contrib controller that has a _custom_access function that I need to override.

    I add a RouteSubscriber, and point the access check to my own controller. Now I want something like:

    if ($condition) {
      return $new_access_decision;
    }
    return $original_controller->accessCheck()
    

    so I can contrinue to rely on the original logic for most cases, and just override for a small subset of cases.

    I don't kn ...

    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.