Questions tagged [theming]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
25 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
64 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
106 views

Use a Twig filter to resize / crop images in templates [closed]

I want to use a twig filter to resize/crop images in Drupal 8 templates for responsive images, I know I can generate responsive images with Image Style and Responsive Image styles, but that requires ...
0
votes
1answer
55 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
20 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
25 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
68 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
28 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. ...
1
vote
1answer
38 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 ...
0
votes
1answer
34 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
0answers
18 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
30 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
86 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
18 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
39 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
56 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
20 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
15 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
59 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
30 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
24 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
78 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://...
2
votes
1answer
48 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
49 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
32 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
24 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?
0
votes
1answer
58 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
57 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
106 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
24 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
26 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
34 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
22 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
54 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 ...
0
votes
0answers
50 views

Twig and CSS for custom Block not working

I'm working on a custom module that has a block. This block has a form in configuration where user input the relative data, so far it works its saving the data and it display it but without a template ...
0
votes
0answers
23 views

Get the list of child pages for a book given the book node id

In a theme preprocess hook, I have the node id for a book. How do I get the list of child pages for the book? I checked the Book module API but see didn't a way to do it.
0
votes
1answer
25 views

<h1>Classification: {{ content.field_classification.value }}</h1> not displaying

Hoping someone can assist me please. I am trying to display the value of a custom field in a bootstrap sub theme I have created my node--testtype.html.twig template and that seems to work. I'm ...
2
votes
2answers
28 views

Does $element['#title'] need to be escaped with check_plain()?

I see (with grep) that the value of $element['#title'] in a render element is sometimes sanitized with check_plain(), and sometimes printed unfiltered. Which one is correct? Is the value considered ...
0
votes
1answer
34 views

Output data of different content types in same page

I have two content types : Content type 1 named book with two fields author and language Content type 2 named movie with two fields date and resolution In my-theme/templates/page.html.twig I want to ...
0
votes
0answers
11 views

How do I change the width of a mega slider?

I am using Drupal 7.x. I am using the popular theme is porto. https://i.stack.imgur.com/Kmhok.png Porto comes with a Mega Slider component. And that is what I am using here. I am using the Mega ...
0
votes
1answer
38 views

Print image URL with image style

I would like to print an image URL with an image-style. This doesn't work, since I don't have a ".value"-value for the image: How to find image style URL from within twig template? Is there anything ...
0
votes
0answers
22 views

How to include book traversal links on a custom twig template page

I use the Book module to create books with chapters. When I use the default twig template node.html.twig to display a book chapter, a section titled "Book traversal links" is included, with links to ...
0
votes
2answers
46 views

Change html tag in template file tpl

I have this template file for a view: views-view--ir-news--page.tpl.php But right now, I need to use Google AMP only for this view (Machine name: ir_news) What I want to know is if something like ...
1
vote
1answer
29 views

Why is Twig not outputting this correctly?

I have function hook_theme_preprocess(array &$variables, $hook) { $variables['bla'] = ' AA <strong> BB </strong> CC '; } In my template I have: {{ bla }} The problem is, in ...
1
vote
1answer
118 views

Get all nodes of a specific content type and print the data of each node inside page.html.twig

I have a content type (Flower) with two fields: Name and Color. In my-theme/templates/page.html.twig, I want to print the name and the color of each flower. <div id="page"> {% for flower ...
1
vote
1answer
37 views

How to pass contextual id value from one view page to another through Drupal menuing system

I use a view to display a list of books. The view has three pages: /books/title, /books/date, and /books/popularity. The pages are essentially the same with different sort criteria. The pages use a ...
0
votes
0answers
79 views

Pass variable from custom module to twig template

How can I pass a variable from my custom module to a twig field template? my field template is the "field--node--field-webform--parliament-visit.html.twig" and my module is named as "custommodule" ...