Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [theming]

Use it for questions about rendering or modifying the HTML markup produced by a module/theme.

0
votes
1answer
28 views

How can I add folders to my template directory and have Twig find them?

I was listening to a Drupal Developer on youtube and one of the suggestions he has, is that when you go into a template folder, create some subdirectories for easier management, like this: Templates -...
0
votes
1answer
23 views

How to print the URL path of a referenced node using paragraphs?

I'm trying to print out the url path of a node from a referenced entity paragraph field in my twig template however have not had any success so far. I have tried various common twig functions but with ...
0
votes
0answers
10 views

How to show contextual links / quick edit links for blocks

I'm building a Drupal 8 template/theme from scratch, and it is not showing the contextual editing options for my blocks when I view a site page. I.E., the little circles that are clicked to see ...
0
votes
0answers
16 views

Adding a script to certain pages

I am trying to add a script code on all but few pages. I tried the following code on the template.php bfile, but it doesn't work. function THEME_preprocess_page(&$variables) { if (isset($...
0
votes
1answer
53 views

Is there a better way to style fields?

I'm learning twig and using it to format and style my fields. The problem I am running into is that I need to create a new twig template for each individual field. In the example picture, I have ...
0
votes
1answer
26 views

How to print the URL of a title field?

I'm trying to print out the url path from the title in my twig template however I haven't been successful so far. Printing out the title containing the link works fine using: {{content.title}} ...
0
votes
1answer
35 views

How to create unique banner for each node and views page?

What I am trying to achieve: I want the unique banner image for each node and the views page, where the site administrator can simply upload the image and description to upload the banner for each ...
1
vote
1answer
18 views

Is the homepage considered in_active_trail?

I'm learning Drupal 8, so still very new to it. I'm working on customizing the main menu. I've been able to add Twitter Bootstrap to my custom theme. I've made a custom menu--main.html.twig file. I'...
0
votes
0answers
31 views

Kint function not working for me at twig template

I have enabled devel module and also enabled devel kint . From configuration section (development/devel) , I select kint as Variables Dumper. I also enable twig debug mode. But {{ kint() }} not ...
-3
votes
1answer
55 views

Use a Twig filter to resize / crop images in templates

I want to use a twig filter to resize/crop images in templates for responsive images, I know I can generate responsive images with Image Style and Responsive Image styles, but that requires too much ...
0
votes
1answer
44 views

When I going to Disable Twig template cache , Fatal error

When I going to Disable Twig template cache , Fatal error . i.e The website encountered an unexpected error. Please try again later. Error: Unsupported operand types in Drupal\Core\Template\...
0
votes
0answers
18 views

get fields from a view into twig from a custom display style

So I created a custom display style following a tutorial and enabled fields to be used. I can't, however, figure out what the variables on the twig file should be to display the fields I want. MY ...
0
votes
1answer
24 views

Extending a base template file such as field.html.twig renders no results?

So I have a custom content entity that has the typical attributes. Name, Author, Creation Date, ect. In the 'view' tab of this content entity, it displays said name, author, ect. When I hover over ...
2
votes
0answers
59 views

How can I use Html::getUniqueID in Twig

The Drupal Twig |clean_id filter calls HTML::getId, which is inferior because accessibility tests fail if your ID appears twice, for example, when the template is placed twice on a page. In the vast ...
0
votes
0answers
25 views

Why is my custom twig template not being selected by Drupal?

So I have a custom module that has boilerplate template code inside it. No problem there. So I following the Drupal Docs which says to create a service.yml file and turn debug on and caches off. Done. ...
0
votes
0answers
15 views

Hide Parent Terms in Taxonomy Term View Block in Twig

Trying to hide the top two terms (or first two levels) in my org listing via twig. The listing itself is a view block using the term reference tree formatter.
0
votes
0answers
29 views

Is the field template documentation wrong?

The core themes Stack and Bootstrap have this documentation in the field.twig.html template: * Instead of overriding the theming for all fields, you can also just override * theming for a subset of ...
-1
votes
0answers
12 views

Drupal 8 Domain Access module implementation [closed]

I am trying to install domain access (8.x-1.0-alpha15) module on latest Drupal 8.7.1 But while installing the domain module I got the an error "The website encountered an unexpected error. Please try ...
1
vote
1answer
34 views

Wrong User Image Display - Weird Twig Cache?

I'm having a weird issue with incorrect user images being displayed and it seems to be a caching issue or perhaps I am passing the user image incorrectly to my template. Problem: If I login to a ...
-3
votes
0answers
17 views

How can I print node node_stats (statistics)? [closed]

How do I use Twig to print the node_stats statistics value, for example 29? I want in node.html.twig pring statistics(modules) value. use {{node_stats}} print value is '29 views'.but I just want ...
0
votes
1answer
20 views

Add target blank to an image link

How do I add target='blank' to a href in a Drupal 8 custom module? Below I have the image being wrapped by the uri. I don't know how to add target='blank' $element[$delta] = array( '#theme' ...
0
votes
1answer
19 views

How to get values from a different function? [closed]

I have the following function in Drupal (Controller) that calls an API via AJAX. It is already returning values from the API but I want to take these values and use them on a private function that's ...
0
votes
0answers
17 views

trying to insert a view inside a view using twig tweak module

I am trying to insert a view inside a view but struggling a bit I have a view called My Class with all my fields in it, this works fine. I have a view with a contextual filter called Students Block,...
0
votes
0answers
22 views

Get input label on input.html.twig file

I'm working on an input.html.twig file. I need the label name of the input for class and other reasons, but for some reason, I can't figure out how to grab it. I thought it would be part of the twig ...
1
vote
1answer
79 views

Passing data from outer preprocess to inner template

I have two templates: - a child that is printing each item in a list; - and a parent that calls it there is also an intermediate Field template that is not involved. The parent has preprocess access ...
0
votes
0answers
37 views

How to get translated term name from TID in views field template?

For a complex view, I need to alter the output of a localized term field: instead of putting out the TID of the term, I would like to render the localized term name. Does someone know how to alter the ...
0
votes
1answer
16 views

Only display profile edit button on personal profile page

I'm using the profile module and am trying to display a profile edit button on your personal profile page. my profile.html.twig: <div class="m-section__content a-container"> {% if ...
0
votes
0answers
32 views

Content type fields list on the page.html.twig template

I have an HTML theme that I am converting to a theme in Drupal 8.7.0. I have created content type Hero content. Then I created fields inside: title body image (there are multiple images) offer(text) ...
0
votes
0answers
9 views

Drupal link value is showing the entity [duplicate]

The link field shows uri:"internal:"... and uri:"entity:" as a prefix in the field link URI. how can i fix that ? Thats how i get my fields uri value. {{ paragraph.field_stage_element_hp_link.uri....
0
votes
0answers
40 views

Loop Paragraph types with all values in field--field-page-detail-paragraph.html.twig

I have two paragraph types called First Type & Second Type and added Image & Text fields on it separately. I have created the basic page & added the two above paragraphs(First Type & ...
0
votes
0answers
13 views

Using Layout Builder With Menu Items

I recently just updated to 8.7 and for the most part everything is working well. In my dev environment I was working on a new feature using layout builder with menu_item_extras to apply a layout to ...
0
votes
1answer
14 views

Search info_split is empty

I need to customize the search results of a drupal 8 (8.7.0 currently) page a bit and need the node_type for this. According to search-result.html.twig, this should be stored in info_split.type, but ...
0
votes
1answer
27 views

Adding a custom data-attribute to a field in Views

In a view I need to add a custom data-attribute to the row output (just like classes are added). Simply rewriting the output doesn't work because XSS attribute filtering strips the attribute. How can ...
0
votes
0answers
27 views

Exporting content translation to similar server

I have 2 instances of the same site built using Drupal. Both need to be translated, and most of the work of the translation has been done on site A and we need to take the translations from site A to ...
0
votes
0answers
33 views

How does a custom module architecture work?

I am a beginner with D8 and I need to create a module with a custom form. I created the module and created the form. I also created a custom block in order to render the form (the plugin block and the ...
0
votes
1answer
20 views

Media images link to their own image

I have inherited a site which had no image management. Instead each image field required you to upload an image instead of reuse an existing one. I enabled Media Browser and updated to 8.7. I am also ...
0
votes
1answer
67 views

Rewriting image output in views: how to provide replacement pattern inside twig tag?

In views I want to rewrite output of image field by using twig function drupal_image (see module Twig Tweak). When I provide the image path directly, this code works: {{ drupal_image('public://...
1
vote
1answer
22 views

Adding a line break or space in TWIG

I'm trying to configure email confirmations that are sent out by one of our web forms. At the moment they are appearing without line breaks but I want to be able to have line breaks between certain ...
2
votes
1answer
42 views

Twig whitespace controls have no effect on fields

I am trying to iterate over a Paragraph field and apply a comma after each Paragraph item. In the field template that outputs the Paragraph, I am trying: {%- for item in items %} {{ item.content }}...
1
vote
0answers
23 views

Why do I get “Warning: Division by zero in __TwigTemplate”? [closed]

I created the connectedFilters.js file in /themes/custom/module/js/ with the following code. (function ($, Drupal) { Drupal.behaviors.connectedFiltersBehavior = { attach: function (...
0
votes
0answers
21 views

How do I get the default comment form in the content type template?

I have created the comment field in the content type. How can I render the comment form using a specific content type template in Drupal 8?
-2
votes
0answers
14 views

How do I render the Youtube field in page.html.twig? [duplicate]

I created a content type field using the YouTube Field module. How do I render that field, link or value, in page.html.twig?
0
votes
1answer
29 views

Removing specific HTTP response header

I am trying to remove specific HTTP response header from my site. The header looks like this: Link: <https://example.com>; rel="canonical",<https://example.com>; rel="shortlink" So far ...
1
vote
1answer
35 views

Understanding page-title.html.twig and/vs field--node--title.html.twig

This question is based on the desire to have only one wrapping tag around the title value. (I am utilizing the block system to render the page/node title) Both of the templates utilize some sort of ...
0
votes
1answer
27 views

How to display a link field with its link text in a twig template

A content type includes a link field link that accepts Link text. A user inputs the URL /target with the Link text "Go to target". How do I get twig to generate `<a href="/target">Go to ...
0
votes
1answer
16 views

How to retrieve the link and description in a custom file field twig template

I have a field field_file. I've created a template field--field_file.html.twig. How can I access the link, description (and attributes and icon ) separately in this file? I have: {% for item in ...
0
votes
1answer
24 views

Putting footer region under body tag

I'm fairly new to drupal and this is my first time posting on stackexchange. Constructive critisism and feedback are more than welcome. All regions in my custom theme are placed inside the body tag ...
0
votes
1answer
25 views

Twig: Generate classname from variable in views template

In the twig template file of a view with grouped rows I would like to add the title of the group as a classname. But the rendered classname from title variable is just "_" on every group. This is the ...
0
votes
0answers
21 views

add custom class for each field of a form

I am trying to create a custom class for the fields based on the title display dropdown for each field, and I have it most of the way working. I was wondering if anyone might have any ideas on this. ...
0
votes
1answer
46 views

Drupal 8: Node “options” does not exist for Node “Drupal\Core\Template\TwigNodeTrans” error after update

after updating Drupal 8 from 8.6.14 to 8.6.15 (twig v1.40.1) I suddenly get this kind of fatal errors: Uncaught PHP Exception Twig\Error\SyntaxError: "An exception has been thrown during the ...