Latest Drupal related questions

Score: 0
marcusx avatar
Are extra fields added with hook_entity_extra_field_info(). not available on product variation pages?
cn flag

Is it generally impossible to render an extra field on product variation pages, because of how the variant fields are injected into product pages?

I added an extra field to the product variations with hook_entity_extra_field_info(). and I see it in the "Manage Display" Tab like it would appear on any other entity. But I can't output it. It is simply not available in the theme. If I do a {{ dump() }} in  ...

Score: -2
user21365078 avatar
Get the HTML content from the database
fm flag

I have a copy of a Drupal 9 database from which I need to download all the pages.
I loaded the database in MySQL Workbench CE and connected to it via Python. There are many tables, but no views or stored procedures. I guess that some of those tables house the content, but I have no idea on how to pull them together to extract webpages.

block_content_body looks promising, but then what?

I assume it is a st ...

Score: 0
Matoeil avatar
custom block field not translatable
za flag

i have created a custom block

<?php

namespace Drupal\amu_external_search_block\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Block\BlockPluginInterface;
use Drupal\Core\Form\FormStateInterface;

/**
 * Provides a 'amu_external_search_form_block' block.
 *
 * @Block(
 *  id = "amu_external_search_form",
 *  admin_label = @Translation("recherche externe"),
 * )
 */
class AmuSear ...
Score: 0
Alex Monaghan avatar
Custom block not showing
in flag

I created a custom block module (nothing fancy, just an A-Z list and a taxonomy list for navigation), this worked fine in D8 & D9, now since upgrading to D10 it only shows when logged out, when logged in, it still writes a debug message to the Apache errorlog from the build() function, so I know the code is being called and I can dump the content to the log, I just get no display of the output. I ha ...

Score: 0
BassPlaya avatar
Fetch the total number of rows in Rules View to use that number in Rules
ma flag

I have a View that lists entity IDs of some sort and I have created a Rules View for this. In Rules, I have created a component where I want to fetch the total number of rows from that Rules View and do something with that number which should be an integer, I believe. I don't want to do something with each row. I just need to collect the total. I'm using the "Collect view result rows" action to try to c ...

Score: -1
Alston avatar
How do I install commerceguys/addressing and commerceguys/int
pr flag

I am trying to install drupal commerce i have put the files in their proper place (folders etc) but its like i didn tdo anything because it is not working for me. What should i do

Installed Modules

Error Message

Score: -4
Why doesn’t "composer update" upgrade this site?
cl flag

I'm running Drupal 9.59. I tried following the instructions on drupal.org for upgrading to Drupal 10. The steps with composer --no-update went fine. The actual update step yields:

Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

Problem 1

  •  ...
Score: 2
yyy20230604 avatar
How to translate the administrative area in an address field?
is flag

I am currently trying to change the confirmation email sent to purchasers after checkout to Japanese, but I am stuck because I don't know how to change only the arrowed part of the image, which shows the prefecture, to Japanese. Does anyone know how to make this part Japanese? This may be a very elementary question, but I have very little experience in web development and there are very few resources in ...

Score: 0
Ricardo Castañeda avatar
theme_suggestions_html_alter not being picked
at flag

I'm trying to implement a custom template html--front--anonymous.html.twig which replaces html.html.twig. The suggestion is being showed, but its file is not being picked.

my_theme.theme

function MY_THEME_theme_suggestions_html_alter(&$suggestions, $variables) {
    if (\Drupal::currentUser()->isAnonymous()) { 
        if (\Drupal::service('path.matcher')->isFrontPage()) {
            $sugge ...
Score: 0
Creating user programmatically fails with Postgres
cn flag

Anyone know what's wrong here? After the D8->D9 upgrade, a stupidly simple piece of code is not working, has there been a change? It worked before.

$params = [
  'name' => $username,
  'pass' => $password,
  'mail' => $email,
  'init' => $email,
];

$user = $this->users->create($params);

$user->enforceIsNew();
$user->save();

In D8 this was fine, in D9 I'm getting:

Drup ...
Score: 0
How to expose a filter of an list (text) field to your site visitors in a REST Export View
us flag

How can I filter based on selections of a list (text) field and share that with users? For text fields this works out of the box, but for list fields you can only select the specified values:

Views Screenshot

I would like to be able to query the values as with the text fields also over a url like this:

https://mysite.com/api?search_categogy=reparaturen

ideally with operators like "contains". how to do that?

Score: 1
nstCactus avatar
How to create entity translations using JSON:API or REST API?
ph flag

I working on a headless localized site in which entities need to be synced regularly from an external source.

During the sync process, I need to create new entities and their associated translations.

I found out that JSON:API doesn't support this. Are there any workarounds to achieve this in JSON:API?

Is it something that can be achieved with the REST API? If so could you point me to some documentation? ...

Score: 0
Jorge Luis Arzola avatar
is it posible to get the value of other fields right inside the buildForm() method without having to save configuration?
pl flag

I have a config form with two select fields. The first one(vocabulary) gets populated automatically without problems with options taken from the available vocabularies for users to pick up one. The problem comes now, the second select field should be automatically populated with taxonomy terms based con the chosen vocabulary...but it DOES NOT work ($form_state->getValue('vocabulary';). My quesion  ...

Score: 0
jreinholdt avatar
403 Forbidden after 10 POSTs
ke flag

Problem/Motivation

Repeated posting a redhen_contact via the Drupal JSON:API succeeds for exactly 10 times in a row. The 11th attempt fails with 403 status code. After waiting for 60-120 seconds, the next 10 POSTs succeed again.

BasicAuth is used, user account has the necessary permissions, also affects user 1. Strangely, this happens with the redhen_contact entity type only, entities of type redhen_or ...

Score: -3
Matoeil avatar
page building using a toolbar to select components (drag'n drop, IPE) on creation and edition
za flag

Of all the drupal solutions for page building, i do not see any that uses the same UI for creation and edition. Layout builder allows to place and (re)organise entities in layout sections but only once the entity has been created.

I would ideally imagine a toolbar that allows to pick from all the components available ( paragraphs , custom blocks or other type of components) and place them in sect ...

Score: 0
de2 avatar
Default language on Language list page
ir flag
de2

I have just installed a brand new drupal 10 website. My goal is to make french its default language and add English as another available language. For that :

  • I selected FRENCH as default language on the first step of the Drupal installation.
  • I enabled the following modules : Configuration translation Content Translation Interface Translation Language
  • I added a new language "English" here /fr/admin/conf ...
Score: 0
JM John avatar
Strange redirect text in page cache entries
mz flag

My Drupal site is having some redirect malware issues. I suspected some strange redirects and tried to catch redirects by caching them through Nginx. Below is the output of one redirect.

Page https://www.test.com/officialsite doesn't exist on the site. No URL redirect with this value.

However, visiting https://www.test.com/officialsite produces a redirect loop because it leads back to Nginx instead  ...

Score: 1
Vanish avatar
functional test: Schema errors but Schema is correct
hm flag

I have a settings form in my custom module and functional test of this form.

I added new field to form

$form['unblockable_roles'] = [
  '#type' => 'checkboxes',
  '#title' => $this->t('Users cannot block another users with these roles'),
  '#options' => $roles_options,
  '#default_value' => $config->get('unblockable_roles') ?: [],
];

Updated schema file:

mymodule.settings:
  type:  ...
Score: 0
Himanshu Lahare avatar
Ajax callback not returning options for checkboxes
pl flag

I'm triggering an ajax callback on change event of a dropdown, this method returns additional form elements like text fields, number and checkboxes, but for checkboxes the options are not appearing at all.

---------
Container for additional elements

  $form['dynamic_field_container'] = [
                '#type' => 'container',  
                '#attributes' => ['id' => 'dynamic-field-wra ...
Score: 1
LeDucDuBleuet avatar
Is there an alternative to hook_webform_submission_render_alter()?
br flag

In Drupal 7, I was able to use hook_webform_submission_render_alter() to alter the rendering of webform submissions. For example, I was able to completely remove the display of specific fields depending on their answered values.

I am looking to do the same in Drupal 9, where that hook no longer exist. I tried different approaches with no luck so far.

What would be the alternative to hook_webform_subm ...

Score: 1
GeorgeCiesinski avatar
How do I edit settings.php when it is read-only?
mv flag

I have a Drupal 10 site that I just installed for the first time. I am very new to Drupal, and I haven't done anything to this site except install it and set up basic details like the site name, emails, and my admin login. The problem I am having is that the Status Details page lists 1 error which is:

Trusted Host Settings

Not enabled
The trusted_host_patterns setting is not configured in settings. ...
Score: -2
Fazeela MukhappillyAboobacker avatar
How do I make an activation link on registration expire in 15 minutes?

I have user registration and forgot password mails sent to the user.

I want 5 minute expiration for forgot password and user registration. Now the forgot password will expire after 5 minutes but new user registration link is not expiring after 5 minutes.

I have set the following changes in settings.php.

But it is not working for first time activation link.

$conf['user_password_reset_timeout'] = '259 ...

Score: 0
Mira chalak avatar
Translating media and other reference fields
eg flag

I am new to Drupal and I am setting up a new Drupal 10 website with multiple languages. I just wanna make sure that as a beginner I have understood the concept of translation for fields that reference to other entities.

For example, I have an Article content type with three fields:

  • field_related_pages that references multiple Page nodes
  • field_main_image that references a media entity (an Image bu ...
Score: 0
Eluchel avatar
How can I disable a specific javascript function in my base theme?
so flag

There is a single javascript function in my base theme that I want to disable and I haven't been able to figure out how to do that.

I have read the documentation on how to disable a whole file with libraries-override, but I am looking for a way to disable only a function in a file.

I tried adding a .js file to my sub-theme and setting the function to null, but that didn't work.

Is there a way to dis ...

Score: 0
Droopaluser69 avatar
Theming image.html.twig for one paragraph type with custom template suggestion
mz flag

I have a custom module that when installed, creates a paragraph type called "Gallery". Gallery has one field called "field_gallery_images", which is a media reference.

I am trying to replace image.html.twig with image--gallery.html.twig only for images inside my gallery.

I have managed to get Drupal to recognise and load my custom template from the modules template directory. However, every singl ...

Score: 4
chris avatar
How can I add inline markup to submit buttons?
ua flag

I migrate code from Drupal 7 to Drupal 10, in Drupal 7 I often created buttons with an icon and text like showen aboven:

Drupal 7 code:

$form['submit'] = [
  '#type' => 'submit',
  '#value' => t('<i class="glyphicon glyphicon-share"></i> Register'),
  '#attributes' => ['class' => ['btn-success btn-sm']],
];

When I try to do this in my drupal 10 code, the icon (I replaced t ...

Score: 0
Rob Carr avatar
Webform File Attachments Uploaded But Not Linked to Submission
us flag

I have Webform 6.1.5 running in a D9.5 website, that has lots of other contrib modules.

Using the Webform Attachments sub-module I have some simple forms that require files to be attached to the submission. The files are being uploaded [to the temporary _sid_ folder] but not to the submission folder once the webform is submitted, nor are the files referenced in the submission. If 'preview' is enabled, t ...

Score: 0
ase avatar
Twig: display linkfield with optional title
pa flag
ase

I created a linkfield within a paragraph with an optional title. The textlink should only be displayed, when the title is not empty. I need the URL from the linkfield for another field (an image where the users can click to open the same URL from the linkfield), so the editor can chose if he wants the textlink as well to be displayed or only the linked image.

{% if content.field_link.0['#title']|re ...
Score: 1
How to generate a patch from a merge request prior to rebase in GitLab?
cn flag

I was using this core patch by taking the GitLab URL and adding .patch:

https://git.drupalcode.org/project/drupal/-/merge_requests/2794.patch

However, on June 16, the MR was rebased from 10.1 to 11.x. I'm on 10.1, and after the rebase, the patch no longer applies.

It would have been better to download the patch locally and then apply commit it to my repo to avoid having the code change suddenly l ...

Score: 0
user3108268 avatar
How to use Commerce Product Options in Rules?
us flag

This questions is about Commerce Product Options version 7.x-1.0 and not 7.x-2.0, the 2.0 version does not have this problem.

The reason we're using 7.x-1.0 is because other module Commerce Pricing Attributes only works with 7.x-1.0 version.

Unless there is alternative how to calculate prices per product attributes/terms/select lists with potential ~50 combinations of variations per product.

Simple sce ...

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.