Latest Drupal related questions

Score: 0
ab2211 avatar
Permissions by Term and Drupal Views
it flag

I created a content type with a taxonomy. I use the terms of the taxonomy as a category for a handbook to show different categories via views. Now, I have a section of the handbook, which should only be visible for one role. I thought I could realize this with the Permission by Terms module.

So, I gave access to this one term just to a specific role. The access to a node with the term is denied f ...

Score: 2
Grab State variable value from View grid - Drupal 9
in flag

I have a drupal view that has a multiselect field at the top. Based on the grid row selection and multiselect field value, specific actions are carried out on the grid rows. It's all based out of VBO module. View looks like below:

enter image description here

The multiselect field is the list of node title of a specific content type named "level2". I grabbed the "level2" node title and created that multiselect with the below code: ...

Score: 0
Interlated avatar
How do I add a field to a node form?
km flag

The goal is to set a default counter, but let people override it. The counter should be the biggest value of the field plus 1.

Using an event subscriber, FORM ALTER event.

public static function getSubscribedEvents(): array {
  return [
    HookEventDispatcherInterface::FORM_ALTER => 'setDefaultCbid',
    HookEventDispatcherInterface::ENTITY_PRE_SAVE => 'checkCbiRaceCondition'
  ];
}


public fu ...
Score: 1
Mauricio avatar
How to override a class method that is not a service?
lb flag

Usually we override services using RouteSubscribers, but i need to override a method of a class that is not a service. I need to alter the module of the core "views", the general structure of this module is:

> views
  > src
    > Entity
      > Render
        - ConfigurableLanguageRenderer.php
        - EntityTranslationRenderTrait.php

I need to override one method of one of those files. ...

Score: 0
jfc avatar
Possible to add end points using REST UI module?
us flag
jfc

I'm using the REST UI module with Drupal 9 with a view. Right now I have my default path which is /api/directory, and this has the fields I want in the API, for example title.

Is it possible to create an endpoint such as /api/directory?title=""

So that way instead of loading all the data on my site, I can only load what is necessary?

Score: 0
user3038672 avatar
Trying to access a "count" variable inside a block field from paragraphs template
cn flag

I'm trying to get the number of paragraphs an authenticated user inputs by counting them in the parent block template and trying to access that number in the paragraphs template. I have two templates I'm working with:

  1. field--field-hover-image-block.html.twig
  2. paragraph--hover-images.html.twig

The paragraphs are being loaded through the paragraph entity field in a custom block. I'm counting the numb ...

Score: 0
Author field in views-view-unformatted.html.twig
cn flag

I'd like to print single fields in views-view-unformatted.html.twig. I'm doing it this way:

{% for key,row in rows %}
  {{ view.style_plugin.getField(key, 'field_name') }}
{% endfor %}

But the author field isn't printing out. I tried

{{ view.style_plugin.getField(key, 'author') }}

and

{{ view.style_plugin.getField(key, 'uid_1') }}

which is the machine name in the view. But nothing works. In the vi ...

Score: 0
user3891775 avatar
substitute for \Drupal\file\Entity\File::load($fid) in Drupal 8.9
mx flag

My goal is to load a file and get its properties.

The method 'Load' does not exist any more in Drupal 8.9 (in the File.php file)

\Drupal\file\Entity\File::load($fid);

What would be the substitute for this function?

I'm using <theme_name>preprocess_views<field_name> hook to override the output of a view. From here I'm able to retrieve the file id by using

$fid = $variables['field']->get ...

Score: -1
Sorting Custom Content Type
mx flag

Apologies if this question has been asked but I can't seem to find an answer anywhere. I am looking to sort a content type called biography. My understanding is that this is likely a custom entity and does not come with Drupal Core.

We currently use it to add leadership information such as (ceo, assistant, admin) position. Currently, the sorting function in views is standard (ascending -authored  ...

Score: 0
ilechcod avatar
Pager element not showing on form
in flag

I have a simple tableselect element inside my form and the tableselect rows are populated using a pager as follows:

$pagerLimit = 10; //default value if nothing is passed in
$query = $this->jobSkillStorage->getQuery();
$query->condition('type', $skillType);   
$query->pager($pagerLimit)
$ids = $query->execute();
$jobSkills = $this->jobSkillStorage->loadMultiple($ids);  

return ...
Score: 0
Check minimum checked Checkboxes
kh flag

i am new to the drupal world.

I have created a web form, there are several checkboxes there. like:

[1]
[2]
[3]
[4]

I would like to check whether at least X of the checkboxes are selected before sending. I have no idea how to set it up.

I would be very happy to hear from you.

Thanks very much

Score: 0
drush updatedb error - The "hidden" plugin does not exist
us flag

When I ran the command drush updatedb its showing this error

>  [notice] Update started: text_post_update_add_required_summary_flag_form_display
>  [error]  The "hidden" plugin does not exist. Valid plugin IDs for Drupal\Core\Field\WidgetPluginManager are: comment_default, datetime_datelist, datetime_default, file_generic, file_editable, image_image, link_default, metatag_firehose, path, text_textar ...
Score: 0
João Mateus avatar
redirect an old url that no longer exists related to a file to a new one
ms flag

I have 2 urls: www.example.com/somefile.pdf www.example.com/somefileNew.pdf

the first one no longer exists, i want to redirect this url to the new one. I tried to use the redirect module to no avail as the module adds the site language to the url (ex: www.example.com/**en**) since the website is multilingual.

how can i achieve this? i tried https://www.drupal.org/project/media_entity_file_redirec ...

Score: 0
Style.css not workign in a classy subtheme
ar flag

I created a subtheme based on classy with this .info file:

name: youverify_theme
type: theme
description: This is a sub theme of Classy
core: 8.x
core_version_requirement: ^8 || ^9
# Defines the base theme
base theme: classy
# Defines libraries group in which we can add css/js.
libraries:
  - youverify_theme/global-styling
# Regions
regions:
  header: Header
  featured: Featured
  content: Content
 ...
Score: 0
Caching related to submit functions and Varnish
uy flag

I am trying to set my website ready before installing and configuring Varnish on it. For that, in lots of cases where I have php functions in .module files that include some tests about cookies if ($_COOKIE['travelID'] == 'yo'){..}, I was afraid that the page will be cached and the condition will be executed only once and then all the users will get the same result. To avoid this issue related to var ...

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.