Questions tagged [theming]
Use it for questions about rendering or modifying the HTML markup produced by a module/theme.
10,753
questions
0
votes
1
answer
428
views
Private file not being displayed on Twig template
I am trying to get an image from the private folder to display on a printer-friendly Twig template page. The private folder is inaccessible to browsers and the only display method I know of is to load ...
0
votes
2
answers
207
views
Pass current langage to twig on custom blocks
my custom module block, with supposely no cache
<?php
namespace Drupal\amu_social_icon\Plugin\Block;
use Drupal\Core\Block\BlockBase;
/**
* Provides a 'Icon' Block
*
* @Block(
* id = "...
1
vote
1
answer
125
views
Somehow subscribe/react to addMessage
I'm trying to find an event that I can subscribe to for the method addMessage.
I need to trigger some code everytime a status message is added. On reacting to this event, I need to send a variable ...
-1
votes
1
answer
198
views
undefined drupal_add_js function inside themename_preprocess_page
I wanted to use javascript to delete an option from the list of options in case the user is not an administrator and I searched and found this code inside a post and I used it inside the project's ...
-1
votes
1
answer
404
views
How can I make Barrio SASS gulpfile coninue watching for changes
When running gulp. It runs and compiles SASS one time. How can I adjust the watch so that it continues watching for changes. Do I need to add usePolling: true or usegulp.series. I am following the ...
0
votes
1
answer
24
views
Drupal 7 taxonomy term fields not handling content filters
Image Resize Filter doesn't work with taxonomy term description.
Resizing works fine in nodes and blocks, but not in views for taxonomy term.
I'm loading term in my view template. And render its ...
0
votes
1
answer
113
views
How can I set a custom document title in theme-settings.php?
I need to set the content of the <title> tag without using a module, for example changing the content of the theme-settings.php file.
I am trying to add the following hook implementation.
...
0
votes
0
answers
21
views
Old GZ file is generated after editing CSS original
After editing CSS file in the /sites/default/files/css directory I removed its GZ version and it's generated after a while, but with old CSS code.
How to edit CSS correctly? And how to force ...
-1
votes
1
answer
2k
views
Get the value of a field to do an if statement Twig
I am trying to generate a PDF with Entity Print. Until then all is well.
In my Twig page, I try to make conditional displays. But I can’t get the conditions to work.
I render my fields using {{ ...
1
vote
0
answers
146
views
How can I customize breakpoints in USWDS base theme?
I'm using the USWDS_base theme as a base for my custom theme. Version 8.x-2.10
In this file: web/themes/custom/my_child_theme/sass/_uswds-theme-utilities.scss I find the tokens used for the ...
0
votes
0
answers
410
views
How to add index to paragraph template
I want to use paragraphs to implement a carousel, and for now, I have the outer paragraph called slideshow, and the template is paragraph--slideshow.html.twig.
Then, inside this paragraph, I can add ...
0
votes
0
answers
443
views
How to remove home in a breadcrumb from a specific page in easy breadcrumbs and add carets for the breadcrumbs?
I've been using the easy breadcrumb module in Drupal 8, I enabled the option - "Include the front page as a segment in the breadcrumb" for all pages, but there are few pages for instance /...
0
votes
0
answers
189
views
Twig sets body class even when region is not rendered in DOM
In the html.html.twig file of my theme if added the following code to body_classes to add a body class if a region is not empty:
page.hero ? 'w-hero-bg',
So it looks like this:
{%
set body_classes ...
-1
votes
1
answer
130
views
How to add anchor to a single block displayed on specific pages within the same page?
I have a basic layout for a Drupal 8 site, created two blocks with block 1 containing menu with static content and links to pages, and block 2 for subscription form, The block 1 and block 2 are called ...
0
votes
0
answers
28
views
How do I create and call a custom named function? [duplicate]
Brand new to Drupal and I need to figure out how to create a custom function and call the custom function in the twig file.
I need to build a news releases function that reads a directory and pulls ...
0
votes
1
answer
358
views
How can I add classes to rows depending on the loop index?
I have received a design where they want to have the latest three articles links put on the top of the front page (over their respective images) so that the first is taking left half of the page and ...
1
vote
1
answer
194
views
Why is my template suggestion not called (the return)?
I have seen many questions like this ones and I have tried all the solutions...
Here is my setup:
1-I have a custom entity with the id defined as follow:
* @ContentEntityType(
* id = "...
0
votes
1
answer
36
views
Escaping CSS digits, 0 is removed from CSS aggregated files
The following HTML markup won't work on a production site.
<div class="iconleft 109">TEXT</div>
This is the code in the custom.css file.
.iconleft.\31 09,
.iconleft.\31 12,
....
1
vote
2
answers
312
views
How do I add a <div> over a paragraph's field, depending on another field of this paragraph?
I have a paragraph (from the paragraphs module) which has two fields :
field_title (text)
field_title_level (list text)
The field_title_level can have either h2, h3, or h4 as a value.
What I would ...
-1
votes
1
answer
90
views
Breadcrumbs not appearing
I have a custom theme extending the bootstrap theme. In my theme there are no extra files except the .info.yml file. Everything else is inherited from bootstrap. I have also kept the regions in my ...
0
votes
1
answer
1k
views
Is it possible to pass classes to twig include template
Drupal 9 bootstrap barrio sub-theme.
I would like to use a generic template to build some "card" bootstrap display. This template is called by multiple other templates like this :
{% include ...
1
vote
1
answer
498
views
Commerce Invoice Entity Print Styling
I am using Commerce Invoice and Entity Print to generate .pdf-files of invoices. In Entity Print settings, I set the paper size to A4 and selected TCPDF as printing engine.
Then, I customized commerce-...
1
vote
3
answers
5k
views
How do I compare a date field with the current time in a twig template?
I have a date field on a node – set to a custom date format (c which is ISO) in the Manage Display.
I have a twig template checking to see if that date field comes before today, in which is should ...
0
votes
1
answer
419
views
How can I print the translated entity title in a template?
I have a reference field for nodes and I have a field template to render the the fields.
{{ item.entity.title.value }}
But I can't get the translated title of the node.
Can someone help?
1
vote
1
answer
47
views
How to set the href with the pathname of the current page in it?
Inside a view I have a block for which there is a field called Global Perspective.
Inside the block override , I have rewrite rules which overrides teh out of the field with custom text.
<div class=...
0
votes
1
answer
155
views
Get taxonomy field value in forum-list.html.twig
I am customizing the appearance of the forums.
I added all my forums and container. Additionally, I added a custom taxonomy field I need to show for each forum category.
How can I show the custom ...
-2
votes
1
answer
209
views
How to debug and find variables on twig themes
I'm trying to create a theme for a drupal web site, but I find it difficult to get variables.
Here is an example:
to get an image form a view I wrote this line
row.content['#row']._entity.field_image....
0
votes
1
answer
259
views
When doing a page preprocess, how do you know if the page is a form?
When doing a preprocess on a page (I need to conditionally change something at the page template level) is there a way to tell if the page is going to render a form? The xdebug output didn't show any ...
0
votes
1
answer
189
views
views.view.unformated.html.twig taxonomy conditional if/else
I am trying to get to the field_news_type term_id/label. I can print the field and I get the term label. Need guideance to be able to select which one I want to use.
{{ fields.field_news_type.content }...
0
votes
0
answers
24
views
Problem in understanding how to manage templates
I'm new to Drupal (and more precisely to version 9), I've been reading resources and tutorials about custom theme creation for 3 days.
I can't figure out how to organize my templates and especially ...
0
votes
1
answer
8k
views
How to get field value from paragraph entity in twig?
Is it possible to get the value from the field inside the paragraph in the red rectangle.
This code part is placed within a twig-template "field--block-content--field-example.html.twig"
{% ...
3
votes
1
answer
159
views
How to determine if {{user_picture}} is not empty in the comment.html.twig template
Trying to determine if {{user_picture}} is not empty in the comment.html.twig template.
{{user_picture}} refers to the Compact display mode for a User Entity.
The below code doesn't work.
{% if ...
0
votes
1
answer
462
views
Get specific element in site path in twig template [closed]
The current page url is http://website/p1/p2/p3/p4
In Drupal 8 twig, use function to get path p1/p2/p3/p4
{{ set site_path = path("<current>") }}
{{ site_path }}
The site_path is p1/p2/...
0
votes
0
answers
64
views
Load page content with AJAX after being gated
I need to gate a page's content with a form so that the content isn't loaded until a form on the frontend is filled out.
I can hook into this form's onSuccess method (all via JavaScript) but I'm a bit ...
1
vote
2
answers
1k
views
Use theme template with specific Views
I have a D8 subtheme of Bootstrap and on the homepage I have 2 Views (2 carousel views).
I turned on twig debugging so I could see which template file(s) is (are) being used, and where it starts and ...
0
votes
0
answers
684
views
How to get the URL of remote video inserted by media field in block or paragraph twig?
How to get the URL of remote video inserted by media field in block or paragraph twig?
I am using the paragraphs module to create video galleries from youtube videos. When I use {{ content....
0
votes
2
answers
842
views
How can I add CSS variables to the HTML head?
For my site I want to be able to set custom css variables to the sites head. I don't want to add css files just inline css code. In the end I want users to be able to set colors using a color picker. ...
2
votes
1
answer
4k
views
How to add template suggestions for form elements of a certain form ID?
I'm looking to edit some Twig templates for certain form elements, but I need template suggestions only for certain form IDs. How do I go about that?
I currently have the following functions in my ....
0
votes
0
answers
15
views
Show field conditionally + display each form part in div
I've followed the tutorial in order to create field conditionnaly, but the field is always shown.
This is possibly due to the way I'm calling my form ? And if I do as I did in my template, how can I ...
0
votes
2
answers
512
views
Adding Count Up module to custom front page
My end goal is to put several Count Up numbers on my custom front page. But I'm having trouble getting it implemented.
First, I installed the Count Up library (https://github.com/inorganik/CountUp.js) ...
0
votes
1
answer
332
views
Using TB Megamenu, how to close one submenu when I open another submenu?
I'm building a couple of (Drupal 8.9.13 and Drupal 9 based) sites where I use TB Megamenu megamenu module (https://www.drupal.org/project/tb_megamenu) to create the menu. All is working fine on ...
0
votes
1
answer
250
views
How to add custom attributes to description meta tag?
I need to add 'class' and 'data-type' attributes to meta tag containing description attribute. I was able to locate the core Metatag module, however I'm unable to find any documentation on how to ...
0
votes
1
answer
107
views
How can I style the webform submissions table?
Using Drupal 9 and Webform, I'm unable to find the twig template used to output /contact/form/submissions. Is there a place in the documentation that lists the twig templates? I see there is a View ...
0
votes
1
answer
2k
views
jQuery dependency on a custom theme is not adding jQuery?
I know that this question has been asked previously many times but any of the solutions are not working in my case so please, I request if anyone can help me with this situation please provide me ...
1
vote
1
answer
341
views
Twig: How to show static text in the template to the Anonymous User?
On a Drupal 8.9.13 website, I've removed the permission "View published content" from the Anonymous user.
By default, when someone visits the front page, Drupal will then display:
Access ...
0
votes
1
answer
35
views
How to display specific button for certain user?
I have a simple Drupal 7 page with 3 buttons. Page is only accessible by logged-in users.
I have 3 roles - role 1, role 2 & role 3
What I would like to do is to show only button 1 when a user with ...
1
vote
1
answer
964
views
Why is the CSS in my sub-theme not working? [closed]
I'm a Drupal newbie, but hoping someone can assist. The site was working okay, but I've tried to implement a sub-theme and things seem to have gotten messed up.
What I was trying to achieve is to ...
0
votes
1
answer
141
views
Twig adds an unwanted 'row' class that doesn't appear in class array
My site theme includes customised templates for 4 regions in the footer, all containing identical code:
set classes = [
'region',
'region-' ~ region|clean_class,
'col-sm-12',
'col-md-...
0
votes
1
answer
261
views
Is there a way to see all the available variables inside content?
I am using Drupal 9 with twig files
I have a page where in one section I need to show thumbnails of the latest posts. So I created a new view as a block, and placed this block under Content in admin/...
0
votes
1
answer
56
views
What am I doing wrong in my theme that's breaking CAPTCHA?
I have a bug in my CAPTCHA implementation. When I click the "Get new captcha!" link, it does not refresh the image CAPTCHA.
After a ton of research in issue queues, testing and breaking my ...