Latest Drupal related questions

Score: 0
Jacob avatar
Programmatically add value to multi-valued/repeater field at weight/index
cn flag

In Drupal 8, I have a content type and more than a few nodes that have a Paragraph field with unlimited number of values, and so I need to programmatically add a paragraph at an index to the existing values in the field. I know in the form editor widget I'm able to add a field value then drag the field to the order that I need, or change the weight then save the content.

I'm currently loading the ...

Score: 0
john Smith avatar
How do I unset a link?
gr flag

I want to programmatically decide whether to render a link or not. This should apply to all links e.g anchor tags (no wysywigs) Not only menu links.

I tried using hook_link_alter.

/**
 * Implements hook_link_alter().
 */
function mymodule_link_alter(&$variables) {
  $my_logic = TRUE;
  if ($my_logic) {
    // Any way to not render the link?
    // I tried:
    // $variables = []; and unsetting ke ...
Score: 0
Token service not replacing text with term as a token
rs flag

I'm trying to use the token service to replace a piece of text using a Taxonomy Term.

Example:
Hi [term:field_first_name], ...

The term is getting loaded correctly, but the text is not changing:

    $term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($tid);

    $token_service = \Drupal::token();
    $text = $token_service->replace($text, [
        'term' => $term,
    ] ...
Score: 0
Anton avatar
Upload directory with no prefix (://) was not found for file uploads
de flag

I am not able to get file uploads of any type to work on my Drupal instance when I attempt to add media using the built in form. When I upload an image file, I get:

enter image description here

And looking at the log messages in Drupal I see:

The upload directory ://2022-05 for the file field field_media_image_private could not be created or is not accessible. A newly uploaded file could not be saved in this directory as a conseq ...

Score: -4
Which module defines this theme function?
cn flag

The code below uses a theme function defined by another module. Here is my code:

<?php

namespace Drupal\greeting\Controller;

use Drupal\Core\Controller\ControllerBase;

class PanelController extends ControllerBase {

  public function displayPanelPage() {

    $config = $this->config('greeting.settings');
    
    return array(
      '#theme' => 'panel_page',
      '#text' => $config- ...
Score: 0
How to add a submission handler to a form class on Drupal 8?
cn flag

I would like to add a submission handler to my form class so that the submitted values are saved. The parent class does not save them but only displays a message. I use Drupal 8! Here is my form class:

<?php

namespace Drupal\greeting\Form;

use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;

class GreetingForm extends ConfigFormBase {

  /**
   * {@inheritdoc}
   */
  ...
Score: 0
octogone.dev avatar
How do I select multiple values with one checkbox?
bf flag

With Facets module/search API, I have a checkbox filter where I need to merge some value.

Example:

vocabulary  = color

term = light red

term = dark red

term = light blue

term = dark blue

In this case i have 4 checkbox.

My checkbox should look like this

vocabulary  = color

term = red

term = blue

And When i tick Red it list all content tagged with dark red and light red And When i tick blue  ...

Score: 0
pglatz avatar
Change the PHP binary that should be used from Drush
in flag

I'm on an Ubuntu shared server hosted at pair.com. Their default PHP version is 7.4, but I was able to change it to PHP 8 for Drupal in my .htaccess; Drupal 9 works fine. My composer specifies PHP 8 and Drush 11.

When I run ../vendor/bin/drush, it thinks I'm using PHP 7.4.

Composer detected issues in your platform:

Your Composer dependencies require a PHP version ">= 8.0.2". You are running 7. ...

Score: 0
Upstream timed out (110: Connection timed out)
us flag

I installed opigno_lms 8.x-2.9, I created a training and want to publish it. When I click "Publish", the site try to load for 60 seconds and then get "Error 504: Gateway time-out". In nginx error log: "[error] upstream timed out (110: Connection timed out) while reading response header from upstream"

I modified php.ini:

max_execution_time = 3600
max_input_time = 3600

and added below to nginx conf  ...

Score: 2
sonfd avatar
Where can I find the Annotation(s) for test classes?
in flag

I've seen lots of examples of tests like:

/**
 * My test description.
 *
 * @group mymodule
 */
class MyModuleTest extends KernelTestBase { }

I know what @group mymodule is and how that annotation works, but what other information can I put there? or, more importantly, where is that information defined? I can’t find it anywhere.

Score: 0
thiokol avatar
Related content by taxonomy term but using a relationship between terms
cn flag

There are many posts and tutorials for creating views with contextual filters to display content that shares the same taxonomy term, but my requirement is slightly different.

I want to create a view that displays content that is related to the content being viewed via taxonomy terms BUT I do not want the related content to be based on the SAME taxonomy term, but instead a related taxonomy term.

I th ...

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.