Questions tagged [8]

Version tags should be used for questions that apply to a version only, not to merely say what version a site is using.

Filter by
Sorted by
Tagged with
0 votes
1 answer
54 views

Can a template file write, copy, or rename files? [closed]

Can code put in a template file write, copy, rename files, or read files that aren't template files?
1 vote
0 answers
324 views

How do I solve "RouteNotFoundException: Route "jsonapi.settings" does not exist" which occurs while installing the REST UI module? [closed]

When I am trying to install or uninstall a module the below error shows up. The same error is displayed when I go to webservices (Home > Admin > Configuration > Web Services). The website ...
Reddy Rohit's user avatar
0 votes
0 answers
65 views

How do I send a notification email as soon as file is uploaded from the node add/edit form?

I have a media video content type that has a video file field (takes a file), name, and air date. The video files are saved on amazon S3 not locally. I want to monitor the files that are uploaded and ...
mamesaye's user avatar
  • 261
-1 votes
2 answers
1k views

How to pass and receive an http request body in GET?

I have two Drupal sites within one project. I want to send a GET request but I need to pass a lot of parameters. So instead of passing them in the query (which will lead to an extremely long URL), I ...
Sergey's user avatar
  • 51
0 votes
1 answer
59 views

How to use the user profile photo as the default image in a content type image field?

I would like to pull the current user profile photo in a content type image field but the default image option only allows the admin to choose an image file. Is there a module that allows the admin to ...
CocoSkin's user avatar
  • 889
0 votes
1 answer
450 views

How to get S3 file path from URI?

So inside my hook function I have URI of some file and I need to find it's S3 path (using s3fs module). How can I do that, to avoid manual string manipulation? Is there some helper function? I found ...
MilanG's user avatar
  • 499
0 votes
0 answers
284 views

Remove N/A option in radio button

I made a field in text list format with radio button widget and I want to remove the N/A option, but my field must be not required. I tried this code without success. function ...
yonea's user avatar
  • 1
0 votes
1 answer
587 views

How to theme a pager with twig?

I've added a pager to a custom page rendered programmatically from a controller. I want to customize the pager. How can I do it without overriding the standard pager twig? This is the hook_theme: ...
Jean da Silva's user avatar
0 votes
0 answers
30 views

Is there a way to nest links with the link field?

Working on a project where a sub menu uses the link field. Now they want a dropdown, but my drupal experience is extremely limited and google doesn't give me anything. I know you can with actual menus,...
Rat's user avatar
  • 1
-2 votes
1 answer
451 views

How do I get a node by its ID?

Using {{ drupal_entity('node', '123', 'body') }} in a template file, I can get the node body and title. Is there a way to get all the available node properties?
1 vote
0 answers
87 views

Create a link to a cart to be used in emails

I would like to be able to create a link to an anonymous users cart, and send this to the user in an email. When the user clicks this link, he should be taken to his cart. (As part of an "...
DisplayName's user avatar
1 vote
0 answers
198 views

Need help with Cache::invalidateTags() and cacheable metadata in REST route

I have a REST route that returns some JSON. I am trying to get cache tags working correct, but it doesn't seem to be working. Only updates if I flush all cache. I have a queue that runs on cron every ...
Ronnie's user avatar
  • 477
0 votes
1 answer
212 views

How to have some element of a custom form rendered outside <form>

I have a form based on FormBase. All the form is wrapped by form.html.twig. I want to render $form['charts'] outside the <form>. I was able to do this, but {{ children }} still render all the ...
gagarine's user avatar
  • 682
1 vote
1 answer
590 views

AjaxCommand to scroll to top of page?

I have created an AJAX form. After the form is submitted, I call $this->createOkResponse() which updates a section of the page with a message (it replaces the form with the message). It all works ...
MrUpsidown's user avatar
7 votes
3 answers
501 views

How can I run the inbuilt Drush 10.x commands as user #1?

I have a Drupal Queue worker class that fetches the Entity objects from Drupal to index to Elasticsearch. The following command is causing the lesser documents to show up in Elasticsearch since by ...
Sivaji's user avatar
  • 2,466
0 votes
1 answer
39 views

How do I update the sort field value dynamicaly?

I have a requirement to list events via view, but these events are categorized as past, ongoing and upcoming events. View results should show ongoing first, then upcoming and past events in the same ...
Suraj's user avatar
  • 884
1 vote
1 answer
415 views

How do I translate a custom string in "Global: Custom text"?

In D9 website I have a view with Global: Custom text field. In that field I have placed a string like this: <span class="general-info">{{ 'General Info:'|t }}</span> I want to ...
Vik Durve's user avatar
0 votes
0 answers
69 views

How do I upgrade without upgrading contributed modules?

I am trying to do a core upgrade, but my dry-run shows Drupal wants to install a number of modules that are already installed. I run composer update "drupal/core-*" --with-all-dependencies --...
arnoldbird's user avatar
  • 1,079
0 votes
0 answers
213 views

I cannot install a module

I have installed a Drupal 8.0.0 local test site in Windows 7 and I am trying to install Devel via Composer, running: composer require drupal/devel:^4.1. I get the following message in the command line:...
vasilis's user avatar
  • 49
0 votes
1 answer
83 views

Use translations with nl2br in template

Is it possible to use translations with nl2br? I tried {{ "This offer may \n interest you"|nl2br|t }}, but it doesn't translate the string because it contains a '\n' character. I already ...
johndoe555's user avatar
0 votes
2 answers
427 views

How to get newly created user id in user_presave hook?

Following is my .module file code /** * Implements hook_user_presave(). */ function cost_sheet_user_presave($account) { $source_userid = $account->id(); \Drupal::messenger()->...
Rifas Ali's user avatar
  • 490
3 votes
2 answers
579 views

Enable xdebug on Lando using Pantheon recipe and PHPStorm

I am trying to enable xdebug on Lando using the pantheon recipe. I have tried different tutorials, but PHPStorm does not seem to connect to Lando, or xdebug is not correctly enabled on Lando. recipe: ...
Tyler Durden's user avatar
  • 2,316
0 votes
1 answer
29 views

How can I run a certain action when a taxonomy field value is removed or added? [closed]

I have a user_territories field which can have multiple values. I need to run a certain action when this field value is changed from the user entity, not when other fields are changed. How can I write ...
Rifas Ali's user avatar
  • 490
1 vote
0 answers
265 views

Form submit handler to open new window and reload the current page

I have a form embedded in a block in a node; when submitting the form, it has to do two things: Open another new window to a custom route Reload the current page The first point works correctly, but ...
Hodba Khalaf's user avatar
0 votes
1 answer
158 views

How to add menu item active class while using url aliases?

My active class name is not working for menu items that redirect to a node using URL aliases For example, if I have a node node/10 and its alias URL is movie/avengers, I'm not able to see the active ...
Lalas Muathasim's user avatar
0 votes
0 answers
44 views

How can I debug during installation?

I tried to install Drupal 9.4.2 in a MySQL-compatible database, but I got these errors. How can I debug during installation or just print out the incompatible SQL statements?
Vincent's user avatar
0 votes
0 answers
458 views

"LogicException: The controller result claims to be providing relevant cache metadata, but leaked metadata was detected."

Hi I've created a module with a controller but now i'm getting this message; The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you ...
skycomputer2's user avatar
0 votes
0 answers
181 views

Drupal.ajax() vs JQuery/$.ajax() – what is difference?

Official manual says This scenario doesn't seems allow behaviours (to be confirmed) Does it mean that Drupal.ajax() shouldn't be called inside Drupal.behaviors.my_func and/or inside JQuery's $.ajax? ...
Dunot's user avatar
  • 101
0 votes
1 answer
50 views

Sort nodes based on parent taxonomy term name in views

I have a taxonomy term "Store Locations". I have added terms as State & City by parent child concept. Like this: I have created Store Locations as node and assign them in the taxonomy ...
Souvik Das's user avatar
0 votes
0 answers
92 views

Manipulate the DOM with jQuery just before the page loads

Because of accesibility tests i need to manipulate the html of my page just before it loads completely. I dont want to manipulate contrib modules i am using, so i need to do it with jQuery. In fact, i ...
leandro713's user avatar
0 votes
2 answers
832 views

Add target="_blank" in menu items (main navigation)

I use Drupal 8.9.3 with custom theme. I need to do a menu item on the main navigation who go on an external link. I would like to add target="_blank" on this link, but I don't see where I ...
Gab's's user avatar
  • 1
0 votes
1 answer
430 views

How do I add a variable for menu.html.twig?

I want a variable in menu.html.twig file. I tried adding the following hook in the theme's .theme file, but the template file doesn't print anything. function my_theme_name_preprocess_menu(&$...
Kunal Raut's user avatar
0 votes
0 answers
165 views

How to make entity query condition field case insensitive to compared value

I am writing an entity query as below $entity_query = \Drupal::entityQuery('node'); $entities = $entity_query->condition('my_field', 'some data', 'LIKE') ->condition('another_field', ...
Sharique's user avatar
-1 votes
1 answer
156 views

REST cookie authentication, Post 403

I am logged in to my Drupal account and if I use the jQuery code from here then I can make a post request to my site and create a node. But if I try from another site, like my local host or a third ...
Tasha Jordan's user avatar
0 votes
1 answer
58 views

Anonymous users can edit all anonymous users content

Drupal has a edit own content permission for each content type. I have given the Article: edit own content to anonymous users and discovered that Drupal doesn't differentiate between different ...
Tasha Jordan's user avatar
1 vote
0 answers
47 views

Multiple value field create duplicate results when using leftJoin

I have a query to the database for a specific content type. Everything is working as expected but when I add a leftJoin query on the field 'node__field_country' which is a taxonomy term reference ...
Black coffee's user avatar
0 votes
1 answer
66 views

cant get file uri using field preprocess

Im trying to use function theme_preprocess_field to get the file path of a file field. I have tried different variations of below. function mytheme_preprocess_field(&$variables) { if ($...
Jay Williams's user avatar
0 votes
1 answer
851 views

Image styles - How to resize uploaded images and force an aspect ratio

I'm looking for a solution to resize uploaded images while maintaining a desired aspect ratio instead of cropping them. We can configure some preset Image styles, but it seems we can only : Resize : ...
Decoy_Octopus_'s user avatar
1 vote
0 answers
13 views

RESTful web services custom reponse when creating nodes?

I have enabled RESTful Web Services and REST UI. I have followed the guide in this answer and am able to create nodes using the REST api. https://drupal.stackexchange.com/a/256429/105808 However, when ...
Jay Williams's user avatar
2 votes
1 answer
997 views

Get all parent term taxonomy id and name of vocabulary

I have a vocabulary (Vehicle) which contains the following taxonomy terms. Maruti Alto Swift Baleno Barazza Hundai I10 I20 Creta Tata Nexon Safari Nano I want to get only the parent taxonomy ...
abc's user avatar
  • 29
0 votes
1 answer
198 views

How to generate templates suggestion for media.html.twig for a specific field in a content type?

I have a content type (say Article) with an entity reference field to another content type (Author). I have used layout builder together with a view mode to display the content of the Author field in ...
Binny's user avatar
  • 886
0 votes
0 answers
87 views

Adjust total price in commerce checkout

I have a store setup with 2 products. Public and private tours. Public tours are 10 for each unit. Private tours on the other hand are only meant to collect a deposit. I need the total to be $50 no ...
Ronnie's user avatar
  • 477
1 vote
1 answer
984 views

Link in URL field to Media File

Before the Update to the latest DruPal 8, we were able to link to public://foo/bar.pdf to a file which was in /sites/default/files/. No the public:// prefix does not work anymore in the URL input ...
Alex's user avatar
  • 87
-2 votes
2 answers
570 views

How can we use \Drupal class inside Settings.php

How can we use \Drupal class inside the settings.php file to load configuration ojects, for example? $slogan = \Drupal::config('system.site')->get('slogan');
Prashant Chauhan's user avatar
1 vote
1 answer
163 views

How to update taxonomy field with array of terms?

I am having a body like this { "userid": 435, "territories_id":[176,139] } Where userid is the drupal user id. And I need to update field field_user_territory which is a ...
Rifas Ali's user avatar
  • 490
0 votes
0 answers
144 views

How to get PHP code into a Views Filter

I have a text field which is extracted from photo's EXIF value; its value is similar to 2021-05-31T15:15:05. I want to create a view, use the filter and get the field added in. However, I can't use ...
Kingto Wong's user avatar
0 votes
2 answers
319 views

How do I print an exposed filter block in a template file?

I have a view with an exposed taxonomy filter. I configured it to be displayed as a separate block so that I can print it another twig template. I tried this. /** * Implements hook_preprocess_block() ...
Binny's user avatar
  • 886
2 votes
1 answer
89 views

Can I know what I'm looking at from the URL?

I think on Drupal 7 I had previously used something like menu_get_object() to find out what content I was on. For example, with mysite.com/content/my-page, it would tell me that this was a node, its ...
Andrew Morris's user avatar
-2 votes
1 answer
27 views

When editing a node, tab group titles are missing [closed]

When editing a node, tab group titles are missing: The HTML looks like this: <ul class="horizontal-tabs-list"> <li class="horizontal-tab-button horizontal-tab-button-0 ...
Alex's user avatar
  • 87
1 vote
0 answers
110 views

Sending data to custom block [closed]

I created a module that has several pages of administration. One of these pages is a block creation page. When the block is created the name of the block is kept in the database. The block build() ...
cjobes's user avatar
  • 11