Latest Drupal related questions

Score: 2
Souvik Das avatar
Append new paragraph item to existing node
rs flag

I want to append a new paragraph item to a existing node, which has previously a paragraph item. I just want to add another paragraph item with the previous one. But my script only updates the previous added paragraph item with the latest data, not appending with the previous one.

$nid = \Drupal::entityQuery('node')->condition('title', $product_name)->execute();
        $nid = array_values($n ...
Score: 0
Jaypan avatar
Programmatically render block content render array with wrappers
de flag

I'm trying to render a custom block, created through the UI, programmatically with a wrapper. I can do this:

$block = \Drupal::entityTypeManager()->getStorage('block_content')
  ->load($bid);

$output['header'] = \Drupal::entityTypeManager()
  ->getViewBuilder('block_content')
  ->view($block);

And the block is rendered, but only the fields of the block - the block wrappers are not rendered. ...

Score: 0
AllisonC avatar
Twig output not styled correctly
cn flag

In one of my twig templates, I have:

<pre>{{ dump() }}</pre>

Twig output looks like:

Sfdump = window.Sfdump || (function (doc) { 

enter image description here

Controller (partial code):

$renderable = [
  '#theme' => 'child-profile',
  '#profile' => $records,
];
$output = Drupal::service('renderer')->renderPlain($renderable);
return [
  '#type' => 'markup',
  '#markup' => $output,
];

How can I get this  ...

Score: 0
awm avatar
How to make a traditional entity field excluded from revision?
mx flag
awm

Is it possible to make an entity field excluded from revision? I want to avoid creating revision table for the field if possible. Otherwise, just excluding creating revisions is fine.

I tried to alter the field definition in code:

function mymodule_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
  if ($entity_type->id() === 'node' && isset($fields['field_my_fi ...
Score: 0
Best practice for user specific data related to specific nodes
in flag

I have a content type travel_locations wich contains multiple fields (such as title, body, geolocation, etcetera). Now I would like the user to reference nodes of this content type when for example he has visited this location, together with specific data about this visit (traveldate, rating, textfield for travelnotes etcetera). The specific travel data will probably be collected trough paragraphs modul ...

Score: 0
Kevin avatar
Apply Context/Conditions to a Views result item?
in flag

If you are using Context for a node, the node itself typically comes from the node page you are on. In some cases, you may want to apply the same context to views results on a node as well - but they are getting the same argument instead of the node of the result. How can you supply the result item as the context argument to conditions?

Score: -1
Sundar Raj Ponnulingam avatar
How do I set a plain text field value to be empty?
to flag
<?php
function MY_MODULE_node_update(NodeInterface $node)
{
    if ($node instanceof \Drupal\node\NodeInterface) {

        $nid = $node->id();
        $nodeType = $node->getType();
    
        $vid = \Drupal::entityTypeManager()
                ->getStorage('node')
                ->getLatestRevisionId($nid);

        $comments = $node->get('field_workflow_comment')->getValue();

   ...
Score: -4
Jimmy avatar
What is the correct procedure for creating multi-instances and websites?
sk flag

I have installed Drupal 10 and it is working with no issues. I can create my first multi-instance with a single website with no issues.

The problem I have is when I create my second website in the default instance; all of the links in the second website point back to the first website by default. I am assuming the method I am using to create Drupal 8 websites is not the same as it is now in Drupa ...

Score: 0
user110190 avatar
When "Use AJAX" is set to Yes on a View with Better Exposed Filters, the old search results are not cleared
is flag

Using Drupal 8, when AJAX is enabled on an exposed filter old search results aren't removed. I don't see any console errors but it seems that 'Use AJAX' isn't clearing the div before loading the next results. Is there a better way to go about fixing this other than attaching behaviors to Drupal AJAX?

Score: 0
Jasbir avatar
Select media popup is not opening after upgrade ckeditor from 4 to 5 Drupal
bi flag

We have drupal version 9.5.7 in our website, When we had upgrade ckeditor4 to ckeditor5 then Select media popup(for image and video) is not opening.

Console error: ajax.js?v=9.5.7:411 An error occurred during the execution of the Ajax response: TypeError: $element.dialog is not a function

enter image description here

When I click on add media button then select media popup is not opening, Please help me to fix it, thanks.

Score: 0
Tobias Krause avatar
Special sorting requirement in views for a multi-value field: how to avoid duplicated result items
cn flag

This is another attempt to solve 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

I have create a basefield (committee_role) for a custom entity (committee_membership). The entity holds data about the membership of a deputy in a committee in parliament. Politicians can have more than one role in a committee but at  ...

Score: 1
Robert Brax avatar
Image from field not properly displayed in teaser
ad flag

On Drupal 10 with Olivero theme, I set image in teaser to be displayed with original size. I also made sure the image field display is enabled in teaser view.

Still, the image is shown on the left of teaser, as minuscule round image. It seems teaser display doesn't respect what is set in admin.

How to have image displayed in teaser with specified size and location?

Score: 4
lilHar avatar
How do I use \Drupal methods in a class?
ve flag

I was out of Drupal for a few years, and PHP a couple years, due to having several years of jobs that didn't use Drupal between two that did. And I'm noticing a lot of functions that were reliable are now gone.

The particular case I am currently looking at is variable_get() occurrences replaced by \Drupal::state()->get().

However, I tried using it, and it's far from a drop-in replacement. In a class  ...

Score: 1
liquidcms avatar
Is it possible to send an argument to a title callback?
us flag

I am trying to figure out how to set page titles on various pages. I have seen a lot of posts suggesting preprocess functions. These are not correctly setting the route's page title but only setting the value for the html template.

Another solution is closer in that it suggests using an EventSubscriber triggering off the KernelEvents::REQUEST event. This is the correct approach. Some routes have  ...

Score: 4
Can services be autowired?
br flag

In drupal 8, each time we used to declare a class as a service by adding it to [module name].services.yml and then injecting it in the constructor of a different class. However, according to this answer https://stackoverflow.com/questions/44809739/is-there-a-way-to-inject-entitymanager-into-a-service , in newer symfony versions, we can inject a service without defining the class in services.yml. does it ...

Score: 1
user110161 avatar
/search-results page returns 404 if no query parameter is present
sm flag

I have inherited a Drupal site with a node that uses /search-results as path alias.

The page works fine if I use https://example.com/search-results?keys=test or https://example.com/search-results?keys, but it returns a 404 error if I use https://example.com/search-results.

Any thoughts on where to begin?

Score: 0
Peter Mengerink avatar
Commerce and Views - show all products where there are colours available as different clickable links
gy flag

I am building a commerce site. I'm trying to create a view where all my products will show with image, title and price. I sell t-shirts in say 3 different colours in 3 different sizes. In the overview page I want to show the 3 colours as separate items not as being part of the same listing. when I create a view it will come up either as all the options, so the same colour 3 times, one for each size or I ...

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 ...

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.