Latest Drupal related questions

Score: 0
mankin avatar
Change operator in a query?
am flag

I'm working in a Drupal 9 website.

I need to change operator in my view query from != to <. In a view i got two contextuals filters:

  • The first to retrieve id from an entity reference field.
  • The second to retrieve current node id.

In the second contextual filter, exclude is selected to be != in my query.

The result i need is to transform this != to < for show all nodes who got the same reference fi ...

Score: 0
D. Jansen avatar
One taxonomy filtering two fields
sn flag

I have 2 fields on one node that both read the same taxonomy (Normal features and special features).

Now I want to show only 1 filter in the view that looks in both fields. And with the "Combined fields" filter I don't get these fields as an option, let alone only get a text field and no checkboxes

Score: 0
Adam888 avatar
Why is this if statement not working correctly in Webform computed twig?
ph flag

I'm using this in a computed_twig element and it's fully working when I test it in this fiddle but only works correctly for value "0" while gives "high" for everything else (e.g. 0.1, 0.4, 0.5, etc) when in my webform!
q# are values of radio input type elements. I tried several variations all to no avail! Thanks

Edit: updated my question and added a minimal sample of my webform. I didn't post thi ...

Score: 0
shibasaki_stack avatar
How to change markup of modal dialogs
zm flag

A modal form is defined in openModalForm(), and the modal form is called by $form['open_modal'].

public function openModalForm() {
  $response = new AjaxResponse();

  // Get the modal form using the form builder.
  $modal_form = $this->formBuilder->getForm('Drupal\workitemmanager\Form\WorkitemModalForm');

  // Add an AJAX command to open a modal dialog with the form as the content.
  $response-&g ...
Score: 0
JM John avatar
SQL injection POST attacks
mz flag

Just found hundreds of POST requests to user registration pages on Drupal site. No users are being registered but these requests are still getting 200 status from Drupal.

Are these requests doing any damage? Any preventive measures I can undertake other than blocking them through Firewall.

Post Data/Request Body:

"{\x22name\x22: \x22oXfxOznTkE\x22, \x22mail\x22: \[email protected]\x22, \x22form_build_ ...
Score: 1
john brush avatar
While upgrading from D6, update.php appears to expect the Drupal 7 version of the database array and it throws errors
et flag

Leaving settings.php in place (but writeable), per instructions 13 + 14 of major upgrade section of https://api.drupal.org/api/drupal/UPGRADE.txt/7.x , with the new D7 codebase but the old D6 DB, i get the following errors:

Notice: Undefined offset: 0 in Database::parseConnectionInfo() (line 1529 of [...]includes/database/database.inc).
Notice: Undefined index: driver in Database::openConnection() (line ...

Score: 0
fallenturtle avatar
How to make it so theme function isn't used when editing a node with layout builder
au flag

I have the following two functions in my .theme file that I'm using to gleam various bits of information from both the path alias and internal URL of the page being viewed. They are:

function rtv_preprocess_block(&$variables) {
  $internal_path = \Drupal::service('path.current')->getPath();
  $current_path = \Drupal::service('path_alias.manager')->getAliasByPath($internal_path);
  $variab ...
Score: 0
RustedBucket avatar
Can I get form values in a controller after form has been submitted?
cw flag

I'm working in D10 and what I have is a simple search form. It's two fields 'searchKey' (textfield) and 'showHidden' (checkbox). When the form is submitted a list of records is return and displayed in a table but I want the search form to always be available. What I have done is used a controller to build the record tables and the form api to build the search form itself.

The controller loads the ...

Score: 0
agodin avatar
How to move add button above listing for inline entity form
in flag

We're using Inline Entity Form for a project and we have a bunch nested content types.

For one of those content types, we want the add button to be above the listing of existing entities of that type ... how can we do that cleanly?

I could probably just cut and paste the button using jQuery but there has to be a way to do this using hooks but I haven't found the right one yet ... any help is appreci ...

Score: 0
quantumized avatar
How can we resize a Media Image inserted using Ckeditor5?
ng flag

D9.5 - Ckeditor 1 (v5)

We have Media Images and are using Ckeditor's "Insert Media" button in the WYSIWYG but we cannot resize the images.

Is this possible with Media images?

Score: -1
"No route found for GET" on custom REST resource when posting
cn flag

I'm seeing really weird behavior. I've created a custom REST resource at the route /user/login-special.

This is a passwordless login resource, so I pass the mail address and then get a response that says Login email was sent!

However, when I POST to the https://abc-xyz-123.us-3.platformsh.site/user/login-special?_format=json, I get the error:

{
    "message": "No route found for \"GET https://www.abc ...
Score: 0
JM John avatar
How to log incoming POST requests
mz flag

We are seeing a lot of POST requests by bots to /register pages or pages with forms. This is likely an attempt to make an SQL injection.

What's the best way to log the full POST request and see the payload data?

Cheers

Score: 0
"Language missing or invalid"
eg flag

I am using Drupal Version 9.5.5 and Forum core module. After enabling the module and creating a forum container, forum, and topics, the module creates a page at /forum/ with a table list of the forums.

Chrome Wave shows an error in the Last post column: Language missing or invalid. It is coming from the variable {{ forum.last_reply }}

This is an example of the HTML markup.

<a title="View user p ...
Score: 0
Chris avatar
Show Siblings via Views and taxonomy term in a block (again)
ec flag

I've got a

  • D9 site
  • with an Event content type and a reference to the
  • place taxonomy term

In the taxonomy term, there is a field zip_code. The taxonomy terms are setup in a hierachy:

  • State 1
    • County 1
    • County 2
      • Town 1
      • Town 2
      • Town 3
  • State 2
    • ...

Now, someone would search for the zip code and find e. g. Town 1. I've got one page which will show the referenced events within town 1 - no problem at al ...

Score: 0
Francesco avatar
Leaflet custom marker doesn't work on multiple points
ht flag

I am using Geofield field with Leaflet module. I need to customize the marker and I'm having a problem with content types that have more than one point on the map.

While for ctypes that have only one dot the marker is replaced correctly, for cypes that have multiple dots or a dot and a dash the marker always returns to the default one.

Has anyone had a similar problem and know how to fix it?

Score: 0
Christoforos avatar
Override the results of Search API pages module
lc flag

I have disabled the default search and enable module 'Search API' and Search API SOLR(used for Backend) to perform search in Drupal 9. I have also enabled Search API pages module and created a search page through this module.

Search API pages module has 2 twigs in folder templates. I have overridden both and when I make a change in search-api-page.html.twig I see difference in the search page but ...

Score: 1
How can I render comment pager on the top and the bottom of the comments portion of the page
pe flag

When comments are numerous on a node and you have a high comments per page setting, you have to scroll a lot to get to the pager. My users have requested pager at top as well as bottom of the comments list (not the top of the page) on a default node page.

To clarify

Current page layout

  • Title
  • Content
  • Comments
  • Pager
  • New comment form

The desired result is

  • Title

  • Content

  • Pager

  • Comments

  • Pager

  • New com ...

Score: 0
How to enforce a specific aspect ratio for all Media images?
cn flag

With the core media Image type, I want to restrict uploaded images by aspect ratio.

I want to block images that have the wrong aspect ratio from being uploaded. My question is the same as this Drupal 7 question, but for Drupal 8+.

Score: 0
NunesRodz avatar
Custom field Widget multiple values as a Table
gs flag

Hello I created a custom field type and field widget with multiple values, one entity reference and two checkboxes.

Everything's was working well, but to improve the usability of the fields, I would like to display the fields as a table, and that is when my problem begins.

I tried changing the field widget to be like a table, that visually worked to me, but now I will have problem because the keys o ...

Score: 0
Todd avatar
Displaying an entity pager in an article if that article is included in an entityqueue
mv flag

I want to have a pager at the bottom of articles that a user can cycle through, that consists of other articles that are in the same entity queue list that the current article is also inside of.

I'm using Entityqueues to create arbitrary lists of articles and I'm using Entity Pager in a view to display that list of entity queue items a set of previous/next navigation links.

Within the entity pager v ...

Score: 0
abe-cedarian avatar
When iterating over multi-value fields is it considered best practice to override the field template vs loop over the var in node or block template?
kr flag

I have a link field that allows multiple (3 max) values on a custom block for which I'm using a twig template.

I want to iterate over the values using a for loop.

I got this to work the way I wanted in my block twig like so:

{% for key in content.field_footer_cta_buttons|keys %}          
  {% if key matches '/^\\d+$/' %}
    <a href='{{content.field_footer_cta_buttons[key]['#url']}}'>{{ content.f ...
Score: -3
beltazzar avatar
Does Drupal core include any comment spam prevention mechanism?
do flag

I have a Drupal 9 core website and I have allowed comments in it (approval needed).

The problem is that my website is flooded with spam boots posting links in pre-approved comments. This causes burden of filtering human-legitimate comments. I also desire not to install any modules and work only from the core.

Does Drupal core include any comment spam prevention mechanism?

I don't recall ever finding a  ...

Score: 1
Tobias Krause avatar
Custom views filter plugin: filter over two fields of a custom entity where one of the fields is a multi value field in a seperate table
cn flag

I have a custom entity with two basefields of type "list_string": "role" and "additional_role". I need this as "role" is used for sorting the entities by a very specific logical order (like the "boss" comes first and the "team lead" after the "boss"). The "role" basefield is a simple one-value field which is stored in the entity table in one column but the "additional_roles" is a multi value field which ...

Score: 0
user5274714 avatar
How can I fire a Google analytics tag event on every form post?
bi flag

I want to see statistics for forms submissions, grouped by type of forms. I am using Google Analytics 4 (https://www.drupal.org/docs/contributed-modules/google-analytics/using-google-analytics-4x). I tried adding a GA event on form submit like this:

 /**
 * Implements hook_form_alter().
 */
function mymodule_form_alter(&$form, &$form_state, $form_id) {
  // Add the tracking functionality to th ...
Score: -2
MrUpsidown avatar
Issues updating from 9.4.3 with composer
eg flag

I have a project that wasn't updated since a few months and I am stuck on 9.4.3 with composer refusing to update.

Here is my composer.json

{
    "name": "drupal-composer/drupal-project",
    "description": "Project template for Drupal 9 projects with Composer",
    "type": "project",
    "license": "GPL-2.0-or-later",
    "authors": [
        {
            "name": "",
            "role": ""
        }
 ...
Score: 0
user110123 avatar
How would I access the pdf generated by Webform's Attachment PDF in a custom Webform Handler?
ge flag

I have created a custom Webform Handler that takes the files uploaded by the user on a Webform and uploads them to the third-party file management system Box via Box's API. I want to also upload the Attachment PDF that is generated but I don't know how to get the file programmatically. I can click on the pdf links generated and they successfully download as expected. However, if I try to load that fi ...

Score: 0
Iulian Boiculese avatar
How to display the output of the View as json in the list of articles which use paragraphs?
sk flag

I have a content type Article which has a field_paragraph field.

Also I created a Paragraph type: View Paragraph which has a View reference field

When I create an article, in the field_paragraph field I added a reference to a view in order to get the list of titles from another content type: Basic Page.

I'm using JSON API module in order to get the list of articles in json format for a front-end app ...

Score: 0
Using the off-canvas dialog, how can I submit and close it, without redirect?
cn flag

I use this as link:

<a
  class="use-ajax"           
  data-dialog-options="{&quot;width&quot;:800}" 
  data-dialog-renderer="off_canvas" 
  data-dialog-type="dialog" 
  href="/group/1/content/create/group_node%3Apage"
>
  Create page
</a>

When submitting the page, I like the dialog to close without redirecting the new page created.

How can this be accomplished? If I add ?destination= ...

Score: 2
Tomáš Bažant avatar
How to group taxonomy terms by depth in views?
de flag

my example taxonomy looks like this:

- fruit
 -- apple
 -- orange
 -- banana
- vegetable
 -- carrot
 -- cabbage

i want to render a page in views that groups level 1 terms by their parent term, The page should look like:

Friut
apple | orange | banana

Vegetable
carrot | cabbage

How can i do such grouping? Thanks!

Score: 1
Adamssef avatar
Replace MessageTemplate with token value and send the message
in flag

I'm having some trouble getting the tokens in my Drupal 9 message template to work properly. I have created and saved a message in my UI using the structure->message templates section, with a WYSIWYG text format field that contains the following:

User [user:account-name] changed details. https://mysitename.com/user/[user:uid]

I'm concerned about the code snippet I've been using to send this message,  ...

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.