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
1answer
362 views

Change a paragraph link field title at runtime

We have a site with numerous paragraphs, one of which is a Call-to-action, comprised of a title, summary and a link field (machine name: field_link). The CTA is used so much that to change the word '...
0
votes
1answer
23 views

How can I disable the cache for a specific page or have the cache ignore query params?

I need to disable the cache for a specific page, or get the cache to ignore query params. I have tried this, but it does not disable the cache for me https://www.drupal.org/project/...
0
votes
0answers
4 views

Paragraph's fields value loaded in a custom controller are in the default language instead of the current language

I made a custom controller that load a paragraph field from a node and then render some part in a template. The paragraph field field_title and field_description are translatable. The translation ...
0
votes
1answer
466 views

How to override custom block methods in drupal 8

i have created a block with all its methods like blockAccess()... i would like to override one of those in other module, in my project i have used page manager, then i cant call hook_block_access().....
0
votes
0answers
14 views

How to set URL for image with view method properly?

Image formatter should accept image_style and url parameters. I've got image_style working but not url. function mymodule_preprocess_views_view_field(&$variables) { // ... $variables['image'] =...
4
votes
1answer
950 views

When I POST an image file via rest, response is 201: Object Moved, status is temporary

I'm attempting to POST images to Drupal 8 via the REST api. The creation is successful (201) and the images appear in the files list. However, there are problems. I'm not sure if they are ...
0
votes
1answer
356 views

How can you add a template for a custom confirmation page URL?

I want to show custom message on confirmation page (on custom URL). I created a custom URL in *.routing.yml file and added a method in controller class that returns an array : return [ '#theme' =&...
-1
votes
1answer
827 views

Edit existing 'if' condition to add a class to a div and display / hide divs

I am using a template which has an 'if' argument to alter the output of a div containing an image field. I need to add my own condition (within comments) to it. Currently the output is creating the ...
16
votes
8answers
10k views

How can I make kint() load faster when debugging twig templates?

I've seen quite a bit of discussion about how kint() from the Devel module is difficult to work with because it maxes out PHP memory limits and makes the browser drag. I've heard some thoughts on ...
0
votes
1answer
2k views

How to render the 'actions' section of a form in twig template?

given a form that is built like the following: public function buildForm(array $form, FormStateInterface $form_state) { $form['#theme'] = 'mymodule_testForm'; $form['actions']['#type'] = '...
0
votes
1answer
12 views

Custom PHP Unit test trait for a custom module cannot be found

I have created a new Trait for testing my custom module and placed it in my_module/tests/src/Traits with the namespace Drupal\Test\my_module\Traits, the same as core modules do. When I try to use this ...
0
votes
0answers
25 views

Custom Action not available in Views

I am attempting to add a custom User action so that it will be available as a Bulk Update in the user_admin_people view. In /web/modules/custom/my_module/src/Plugin/Action directory I have this file ...
0
votes
1answer
28 views

Access denied when trying to import single configuration item

I am using Drupal 8.9.2 and trying to import a view using the Configuration Management UI in the admin. I did this with no issue importing the view from my local dev environment to our dev server, but ...
0
votes
0answers
34 views

Hook on drush cache:rebuild

Is it possible to hook on drush cache:rebuild before the command is executed? I've seen some hooks for afterwards, but I am trying to compile my less files into css before cache the is rebuild. I'd be ...
0
votes
0answers
37 views

D7 to D8 migration running incredibly slow

We are upgrading our D7 instance to D8 and when I migrated my local instance over it took a couple of hours, but that was no surprise. User migrations were processing about 50 users at a time via the ...
1
vote
1answer
1k views

How to add twig code in View 'global custom text' field?

I want to add if condition in my "global custom text" field saying if node is published, print some link. I tried below steps , but it is not working: 1.I have added "Content: Publishing status" field ...
3
votes
1answer
351 views

Is there a way to add node grants to anonymous users?

I want anonymous users to be able to access nodes that are promoted to the front page. (They can't access to nodes that are not promoted.) It seems hook_node_access() isn't seem called for anonymous ...
1
vote
1answer
660 views

Content edit links?

I'm new to Drupal 8 and can't figure out a way to show the edit contextual links for content displayed through the Views module. This was simple in Drupal 7, but in Drupal 8, a view only shows the ...
-2
votes
1answer
40 views

Clear render cache with Rules [closed]

In Drupal 8, i want, every time I publish a node, to clear render cache. I am trying to do it with Rules, but I didn't find the action to do it.
0
votes
1answer
619 views

Language variable doesn't work in Twig?

I have to put a several languages in a site. But I just discovered that the taxonomy terms without a language (because it's the same label for every language) gives the link toward a page in the ...
1
vote
0answers
32 views

Order minimum quantities

I need to set order minimum quantities in my Commerce 2 website. The website has two stores: retail and wholesale. Customers who are shopping in my "retail consumers" store must have at ...
0
votes
1answer
24 views

Add custom access check to user page

I would like to add an additional access condition to viewing user pages like user/1. I looked at the following guidelines, but have not succeeded in coming up with a solution. https://www.drupal.org/...
0
votes
1answer
606 views

How to disable core JS aggregation and AdvAgg just for admin paths

I help look after a site which uses $settings['file_public_base_url'] to serve files from a different subdomain on the frontend, but on the backend (admin paths like node/add and node/edit) this ...
0
votes
3answers
1k views

How to get term by path or alias?

I've seen this question posted many places, but no answers - or relevant answer. i.e. how to get term object or ID from path or alias e.g. /cat/subcat or /taxonomy/term/6??
-1
votes
0answers
21 views

Share private content via e-mail

I'd like to use my Drupal 8 website to share some big files to some authorized people (20-30) on a monthly basis. These people change every time, so I wouldn't register them as regular users with a ...
1
vote
1answer
591 views

Creating Parent-Child Entities

Is there a way to create parent-child entities in Drupal 8? I'm trying to create a structure where the top entity is for County, and the next level entity is for departments, and next level would be ...
0
votes
1answer
27 views

How to get the entity ID in a twig template

I have a custom entity, with the template my-custom-entity--my-entity.html.twig. How do I access the ID in the template? I can do this by implementing hook_preprocess_entity, but am wondering if the ...
2
votes
1answer
37 views
+50

How to send system mails in html format (with Swift Mailer)?

At Account settings page (/admin/config/people/accounts) I can edit system mails Drupal is sending (Welcome, Account activated, Account blocked and so on). I also installed and configured Swift Mailer ...
2
votes
1answer
404 views

How to display entity label using entity reference field checkbox form display

I am working with Drupal 8. And I want to create a field of entity_reference type. The field has a reference to context_question entity. And the field is displayed fine, but without any description ...
0
votes
0answers
29 views

For performance, one multi-value field or four individual fields?

I have a node content type that needs to store four different int values: Score A Score B Score C Score D Each node of the content type always has all four int values. I could store this one of two ...
1
vote
1answer
533 views

Advanced Migration - update nodes

I'm a little bit new in Drupal but experienced in PHP. I would like to migrate data from CSV and assign to existing nodes in DB. My question is about the possibility to match processing rows with ...
4
votes
1answer
56 views

Load nodes by property, including empty ones

I want to render a node with certain properties set. For example, I want to load every node which ONLY has field_a and the other fields are empty. If I use $this->nodeStorage->loadByProperties(['...
7
votes
2answers
5k views

How do you add a PDF attachment to an email?

Goal: I need to send an email with a pdf attachment in Drupal 8. Progress I am able to send an email with subject and message but have never been able to get the attachment. When I turn on the logic ...
3
votes
0answers
21 views

How can I correctly attach a file to a mail? [duplicate]

I am very new to drupal and need to upload a file and sent it as attachment in Drupal 8. I have created the form element like $form['candidate_attachment'] = [ '#type' => 'managed_file', '#...
0
votes
1answer
472 views

How to use 'use-ajax' class with pages created by controller?

I'm trying to use 'use-ajax' class to load a page inside a modal box. My Page is dynamically created using node id pass on my page controller My link looks like this Any idea on how can I achieve ...
7
votes
1answer
2k views

How can I add a CSS class to the body tag based on the current path alias?

Is it possible in Drupal 8, to add a CSS class to the <body> tag based on the current path alias?
3
votes
0answers
912 views

Why are the thumbnail images not loading?

I am using Drupal 8, and have just moved my site to shared hosting. When I upload a standard image field on my shared hosting environment, the thumbnail image does not show up. This works perfectly on ...
0
votes
0answers
25 views

The SQL storage cannot change the schema for an existing field (id in sms_phone_number_verification entity) with data

I am using the SMS Framework module and after updating my site from Drupal core 8.8.8 to Drupal Core 8.9.3 and the SMS Framework module from 8.x-1.3 to 8.x-2.0.0-alpha1, I start seeing the below error ...
-1
votes
0answers
31 views

Getting values from checkbox in foreach loop form [closed]

Im building a custom module, this module is getting data from values in db, i have created the form using this way: $data = []; foreach ($nodes as $node) { $getData = \Drupal\node\Entity\...
1
vote
0answers
21 views

Use Order Number in Receipt

I want to use the Order number rather than the order id. I'm using Commerce POS and it uses $commerce_order->id()to generate the id used in the receipt generated and receipt email sent. But in ...
1
vote
3answers
2k views

How do i change date format in View Exposed Date filter?

How do I change date format in View Exposed Date filter? By default it's in d/m/Y format, I want to make it Y.m.d format, without changing the query parameter date format (Y-m-d). Any suggestion, how ...
0
votes
2answers
1k views

Redirect user to previous page after registration

I'd like users registering on my website are redirected to the page where they clicked the "create account" button which is in a modal. First, I tried to redirect to an absolute url I tried $...
2
votes
1answer
597 views

cannot use some drush commands

I am running into some trouble with drush I can't pm-enable the modules I just downloaded with it. I did some research but none of the solution worked for me, most cases involved switching "localhost" ...
0
votes
0answers
28 views

Replace the default modal with a different one

I want to replace Drupal 8 default modal with MDB. How I can do it? Should I unload default library for modals and load new one? Any idea?
1
vote
0answers
24 views

Views_pre_render How do I get a file's path url if I only have the file name?

I have a dynamically created Views listing page where I display fields from "Collection Items" node type in this order: Item Title Item Status Date Stamp Document (uploaded file. I'm only ...
1
vote
1answer
63 views

How can I use Migrate API to migrate taxonomy with an unknown level of parent child relationships in tact?

I have a JSON file with an entry that looks like this: "taxonomy": "abc/historical_controls/abc2000_2013" In my YML file I have it mapped like this: field_abc_asset_taxonomy_auto: - ...
0
votes
2answers
679 views

How do I allow full HTML while rendering a view?

Some HTML code like <iframe> is stripped out. How can I allow full HTML in a view? $options = array( 'id' => 'area_text_custom', 'table' => 'views', 'field' =&...
1
vote
1answer
40 views

Using container element in form widget

I want to build a widget for a own field type. In the function formElement() of my widget I want the elements wrapped in a div. For this purpose exists the container element. So I build my form: ...
0
votes
0answers
19 views

TypeError due to dependency injection of test class [closed]

I'm attempting to test some of the functionality on my site related to scheduling. To do so, I added the Datetime Testing module. However, when I enabled the module, my site starting getting a WSOD ...
1
vote
2answers
498 views

Adding block in view tabs

I have tabs created using views and has contextual filter of group parent(Group ID from URL). I created a block that has a contextual filter of GID. In the block layout, I placed the block in the ...

1
2 3 4 5
296