Latest Drupal related questions

Score: 2
liquidcms avatar
How to add views aware configuration options to a field formatter?
us flag

There is a contrib field formatter module (bg_img_formatter) which has numerous field configuration options. One of these options is a text field which needs to allow for the same views field replacements as the "Rewrite Result:Override the output of this field with custom text" does. But as this is a "field" formatter and not a "Views field" formatter; the formatter class and specifically its viewEleme ...

Score: 5
How does the Geolocation content of a page filter is a Views block?
cn flag

I have a website with Drupal 9 and the Geolocation module :

https://www.drupal.org/project/geolocation

I created a content type with a Geolocation field that contains coordinates.

My website uses the Olivero theme. I want to create a Views page with the summary my nodes and create a Views block with my nodes on a map.

The block must be on the same page, but it must be in the "Hero (full width)" r ...

Score: 2
Carl avatar
How can I disable products so they are unpurchase-able and also display in a view?
cn flag

I have a view of published products. I want to also create a view of unpublished products, so users can see previous products that were available, but there shouldn't be an Add to cart on these products.

I've unpublished the products and created a view of these. Admin can see the results in the view and when they click on one of them there is still an add to cart to button. Anon users can't see t ...

Score: 0
After updating from 9.2 to 9.3, my site breaks, but turning CSS/JS aggregation off fixes it. What can I change to make it so I can turn it back on?
pk flag

After updating from 9.2 to 9.3, my site breaks. When I turn off CSS and JavaScript aggregation, it fixes my 9.3 versioned site. I would like to turn it on as that would speed up my site. Normally I find the issue is that the correct owner isn't in place or the permissions are off. My sites/default/files directory seems to have the correct permissions of 775 and the correct owner, being the server. Th ...

Score: 0
Md. Shafiq Hossain avatar
Node form ajax dependent dropdown fields issue
cn flag

I am using Drupal 9. I know how to change single dropdown list using another one. Here is my scenario:

I have three dropdowns, in node form - company, protocol and investigator. What I like to do, when some one select a value in company dropdown, other two dropdown list which change based on selection.

I have written some code, I see the list is updating but its not refreshing.

function hook_form_alter() ...
Score: -1
Matoeil avatar
How do I sanitize the uploaded files name for sending safely as email attachments?
za flag

I have create a form that upload a file. This file is send as email attachment

 ..
     $form['cv'] = [
          '#type' => 'managed_file',
          '#title' => 'Votre CV',
          '#required' => true,
          '#upload_validators' => [
            'file_validate_extensions' => ['pdf doc docx odt odf'],
            'file_validate_size' => 4000,
          ],
        ];
..

on form ...

Score: 0
Joost avatar
Programmatically add Views block to field group
jp flag

I want to programmatically add a view to a field group I created using the field_group module. I created an group_articles tab field group.

When I do this something like hook_form_alter:

    $form['issues__articles'] = array(
      '#type' => 'fieldgroup',
      '#weight' => 0,
    );
    $form['issues__articles']['view'] = [
      '#type' => 'view',
      '#name' => 'view_admin',
      '#disp ...
Score: 0
Tushar avatar
Getting issue on views import?
nz flag

Accidentally I have deleted the views relationship field. After that I am getting error when try to open views configuration page.

To fix the issue I have exported that view from site configuration single item and change in yml file. But when I import the changes getting below error.

Configuration block.block.test_local_tasks depends on the test theme that will not be installed after import.

Configurat ...

Score: 1
Jimmyb_1991 avatar
Can you install exported site config as part of a kernel test?
cn flag

I am using the Configuration Sync module to export config specific to my site out into a config directory that lives outside my main Drupal directory.

When writing kernel tests I know that you can use $this->installConfig() and specify a module(s) to install default config from, but how can I specify certain (or all) config files from that directory to be installed inside of a kernel test?

Score: 2
quantumized avatar
How can we create sums of a View's table column values in a header and/or footer?
ng flag

We have a View with multiple decimal field value rows. We need to create a sum (add all of the values) for these columns in a header and/or footer of the View. I see there is a D7 module called Views Calc that looks like it may do what we need but there is no work on a D8/9 port.

How can we accomplish this in D9?

enter image description here

Score: 0
How to get the url of a link field in field.html.twig
in flag

Inside the field--link.html.twig file, I'm trying to output the url from a link field like so:

{% for item in items %}
  <div{{ attributes.addClass(classes) }}><a class="button" href="{{ item.content.uri }}">Apply Now</a></div>
{% endfor %}

I've tried the following to get the url, and nothing seems to work.

  • item.content.uri,

  • item.content.uri,

  • item.content.url,

  • item.content. ...

Score: 1
liquidcms avatar
How to get a rendered views field value programmatically?
us flag

Yes, I see there are many answers already posted here and elsewhere for this; but sadly they are all wrong. These answers include any of the following:

$view->style_plugin->getFieldValue($rid, 'field_myfield');

foreach ($view->result as $rid => $row) {
 foreach ($view->field as $fid => $field ) {
   $values[$rid][$fid . '-value'] = $field->getValue($row);
   $values[$rid][$fid ...
Score: -1
How do I use `NestedArray::getValue()` to get a value from an array?
et flag

I see the NestedArray::getValue() but the documentation isn't clear. How do I use this to get a value out of a nested array, such as form state or raw form input?

Score: 0
May  avatar
Ho can I add a class to a specific row in views-view-field template?
zw flag

I have created a custom views-view-field template and added some custom html and views field similar to this

<div class="{{ fields.my_text_field.content }}">
  {{ fields.my_media_field.content }}
</div>

The trouble I am having is that I want to add classes on certain rows only. Similar to below

<div class="{{ fields.my_text_field.content }} not-row-2">
  {{ fields.my_media_field ...
Score: 2
Yuseferi avatar
Enable image resizer for all images in the ckeditor
cg flag

I'm using Drupal 9.2.9,

I have some migrated content that comes from an external source. there are some <img tags,

the Ckeditor image resizer is working for the images I insert into the editor the upload icon but for the images that come from the content migration, the resizer is not enabled.

enter image description here

I even tried to add height manually to the <img tag but nothing appear.

the question is that, how can I ena ...

Score: 0
miststudent2011 avatar
How to create a View to display nodes with empty entity referenced fields
fr flag

Can anyone please help me to create a view when entity referenced field is empty. I have a body field where various paragraph fields are referenced. I would like to get list of nodes whose body field is empty.

By default body field is entity referencing to one text paragraph. Even if it is not a required field.

Even thought the para is empty it is not being displayed in the results. If I remove defa ...

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.