Latest Drupal related questions

Score: 1
SomebodySysop avatar
How to add view filter programmatically using hook_views_pre_view()
gb flag

I want to add a simple filter to an existing view in Drupal 9. It appears that I can achieve this with hook_views_pre_view(). In every example I can find, including all the "Similar questions" links that come up when entering the title of this post, I see that $view->add_item() is used. See: Add views exposed filter programmatically

However, when I try to run this code:

function sbn_views_pre_view($vi ...
Score: 0
Custom block plugin: Give access to edit form
in flag

I am creating a custom block plugin with custom configuration options (blockForm()).

I would like to allow content editors to edit the configuration of this block, without giving them "administer blocks" permission. Also, I don't want them to create new block instances..

I would like to avoid installing an additional module like block_permissions, as this would introduce a wide range of settings or pe ...

Score: 0
Views: count flaggings per entity-referenced node
pe flag

I have a flag called Collect. (Flag is individual, and enabled on multiple content types.) The flag has an entity reference field to a content type called Bucket. When users flag nodes, they go to a form and select the bucket for the flagging in the entity reference field (field_bucket_select).

Users can view their Bucket list in a view that filters on 'current logged in user' (as well as the con ...

Score: 0
Provide menu link when creating node programmatically and append it to parent menu link
in flag

I am creating a Node programatically:

Node::create([
  'title' => "Some name",
  'type' => "people",
  'body' => $params['body'],
  'field_people_degree' => $params['field_people_degree'],
  'field_people_email' => $params['field_people_email'],
  'field_field_image' => ['target_id' => $this->createImageFile($params['field_field_image'], $params['field_pub_tool_id'])->id()],
  ' ...
Score: 0
Timberman avatar
Link user to a LDAP user
cn flag

I have the LDAP authentication module installed, and have a user that is not able to sign in using LDAP.

In the database I can see that there is no DN string for this user.

I have got the DN string for this user.

Is it possible for me to add this string somewhere in the database, for him to be able to login to drupal again?

Thanks!

Score: 0
Rainer Feike avatar
Create solr_core for search_api_solr 4.x with docker solr 8
in flag

I used to create my solr instance for drupal like this:

docker run -v $PWD/solrconf:/asdentcore  -e SOLR_JAVA_MEM="-Xms2G -Xmx2G" --restart unless-stopped  -p 8984:8983 -t --name asdentDevSolr -d solr:8.11
docker exec -it --user=solr asdentDevSolr  bin/solr create_core -c asdentcore -d /asdentcore

Where ./solrconf contains the files from modules/contrib/search_api_solr/solr-conf-templates/7.x.

With the n ...

Score: 1
Baud avatar
How to validate a paragraph field?
sa flag

I have a paragraph type with 2 fields: year and quarter

I have a content type with a paragraph field (field_year_and_quarter) targeting ONLY this paragraph type

I am trying to create a constraint to disallow the encoding of a duplicate (same year/quarter)

I have tried:

1-A constraint at the node level which is looping into field_year_and_quarter with $node->get('field_year_and_quarter')->reference ...

Score: 0
Arif avatar
How to get remote post handler returned response at module file?
us flag

I want to get remote post handler returned response inside hook_webform_handler_invoke_post_save_alter.

Please help me.

function hook_webform_handler_invoke_post_save_alter(\Drupal\webform\Plugin\WebformHandlerInterface $handler, array &$args) {
  $webform = $handler->getWebform();
  $webform_submission = $handler->getWebformSubmission();
  $webform_id = $webform->id();
  $handler_id = $h ...
Score: 1
How do I get the selected image style from a referenced media field?
cn flag

I created a custom block with an entity reference to a media field (field_background_image).
In the display settings I have chosen 'Thumbnail' as format and selected a custom image style 'background'.

In my _preprocess_block(&$variables) function I would like to get the selected format (thumbnail) and especially the selected image style ('background').
How can I load both these information from the $v ...

Score: 0
Dorian Winterfeld avatar
How can I stop Webform Spam?
ae flag

We are getting spam from a simple Contact Us webform. We are running Drupal 7, using the Captcha and Honeypot modules. The Captcha challenge is set to image and the Honeypot time limit is set to 4 seconds and in enabled for all webforms. But we recently started to get spammed at the rate of 4 or 5 posts per minute, all from different gmail or ru addresses. For the time being we unpublished the offen ...

Score: 1
Jaypan avatar
Is it possible to add an entity to the current route parameters?
de flag

Using \Drupal::routeMatch()->getParameter(), it's possible to fetch objects that come from the parameters of the URL.

I'm wondering if it is possible to add values to the routeMatch. For example, if using the Groups module, nodes may be part of a group, however the group is not part of the path. Is there a way to load the group from the node, and add the group to the parameters that can be retrieved  ...

Score: 1
Vince Saseniuk avatar
Adding a class to an image using preprocess function
ck flag

I am having trouble adding a class to an image using a preprocessor function in Drupal 9. Specifically, I only want certain images to have that class added. The image is being added using paragraphs.

I've tried a few variations of the following and cannot seem to get class added. I've also tried using ['#item'] but it causes an error.

function confluence_preprocess_field__paragraph__field_card_imag ...
Score: 0
Drupal 8 Webform multistep - send data to custom controller
cn flag

I'm trying to implement a multistep form with Webform. I have my custom controller that takes data from POST request and then rendering a page with result from the from.

But I don't get how to link the two. Webform Remote Post Handler doesn't seem to be the solution.

Score: 0
Adding theme JS library in custom module
pt flag

My theme documention.libraries.yml file is defined as follows :

global-styling:
  version: VERSION
  css:
    base:
      styles/dist/styles.css: {}
tocbot:
  js:
    libraries/tocbot/tocbot.js: {}
    js/tocInit.js: {}
  css:
    layout:
      libraries/tocbot/tocbot.css: {}
layout_tweaksLib:
  js:
    js/layout_tweaks.js: {}

My custom module implements a custom template which also requires the theme fu ...

Score: 0
Amine avatar
Vertical tabs custom form Drupal7
us flag

I have a question to discuss about Vertical tabs on Drupal7 when we use it on custom module to make a form.

Can we use a vertical tabs on a another vertical tabs?

I know how we do to make a one vertical tabs but with one on another i think maybe one day we need it.

Score: 0
Gunnar Vestergaard avatar
The quick-start script in Drupal fails
de flag

I am trying to install Drupal v 9.2.9 on my web server. I was informed by core/INSTALL.txt that I could run the script

php core/scripts/drupal quick-start

It stops the installation prematurely with an error message:

In RouteProvider.php line 206:
Route "user.reset" does not exist.

How do I solve this? I have not set up a database yet. The web server has MySQL and PostgreSQL installed.

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.