Latest Drupal related questions

Score: 0
Martin Fuggle avatar
Website URL issue
fr flag

I have an Drupal 10 installation on my Macbook Air. The web root is ~/Sites/drupal10/web. I have a hosts file entry pointing d10.mf.local to localhost and I have an Apache Vhost set up with ServerName = d10.mf.local and DocumentRoot = ~/Sites/drupal10/web.

If I access the site using http://d10.mf.local the front page is displayed but as soon as I try to access any item in the menu the URL has /drupal ...

Score: 0
nihdrupal avatar
cant wrap element created twig
xk flag

I made a custom menu and I want to wrap an element with parent element through a script. element create from block-menu.html.twig Element: <li class="menu-item menu-item-level-1">

my js file:

var $ = jQuery.noConflict();
$(document).ready(function(){
  $( ".menu-item-level-1" ).wrap( "<div class='new'></div>" );
});

The console does not display any errors, the script is connected. Ch ...

Score: 0
monster_energy avatar
How can I add an external/third party library with type = 'module' using drupal_add_js()?
mp flag
  drupal_add_js('path_to_external_JS_file_on_CDN', [
    'every_page' => TRUE,
    'type' => 'external',
    'defer' => 'defer',
    'attributes' => [
      'async' => true,
      'type' => 'module'
    ],
  ]
);

I tried all combinations of the above, but I couldn't get it work. Is there a way to achieve it using drupal_add_js(), or should I use some other way?

I am trying to achi ...

Score: 0
Juc1 avatar
Can I add classes to individual menu links?
eg flag

I am using the main menu /admin/structure/menu/manage/main

There are a couple of links that I want to display only in mobile devices, and then also another couple of links that I want to display only in laptop devices. Can I do this without needing two separate menus? I guess one way would be to attach a css class to the relevant links but looking at /admin/structure/menu/item/1/edit there is no  ...

Score: 0
Kartagis avatar
How do I handle git asking me to remove untouched files?
lu flag

A while ago, I cloned the Drupal repo. Today, I attempted a pull only to find out that I'm being asked to remove most, if not all, of the core directory to prevent overwriting. This happened to me once again about a month ago and I fixed it by removing the core directory prior to pulling, but obviously I can't remove the directory every time I pull. How can I fix this once and for all?

EDIT: git outp ...

Score: 0
Gábor Riskó avatar
Check referenced child entity update in Inline Entity Form and change author in parent entity
hu flag

Can anybody help me how I can check upon entity update (with hook_entity_update or with something else) whether one of the fields of child referenced entity is update and make changes on parent entity? The child is an Inline Entity Form inside parent edit form.

There is a Parent node type which has a reference field (field_referenced_child, cardinality is 1) to Child node type which has a field_i_need_t ...

Score: 0
somo avatar
Why does the Full HTML text format convert special characters to HTML entities?
ye flag

I am trying to create a block with plain text HTML in Source mode of CKEditor.

The HTML should be 100% the HTML that I myself write. Drupal shouldn't modify this HTML or add HTML to it.

When the block's text format is set to "Full HTML" and edited in Source mode, Drupal keeps changing this:

<p style="color: #fff; font-size: 36px;">טקסט<br>
טקסט<br>
text</p><br&gt ...
Score: 0
Robert Neil avatar
How do I style a "Read more" button?
us flag

I installed the CKEditor Read More module. I want to style the Read more button to match the page background and change the button text color to blue.

I've searched all of the files associated with this module, but I found no CSS file for styling that button. I've also attempted to style the button using both internal and inline styling without success.

When the module is used, the following markup is pro ...

Score: 1
How can I modify a field using PHP code in "rewrite results"?
pg flag

Drupal 9.49

PHP 8.0

Views 9.49

I am returning the title field in a view. The title being returned is "XYZ Aberdeen".

I want it to simply return "Aberdeen"

When I click on "Content: Title" and then "Rewrite results" I was hoping I could simply use the following code:

<?php print str_replace('XYZ', '', {{ title }}); ?>

Can anyone tell me how to do this please?

Score: 0
Anche avatar
Email does not contain a link to the file attached to the contact form
pl flag

I am using the following code that programmatically creates a file and attaches it to a file field when a contact form is submitted.

function mymodule_form_alter(&$form, &$form_state, $form_id) {          
  $form['actions']['submit']['#submit'][] = 'custom_submit_handler';
}

function custom_submit_handler(&$form, &$form_state) {
  $file_contents = '777';  
  $filename = 'my_file.txt ...
Score: 0
user108721 avatar
Creating twig template for rows in a specific view
kp flag

Hi I have a view with the machine name news_filter. In the html every content type it's fields are inside a .views-row div. I want to create a template for those specific rows and maybe later also for each field too. But I can't find the right naming conventions to do so.

Does anyone have an idea?

Score: 0
jfc avatar
How can I get multiple results from the same filter with the REST API?
us flag
jfc

I am using the Drupal REST API UI module to create filters I can search. I have one for a page type called Category. If I want to search for category 52 I can use api/resources/?category_id=52.

I have some scenarios where I need to populate results from different categories. So for example I want all pages with category 52 and 57 to appear. If I try api/resources/?category_id=52&category_id=57, ...

Score: 1
Lambic avatar
Custom plugin definition not loading
ph flag

I'm trying to create my own plugin type in Drupal 9 but it's not finding my test definition and I can't figure out why.

Here's my services.yaml:

services:
  plugin.manager.reaction:
    class: Drupal\nm_events\ReactionManager
    parent: default_plugin_manager
  

Here's ReactionManager.php:

<?php

namespace Drupal\nm_events;

use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ ...
Score: 0
WebmasterPF avatar
User error : "2" is an invalid render array key dans Drupal\Core\Render\Element::children()
jp flag

I face off this message on certains pages, somtimes relate to twig template part, sometimes to other things. In watchdog:

    User error : "2" is an invalid render array key dans Drupal\Core\Render\Element::children() (/home//www/pfdev/multid9/recommended-project/web/core/lib/Drupal/Core/Render/Element.php ligne 98)
#0 /home//www/pfdev/multid9/recommended-project/web/core/includes/bootstrap.inc(347 ...
Score: 0
Entity print broken when updating to PHP8.1
kn flag

I've updated my drupal environment php 7.4 to php 8.1.18. i've enable some extensions, but I have this error when i try to download a PDF

Error : Typed property DOMDocument::$documentElement must not be accessed before initialization in Masterminds\HTML5\Parser\DOMTreeBuilder->startTag() (/var/www/myproject/vendor/masterminds/html5/src/HTML5/Parser/DOMTreeBuilder.php line 275)

#0 /var/www/myproject/v ...
Score: 0
Farhan Erooth avatar
How to save a customer profile to address book in Drupal Commerce using JSON:API
ng flag

In the commerce order checkout page, if you use "Save to my address book" checkbox in the billing address section, the address is getting saved to the user's address book. But if I am doing this using JSON request, how can I save the address to the user's address book and how can I load the saved addresses.

Score: 0
Michael Chen avatar
Field design problem for approval level + assigned user entity reference
nl flag

Say I have an approval system that needs to assign to users by levels with a limit of 5 levels

(say choose limit as 2 levels, then level 1 => uid 3, level 2 => uid4, that makes it a two level approval node).

Which setup of backend field is better on a decoupled system?

  1. Create a single entity reference field, use the delta weight as level for the user being referenced within.
  2. Create two field ...
Score: 0
Adamssef avatar
Disabling (or overriding) a css file from contrib module's library
in flag

I am using admin_toolbar module and I would like to override the path to a logo file that is by default provided by one of this module's CSS file.

I found information that I can achieve this with libraries-override in my theme.info.yml file.

The problem is that the file seems to be still loaded when I check the page source.

The file that defines the path to a logo file is located in:

/modules/contrib/ad ...

Score: 0
How can I delete an item depending on the processing result?
fr flag

I have a queue that is processed while cron run. processItem($data) checks some requirements.

How can I delete an item when some requirements are not met? Can I update an item (the $data array) and "mark" it for deletion in another cron job?

Score: 0
JamesH avatar
Is there a way to "migrate" data after an initial upgrade migration?
ax flag

I was hired into a role that has a Drupal 7 site that needed to be updated to Drupal 10. The project is an 8 month one.

I've done the initial process of creating a destination site, running /upgrade in the browser, and migrating the Drupal 7 database to the new destination Drupal 10 site's database.

We are about to go into testing and so I need to bring in all the data (Users, pages, forum posts, co ...

Score: -1
Grant a permission for the current page load
br flag

What is the best way to grant a user permission dynamically for a single page load? In other words, I want Drupal to behave as if the user has a certain permission when it loads the page, depending on conditions. But I don't want to save the permission to the user's account.

It's fine if Drupal doesn't respect the temporary permission after the page loads. The user can interact with the page a ...

Score: 0
FrankDesign avatar
How to Sort Views results based on two fields
cn flag

I have a view that lists nodes of type Article. Each Article includes a boolean field and a date field. Neither field is required. I want to sort the list of articles so that the first articles are the ones with the boolean field checked and with a date that is in the future (sorted by published date – newest first) followed by all the other articles sorted by published date (newest first) (whi ...

Score: 0
Alex Smirnoff avatar
Use specific theme [not template file] for 404 and 403 generated for specific path
mk flag

I have 2 themes, both enabled, assume they are called my_first_theme (default) and my_second_theme. I have /whatever path and lots of the pages under this path, and I have a theme negotiator, which sets my_second_theme as an active one for any page under this /whatever path, including nodes, views, custom controllers etc.

So far it works good. Problem is, when 404 or 403 is triggered, the theme used t ...

Score: 0
Dylan Spencer James avatar
Ordering comments on a forum topic by rating provided by Rate module, whilst retaining the correct threading
no flag

I have a forum with threaded comments. Each comment has a like button provided by the Rate module (which uses the Voting API). I want to order the comments on the forum post by the rating count value. I've started looking at the hook_query_TAG_alter() hook but I'm not getting very far.

Score: 0
jcaissey avatar
Webform Multiple File Upload Not Working Properly
gq flag

I have a webform on my Drupal 10 site which has a multiple file upload element. When uploading multiple files, if I click "remove selected" an Ajax error is thrown. The items stay on the page visually, but If I click submit, the files will not be uploaded to the server, so they are still removed from the upload queue.

I've so far been able to recreate this by creating a new file upload element, a ...

Score: 0
Why does twig tweak's drupal_field() function convert special characters to HTML entities?
cn flag

I'm using the following inside views to change the page title to the term name but it renders term names with & in them as &amp;

In the views override title section I'm using.

{{ drupal_field('name', 'taxonomy_term', arguments.tid) }}

I have tried adding render|striptags at the end of the function but that doesn't seem to work.

Score: 0
starplatinum123 avatar
Limitation submisson on webform hide my form
aw flag

I've created a form with webform and configured the submission limit, however when I test when arriving at the submission limit, the form is hidden : Nothing is displayed, As if there were no form at this location, whereas from what I've understood on tutorials, I'm still supposed to access the form with an error displayed on submission.

what could be the reason for this behavior, is it a setting ...

Score: 2
TripodC avatar
Removing phantom plugin from database
fr flag

On several sites I've worked on, for whatever reason before I put my hands on it, the database seems to register a plugin that is no longer in config or code.

This usually goes as follows:

[error] Drupal\Component\Plugin\Exception\PluginNotFoundException: The "name-of-plugin" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition()

In D7, it was relatively straightfor ...

Score: 0
Jordi Bustos avatar
Programmatically remove duplicated nodes without changing the number of nodes shown per page
mr flag

I have a content type called Página de área (Area page) referenced by two content type: Article and Agrupador. I have a view that displays all the Article nodes that share at least one area with an Agrupador node.

My goal is removing the duplicate nodes (I get calling $query->addWhere()) from the view.
I already tried using the Distinct and Aggregation options in the user interface, but they  ...

Score: 0
donbuche avatar
How to configure Page Manager variants based on Domain module?
cn flag

I've inherited a Drupal 8 website that must be upgraded to Drupal 9. The site has several subdomains declared, using Domain module.

Some pages are build with Page Manager, having 2 variants based on a domain selection criteria basis:

  • Variant "A" should be selected when the domain is www.example.com. I.e.: www.example.com/example-page
  • Variant "B" should be selected when the domain is NOT www.example ...

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.