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
0
votes
1answer
18 views

Get media image url in views-view-unformatted template

I'm using drupal 8, in my template I created a file named views-view-unformatted--block-12.html.twig and this is it's content: <div class="row list"> {% for row in rows %} {% set ...
-1
votes
0answers
17 views

Find Class from Custom Block twig template

How can I check if a css class exists in the page from the twig template of a custom block. For Example: <body> <div class="headClass"> <div> Custom block is here </...
1
vote
1answer
32 views

Twig find if a css class exists in a tag

Is there a way to find out if a css class exists in a specific tag through twig? For example: <body class="new-class"> Then I'm able to do a conditional statement in twig based if new-...
0
votes
1answer
28 views

How do you programmatically get the current user's status?

I'm trying to get the currently logged-in user's status (active or blocked) in template_preprocess_user. I tried the following with no luck. function MYTHEME_preprocess_user(&$variables) { $user ...
0
votes
1answer
51 views

Is there a way to change how a form button looks?

I know how to add a class to a form element and how to add a form submission button, but there are classes that are automatically added to these buttons in my Drupal 8 install. The form I am editing ...
2
votes
0answers
34 views

How do you reliably create a GraphQL/Twig theme as a subtheme?

Our theme is built with GraphQL Twig and it's working great. We need to build a subtheme for a different website based on this theme. We're not really having a problem overriding simple Atoms ...
0
votes
0answers
20 views

How do you create skins for the views slideshow?

Supposedly, in Drupal 8 you can create custom styles for your slideshow (Views Slideshow), which the README refer to as "skins". Normally I'd use a css, but the module annoyingly includes a ...
0
votes
1answer
29 views

Load Bootstrap CDN only if not is loaded before from another project

I want to load Bootstrap CDN but only if is not loaded before. How can I do this? Today I'm loading on Libraries.yml like this: And it works. But the problem is: in some cases the Drupal site already ...
-2
votes
0answers
22 views

How to do query from sql and display result in twig in drupal 8 [closed]

I am new in drupal. I made modul, controller and twig now i need to do query and display result of custom content type on page. Can somebody post me code to see how to do it in which file. Thanks for ...
-1
votes
0answers
14 views

Resize “Select” Webform Element

I'm rather new with Drupal and especially the webform module. I've created a basic form with one of the elements being a "Select" type. When I referenced the form on my page, my drop-down (...
0
votes
1answer
24 views

How do you make a Image View of a specific page?

I have a problem. The thing is that I know that you can have a [Content Type] with an image [Field], and then you can create a [View] to display the image [Field] in each of the pages that are of the ...
1
vote
1answer
19 views

How can I link the file name to the file?

I created a content type with a "file" field type. This to upload a pdf file. Now I want to create a link to open that specific file, in my twig. If I do this : <div>{{content....
-1
votes
1answer
14 views

How to display default drupal search block in twig template

In twig_tweak module before version 2 (for Drupal 8) I could place the following code in my page twig template and it would work: {{ drupal_block('exposedformsearch_contentpage_1') }} This would ...
1
vote
1answer
35 views

Adding attributes to a link to an uploaded file

I have been asked to add target="_blank" to the links that are produced when a user uploads a file on a Drupal 8 site. The field type is "File". Multiple uploads are allowed. Twig ...
-3
votes
0answers
26 views

How do I customize CSS in the Bartik theme? [closed]

I want to make some style changes to my website for the Bartik theme. Can I do the changes and add classes to core/themes/Bartik/layout.css, or do I need to create a sub-theme? How do I create a sub-...
-1
votes
1answer
46 views

How to use a Twig variable as View name in drupal_view() Twig Tweaks function? [duplicate]

This works: {{ drupal_view('nursing_resource_blog_teasers', 'block_1') } But this doesn't: {% set view_name = "nursing_resource_blog_teasers" %} {{ drupal_view(view_name , 'block_1') } It ...
0
votes
2answers
32 views

creating a custom report page with a table

Drupal 8.9.6, I'm trying to create a custom module admin report page. I have a custom sub theme of seven called wd_admin. I made a page controller that generates a table as markup, but want to use a ...
2
votes
0answers
55 views

Why can html.twig files be placed outside the templates folder?

In Drupal theme folder structure, there is written: Templates provide HTML markup and some presentation logic. Contrary to Drupal 7, in Drupal 8 template files (*.html.twig files) must be stored in ...
1
vote
1answer
57 views

How to render a field of a taxonomy term inside a view template?

I'm trying to display an image as a banner above the items of a view (which creates a block). The image is a field associated to a taxonomy term and the view is used to display all items which have ...
1
vote
1answer
46 views

How to move views pager to different region as a block?

I created a page view and results are showing up in main page content block. Now i need to move the pager attached with view to different region. I am not sure how to achieve this. Please suggest any ...
2
votes
2answers
141 views

How can I stop the full HTML editor from deleting my <p> paragraph?

https://drupal.slack.com/archives/C1BB308HH/p1602318464360700 Link to slack question in #support JSFiddle of the offending html: https://jsfiddle.net/tyeth/xr4ohast/ Demo Video showing the paragraph ...
0
votes
0answers
34 views

How to add attributes (classes, id, …) to preprocessed text of field? [duplicate]

I'm working on a theme for Drupal 9 where I'm rendering a node's field, which consists of multiple "raw" HTML elements (without any attributes). The item.content variable inside my field ...
1
vote
1answer
48 views

How do the variables in .twig files work?

I am using a theme based off awesome zymphonies theme. I'm trying to use the site_logo variable from page.html.twig, but it doesn't have access to it, instead I have to use the page.header region, ...
1
vote
2answers
73 views

What could cause a View template to ouput wrong row index?

Context I have a weird issue on my live environment that I have never seen on my local environment. Cache bins are disabled on my local environment and enabled on live server. When clearing all caches ...
0
votes
0answers
19 views

Modify entity field from preprocess hook

I can't get how to modify an entity twig variable from a preprocess hook. It is easy enough to add variables to your twig templates but I don't get how can modify an entity predefined variable. In my ...
1
vote
2answers
46 views

Create a custom fieldset template

Normal scenario In a custom form (created using FAPI) I have a fieldset definition: $company_field_set = [ '#type' => 'fieldset', ]; If I would like to customize the fieldset template, I ...
-1
votes
0answers
27 views

How do I set a field to user input using the value field?

Edit: I made a few changes to reflect the attempts I made to help fix the code but it still does not work?? I have a bit of a problem: I want to set the value of a form element to the user input so ...
0
votes
1answer
9 views

Combine multivalue field rows with copy of same multvalue field

Having a list of pdfs using pdfpreview for image-preview I want to add an additional formatted text-field to this ouput. That's why I've created a copy of this field with a different formatter (e.g. ...
0
votes
0answers
44 views

Alter core and add wrapper twig template

Our site has multiple block twig template in our theme (20+). They are simple. When the block is in the layout builder we need to add additional things (admin label, classes, etc), because nothing ...
1
vote
1answer
21 views

How do I name a mimemail-message.tpl.php template to be used with a specific webform?

I cant seem to get the naming of the mimemail-message.tpl.php correct in Drupal 7. I know the naming scheme says "mimemail-message--[module]--[key].tpl.php" but either I'm not understanding ...
-1
votes
0answers
22 views

Adding Pivot to custom schema

We need to add the Pivot option to our custom schema.org module. The output should look something like this. { "@context": "http://schema.org", "@graph": [ { "@type&...
2
votes
0answers
42 views

Site errors out when trying to create a subtheme based on Classy

I'm creating a custom theme in Drupal 9 and am trying to use classy as my subtheme but get the following error: The website encountered an unexpected error. Please try again later. Drupal\Core\Theme\...
0
votes
1answer
35 views

Modifying only one field with a twig template

I have a content type that has multiple fields. I'm fine with the generic display view for all but one of those fields. Is it possible to use a twig template to modify only one of those fields? ...
0
votes
2answers
26 views

Change article layout on homepage

I would like to change the layout of articles on my homepage. But I cannot find the template hereof. I've got my page.html.twig, which but that only includes a placeholder "{{ page.content }}&...
0
votes
0answers
27 views

Customize email template layout of built-in emails?

How to customize the layout of email templates of built-in emails sent by Drupal: Signup, Password Resetetc.. Currently it's sending plain template. I have tried with hook_mail() hook, but seems that ...
0
votes
3answers
47 views

Custom 404 page not working

I'm trying to set a custom 404 page but is not working. What I tried: configuration - system - basic site settings and set node path on 404 page -> didn't work add page--404.html.twig to my custom ...
2
votes
1answer
44 views

How do I display the file size and format of attachments on a node templates?

In the node template I output the attached files (multiupload file field). Need to output the size and format of each file. I do it like this: {% for file in node.field_news_files %}Size {{ file....
3
votes
3answers
272 views

What's the difference between the container and html_tag render elements?

What is the difference between render elements of #type html_tag (set to div) and container in Drupal 8? Is the container render element, a simpler version of html_tag? Easier for processing to ...
0
votes
2answers
59 views

How to count number of published nodes of a specific content type in twig template?

I'm looking for a way to achieve this in my Twig file; if the number of published entities of a content type 'promotions' is at least one, a certain entity should be displayed in a content type Shop. ...
-2
votes
1answer
147 views

How to put a condition in TWIG “if the user is flagged”?

I have a site with Drupal 8 and the Flag module. I would like to display a text when the user has the association role and when it is flagged with the following flag (his machine name): ...
2
votes
0answers
41 views

Differences in adding classes to nodes and paragraphs

I'm trying to add some classes to a certain content type. In mytheme_preprocess_node_contentype() I'm able to use $variables['attributes']->addClass('myclass') However, in ...
-2
votes
0answers
22 views

Override Google Font inclusion in child-teme [duplicate]

i'm using Drupal 8.9.6 and create mytheme as child-theme of Hawell. In hawell.libraries.yml i have global-styling: version: VERSION css: theme: css/bootstrap.min.css: {} ...
1
vote
1answer
49 views

Webform Status in Webform Submission Twig Template

I'd like to use the current open/closed status of a webform in a conditional on the webform-submission-information.html.twig. There is a "webform" variable available to use in the ...
0
votes
1answer
24 views

How can I use #tags in pager_default_initialize()?

I want different label for first/last/next/previous button in the custom navigation using pager_default_initialize(). How I can set an array that can change the button label. $total_count =9999; $...
0
votes
0answers
34 views

How can I show/hide node field values the same way items are shown/hidden in /admin/modules?

When viewing a node of a specific type, how can I show/hide the values like in /admin/modules? I want to be able to click on the field title and show or hide the value. Is there a module that can help ...
0
votes
1answer
31 views

Override of commerce-order-receipt.html.twig template not working?

My theme is using Bootstrap barrio theme (bootstrap_barrio) as a base theme. I'm trying to override Drupal commerce template modules/contrib/commerce/modules/order/templates/commerce-order-receipt....
-2
votes
1answer
39 views

Custom block theme not appearing in QuickTabs content

I'm attempting to create a dashboard page that contains 4 tabs that are each a block that will contain a content based on the current user. I went ahead and created the 4 blocks (bl1, bl2, bl3, and ...
0
votes
1answer
61 views

How to get taxonomy term reference fields value translated in twig

I have a taxonomy vocabulary with terms. In a content type, I have a referenced field with this taxonomy. I can get the taxonomy term in twig like this : {% for item in node.field_lorem %} {{ ...
0
votes
0answers
26 views

How do I inject CSS classes to a rendered field with a view style?

I maintain a module that provides several views styles. I have been unable to figure out how to get the fields where a users custom css entered in the views UI is then output with the view when I have ...
0
votes
1answer
41 views

Count multivalue image field values in views-view-fields.html.twig

Making a presentation template for the gallery. The photo gallery has an image field with multiple values. I need to output the number of gallery photos (in the field_gallery_photo). How do I do this? ...

1
2 3 4 5
208