Latest Drupal related questions

Score: 0
How to use patch request with parameters in custom rest resource?
kr flag

I am creating a custom rest resource.

/**
 * Provides a resource to update nodes.
 *
 * @RestResource(
 *   id = "my_custom_resource",
 *   label = @Translation("Custom rest resource"),
 *   uri_paths = {
 *     "canonical" = "/custom-api/{node}",
 *   }
 * )
 */
class MyCustomResource extends ResourceBase {

  public function patch(EntityInterface $entity, $data = []): ResourceResponse {
    retur ...
Score: -1
MetalBearSolid avatar
anchor menu description under each menu in menu.html.twig
br flag

I am currently displaying the Menu "description" underneath each link using menu.html.twig. by doing this:

{% if item.original_link.getDescription %}
  <span class="navigation__link-description">{{ item.original_link.getDescription() }}</span>
{% endif %}

The issue is that it's not anchored with the URL due to it being outside {{ link(item.title, item.url) }}. Does anyone know what I ne ...

Score: 1
Geat avatar
What's the equivalent of drupal_build_css_cache()?
de flag

Our client uses an external website for some of their pages. This provider does not enable us to theme their website directly, but they do allow us to load a single JS file from the Drupal site that we maintain.

We create this JS file through a Drupal route/controller, assembling the header and footer blocks, including CSS and JS files, and inserting them into the content by appending them to the ...

Score: 2
liquidcms avatar
Why can't some fields be moved within details element?
us flag

I am trying to move 2 form fields to the advanced sidebar: dismissible and status. Status was already part of the meta container and setting #group='meta' on dismissable also placed it there; but these weren't in the proper order. Nothing I do seems to have any impact on:

  • dismissible
  • standard meta fields: published, author, revision log
  • status

Both dismissible and status are fields added by the

Score: 0
Tommy Styrbæk avatar
Ajax message after node save
cn flag

I am trying to add a Ajax Alert or popup message inside a hook_node_presave or hook_node_update, but it is not working.

My current code look like this, but I have tried a lot of other ajax

$response = new ajaxResponse();
$response->addCommand(new AlertCommand('Ajax test'));
return $response;

The node is saved but no alert and no errors in the console. Drupal 9

Score: 1
How to implement TrustedCallbackInterface
us flag

I'm maintaining a module that I've had a 3rd party dev build for me. I D9 this issue has appeared when using the module that otherwise works in D8 and should be compatible with 8 & 9.

The module creates blocks with event dates pulled from the Songkick service but on D9 pages with a songkick block enabled throws this error:

Drupal\Core\Security\UntrustedCallbackException: Render #pre_render c ...

Score: -3
mt.i.1 avatar
Search and pagination in media popup don't work properly
us flag

In the /admin/content/media page, I have more than one button for the pagination.

screenshot

The search is working properly.

screenshot

When I edit a media on some node, in the popup, I only have one button in the pagination.

screenshot

The search isn't always working. Here, I'm making the search from the page 2, where the image isn't available directly.

screenshot

It only works when the searched image is on the current page (selected ...

Score: 0
Can users with a custom role approve the user registration?
cn flag

I have created a site that requires approval of new user registrations. I added the Manager role for the site owner. I'd like users with that role to approve the account registrations.

Is there any configuration that will give another role the permission to approve new user registration?

Score: 1
Steve Siddu avatar
Filter view based on current user's role and taxonomy terms
br flag

I have three content types.

  • Article
  • Basic Page
  • Custom Page

All the content types have a field_interests field, which can have multiple values, and which is an entity reference field to the interests vocabulary.

The taxonomy terms for that vocabulary are:

  • sports
  • songs
  • movies

I have three user roles.

  • Athlete
  • Singer
  • Actor

I want to create a view in which:

  • Athlete users can view nodes for which  ...
Score: 0
abelass avatar
Custom validation constraints multi value paragraphs : how to get weight value
nl flag

I am validating a multi value paragraph field using constraints.

/**
 * Implements hook_entity_bundle_field_info_alter().
 */
function cnfpt_internet_entity_bundle_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle) {
  if ($bundle === 'manifestation') {
    if (isset($fields['field_occurence'])) {
      // Add a validation.
      $fields['field_occurence'] ...
Score: 0
abelass avatar
Custom constraints validation of multi value paragraphs: highlighting missing field
nl flag

I am using constraint for the validation my multi value paragraph field.

I can correctly implement the different validation rules but I haven't found out how to highlight only the erroneous field(s).

Here is my violation declaration

      $this->context
       ->buildViolation($constraint->modaliteRequise)
       ->atPath((string) $delta . 'subform.field_modalite.0')
       ->addViolation( ...
Score: 0
Joost avatar
How to debug ccs and js aggregation problem
jp flag

I'm working on a D9 website. On my local server I have all caching and performance settings like js and css aggregation turned off. Now when I copy my site to me remote server these settings are on. Good to know is that I use advagg next to the core performance options.

But on some of the pages in the back-end of the website I get js errors resulting in problems with, for example, admin_toolbar and

Score: 0
shablm avatar
Post Data to D7 from D9
cn flag

How do I post data from Drupal 9 when a content is created, post data to Drupal 7 hosted in a different server to create node content.

In Drupal7, I have enabled services module and created a resource to create login session, accept json data and creates node content. This is working fine when I test from POSTMAN.

I am new to Drupal 8/9 and not sure how to post json data to D7. Please could anyone  ...

Score: 0
mxr10 avatar
How do I programmatically set a content reference by name for a node?
id flag

Hi team i have some isssues.

I'm creating a node and i would like to set a content reference by name not by id, i'm doing this but this is not working: 'field_content_type_items' is referenced to another content type

$node = \Drupal\node\Entity\Node::create([
    'type' => 'items',
    'status' => $status,
    'title' => $title,
    'field_content_type_items' =>  "CUN",
]);

Also i tried with  ...

Score: 0
quantumized avatar
D7 to D9 /upgrade migrates content types to new site but not their fields
ng flag

Using Drupal's migration by going to /upgrade and the upgrade creates the content types in the new D9 website but they do not contain any of the fields that were in the original D7 content types. Only the body field is present.

The fields are all listed in the "field list" (admin/reports/fields) though, but without any nodes associated.

Any ideas as to why the fields are not being attached to the co ...

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.