Latest Drupal related questions

Score: 1
How do I install a working demo?
us flag

I have been struggling with this for quite some time. I am trying to install a demo of the Commerce module as provided by Centarro, but every time the install finishes, I only get an empty site with the Beograd theme enabled but no product catalogue at all.

Here's what I do every time I try.

  1. I install the Commerce module via composer create-project.

    composer create-project drupalcommerce/demo-project dem ...

Score: -3
How to pass an argument to a hook without creating a custom module?
cn flag

I need to attach a theme-agnostic ("global") CSS file to the preprocess_hook() function so that any theme I use, would include that CSS.

I want to do that without creating a custom module because while I am a programmer, I am just not a PHP programmer and I find the documentation about creating custom modules overkill for this specific goal and I won't learn this entire subject just for a CSS file.

 ...
Score: 1
Giuseppe avatar
How get webform translations programmatically?
br flag

I'm on Drupal 9. I need to load the options labels of a Webform's option programmatically.

So far, I've managed to load the labels:

  $element = $webform_submission->getWebform()
      ->getElement($element_key, TRUE);

  $option_text = WebformOptionsHelper::getOptionText($element_value, $element['#options']);

However, I also need to get those labels for both the language of the site - en and

Score: 0
ab2211 avatar
Caption for colorbox gallery
it flag

I added a little gallery via colorbox to a content type. I just added an image field with no limitation and as formatter colorbox. Now I'm struggling, because I would like to have an image description at the page not only at the lightbox. I found a template with the following content <a href="{{ url }}"{{ attributes }}>{{ image }}</a>.

I could solve this if a could add the alt or title there ...

Score: 0
Migrate accessing source fields by name instead of by selector?
in flag

I'm working on the MongoDB source plugin and I'm able to do the migration, but I have to make strange compromises. When defining the source fields, I have to set name the same as selector, like this.

fields:
  -
    name: _id
    label: 'Unique ID'
    selector: _id

That works, but if I decide to change field name and keep selector, the migration fails.

fields:
  -
    name: node_id
    label: 'Uni ...
Score: -1
Options for pml command with Drush 10
us flag

I just install a Drupal 9.2 site and Drush 10 to manage it. Usually I use Drush 9 and Drupal 8.9.

It appear option for pml command seem not to work in Drush 10 as it do in Drush 9. Example:

 drush @pfdevd9pf pml --filter=rss
  The "--filter" option does not exist.

drush @pfdevd9pf pml | grep "rss"
 RRSSB  Ridiculously Responsive Social Share Buttons (rrssb)   Disabled   8.x-2.3

This is a weird thing, th ...

Score: 0
mt.i.1 avatar
Adding custom field generated by drush to available fields on node
us flag

I have an existing custom module on my D9 website and I need to make some changes inside it. I want to add a field (boolean) into any content type page edit without doing it manually.

So I need my field to be available here /admin/structure/types/manage/mycontenttype/fields/add-field

On my CLI, i've run this command drush generate field, which gave me those files :

  modules/custom/mymdule/config/ ...
Score: -1
Change CSS without changing the website's filetree
cn flag

I need to change the CSS of my current theme a bit (say, up to 100 lines).

I don't want to create a sub-theme and I don't want to directly edit my theme's files (even though it's premium theme which gets upgraded maybe once in two years so migration, in such a case, would be easy).

Rather, I want to add some global CSS which effects any current theme (given selectors are still matched), but preferabl ...

Score: 0
hank avatar
Problem with upgrading because an unmigrated module
mx flag

I am trying to migrate a Drupal 8 site to Drupal 9. Though most of the migrations have gone easily, this site breaks because it uses the Video module, which hasn't been updated for Drupal 9.
Specifically, the problem happens when I try to run drush updb. I geet this error message.

Unable to determine class for field type 'video' found in the 'field.storag e.paragraph.field_video_item' configurat ...

Score: -1
How do I access the protected value of node entity?
in flag

I have a view node and I use the below code to Kint out the node objects:

$node = \Drupal::entityTypeManager()
      ->getStorage('node')
      ->loadMultiple();
 dpm($node);

returns the below output:

enter image description here

I get to see the properties of each node. In this, I want to access the target_id/value of the highlighted field - field_cp_level2_ref_level3. I tried the below line and it is coming out as null:

Score: 1
Custom field formatter fails in create()
cn flag

PHPStorm, PHP 7.4 IDE highlights $container->get('date.formatter'), with

"Expected parameter of type '\Drupal\Core\Datetime\DateFormatterInterface', 'object' provided"

This function is an exact copy of the core TimestampFormatter (which also shows the error)

/**
 * {@inheritdoc}
 */
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definitio ...
Score: 0
Patrick Star avatar
Hook for field not triggered when using delta in template
ie flag

I tried to hook my Link type field with machine name "field_link". This field is rendered in template using delta index to extract some values, e.g.:

{{ content.field_link[0]['#title'] }}

I have noticed that when I use content.field_link[0] or content.field_link.0 my hook HOOK_preprocess_field__field_link(&$vars, $hook) is not triggered. But as soon as I use content.field_link the hooks works.

Score: 1
quantumized avatar
Is there a way to pull the 'description' metadata from Media's Remote Videos?
ng flag

We have a Drupal 9 site that is using Media's Remote Video for YouTube videos. We need to pull the YouTube video's description but I do not see any way to accomplish this. The end result will be to display the YouTube description in a View.

EDIT: The screenshot shows that there is no "description" field in the Remote Video's field mapping.enter image description here

Score: 1
Kevin avatar
Output JSON string into PHPTemplate file
in flag

I want to output a JSON string as part of a data attribute on an HTML tag for a template in Drupal 7. For the life of me, I cannot figure out why it does not work (works perfectly in 8+).

I need to list a set of image urls and media sizes which is parsed by Javascript later.

In template.php:

    $variables['background_images'] = [];

    $variables['background_images'][] = [
      'srcset' => 'https:/ ...
Score: 0
Dimetry avatar
Alter route path within event_subscriber with GET parameters
cn flag

I know I can alter route path with event_subscriber

class AdminRouteModifier extends RouteSubscriberBase {

  protected function alterRoutes(RouteCollection $collection) {
    if ($route = $collection->get('entity.admin.collection')) {
      // Set new path for the route
      $route->setPath('/admin/entity_admin_collection/newpath');
    }
  }

}

But I cannot find how to get link with GET pa ...

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.