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
0answers
10 views

Foreach image uploaded in a Node Content : get the url

I'm begining with Drupal8 and I want to get the url of the photos in the content I create to display them. The context is : a photograph upload pictures for a customer. This customer can see it on a ...
0
votes
2answers
21 views

Cannot get role information in twig file

I cannot seem to get the role of the current user in my twig template. I have tried the following: {{ user.getRoles }} {{ user.hasRole('content_administrator') }} and neither return anything. ...
0
votes
0answers
26 views

Getting white screen in Login /user and the page content

I was recently editing a website with Drupal 7 installed, and was integrating twitter feed. I created a block twitter_feed_block and assigned the block to the content section of the front page. It ...
0
votes
1answer
10 views

No install link for sub theme of sub theme

In my D8 site I have Magazine Lite, a sub theme of Classy. Magazine Lite is installed. In web/themes/custom I have a theme installed that in its .info.yml file names Magazine Lite as its base theme. ...
0
votes
0answers
22 views

Get relative path to node by title in a Twig

Using Drupal 8: I would like to get the relative path to a node using the Title field. Is this possible? All the Twig documentation I've found uses the node ID, for example: <a href="{{ path('...
1
vote
1answer
25 views

Can we output individual form items within a Layout?

We are using Layouts (via mytheme.layouts.yml) to create regions for our Node Edit forms. This looks something like... edit_nodelayout: label: 'Edit Node Layout' category: edit path: templates/...
0
votes
1answer
20 views

twig problem, how to override base templates?

I have installed Bootstrap and the Radix theme, and created a sub-theme, which is all working OK. But I am unable to get some of my twig files to override the base theme twig files... The file themes/...
0
votes
1answer
9 views

Date and links formatting in node template

Drupal 8.x I have 2 quick questions. I have the following node template node--briefing--teaser.html.twig <div> <span>{{ date }}</span> <span>{{ label }}</span> &...
0
votes
1answer
31 views

What's the best approach to create content for users not using an admin theme?

I created a content type : Post and has below fields title media (file) tags (taxonomy) status (only for admin) field_1 (only for admin) field_2 (only for admin) Basically, in Drupal 8 we can set ...
0
votes
0answers
8 views

how to add “addtoany” share icons on search result of a node

I want to display addtoany share icons on search result of a node. And I'm customizing search template search-result.html.twig and how specically tell addtoany to display in search results. I added a ...
0
votes
0answers
8 views

block-header.tpl.php just print only one block

I create block-header.tpl.php file just <?php print $block->content; but it only show one block in drupal 6. In drupal 6 header block have 2 blocks.
0
votes
1answer
24 views

How to display a field of the parent store in my module?

I have a Drupal 8.7 site with the Drupal Commerce 2.14 module. I created a marketplace (several merchants on the same site). In the store type, I created a "Text (formatted, long)" field with the ...
1
vote
2answers
13 views

How to detect Panelizer use in template_preprocess_html()?

In Drupal 7, you could look for $node->panelizer or use page_manager_get_current_page() to check if the current page uses a panelizer layout. How do you do that in Drupal 8? I'm trying to add a ...
0
votes
1answer
18 views

Can we display region label from Layouts?

We have a MYTHEME.layouts.yml file which defines regions... layout label: 'Layout Name' path: templates/panels template: layout-template default_region: theregion regions: theregion: ...
1
vote
1answer
38 views

How do I add default header and footer regions to my site?

i have added regions in my theme.info file. now i want to add default header and footer with logo in all the pages of my site.This is my page.html.twig <div class="layout-container"> <...
0
votes
0answers
22 views

How to retrieve information from the parent store of a product?

I have a site with Drupal 8.7 and Drupal Commerce 2.14 I created a template for my stores : commerce-store--professionnel--full.html.twig And I added this code : <div class="col-xs-12 col-sm-12 ...
0
votes
0answers
16 views

TWIG Template file passing variables

Basically I'm creating a bridge status monitor. I've built this within views. There are 3 main options, Open, Closed, Restrictions (with conditional logic showing these in the form). I managed to ...
-2
votes
0answers
45 views

Custom YouTube preview image in node detail view

Presently I am using https://www.drupal.org/project/video_embed_field. Now I can embed YouTube and Vimeo videos finely in my website. I want to display my own preview image rather than YouTube/Vimeo ...
1
vote
0answers
43 views

How do I add a script just above the closing body tag?

How do I add a script on Drupal 8 site/app just above closing body tag? Vendor provided some JS in the following form: <script> ... code </script> Asked me to place immediately ...
2
votes
1answer
35 views

How do I return a Twig template inside the build method of a block class?

Am new to Drupal and this week I learned quite a bit about module development, and for today the case is: For my new module, I create a custom block that renders a markup, and from the folder ...
0
votes
0answers
24 views

How can I theme a paragraph on admin edit pages?

I'm struggling to override the template on the admin interface for a content type. I'm going to need to do several modifications to the edit form to meet the editor's requirements, however, I seem to ...
1
vote
1answer
12 views

Remove an item from list of taxonomy terms prior to rendering

What is the correct way to remove an item from a list within hook_entity_view or hook_preprocess_node? I am trying to remove a taxonomy term from a list of terms EntityReferenceFieldItemList. I ...
0
votes
1answer
28 views

How can I debug adding libraries via hooks?

I am trying to attach simple css via hooks in the themes and it does not work? The code looks correct to me. It doesn't attach. What am i doing wrong? global-styling: version: 8.x header: true ...
0
votes
1answer
42 views

Setting a Twig to a specific Form Container

As the title says, There is a specific Form Container that I would like to add a twig to that is on a page having its own twig. No theme hook name suggestion is provided when I inspect its element. ...
2
votes
1answer
77 views

How to add a theme preprocess function for published state?

I want to create a body class for the published state of a node. I found some suggestions below for Drupal 7, but this code is not working for my Drupal 8 theme. Add class based on published state ...
0
votes
1answer
56 views

How can I programmatically get the image style of an image in a paragraph template?

I have an Twig extension that applies image style to an image and provides a URL for the processed image. The extension looks like this: protected function setImageStyleUrl($url_field_value, $...
0
votes
1answer
15 views

How can I customize the header and footer from a custom page controller?

I have a module named some_module. This is my some_module.routing.yml: some_module.index: path: '/this/is/the/path' defaults: _title: 'Some Title' _controller: '\Drupal\some_module\...
1
vote
1answer
34 views

Preprocess SCSS with Zen Theme on MS Server

I'm getting familiar with the official documentation of Zen Theme on Drupal 7. I'm wondering about the SASS- and SCSS-Files. The CSS-Interpreter can't understand these files ofcourse. I read about ...
0
votes
1answer
13 views

Drupal 8 block css add

I am using a fresh D8 install. I have created a custom block with a token which I have added to a header. The block is themes from somewhere to float left. If I, through "inspect" in the browser, add ...
0
votes
0answers
25 views

How to view entity when I kint or vardumper views twig?

I am using "views-views-unformatted--view-machine-name.html.twig" twig template. I want to show value of row content like folowing: {{file_url(row.content['#row']._entity.field machine name.entity....
0
votes
0answers
27 views

How can I theme the login form?

I new in Drupal 8 and I have an a problem, i want to change de look of my user_login_form, reading about that i knew that i could use the hook_form_alter for my purpose but I can't access the form ...
0
votes
1answer
42 views

How to modify default login page using theme?

Version: Drupal 8.7.x Currently, I am using a subtheme of the Bootstrap theme and I want to override the default login page because the interface doesn't look good. I was hoping to override the ...
0
votes
0answers
13 views

Theme suggestion for child element of a multiple value field widget

I would like to add a custom twig template for the table of a multiple value form element that is shown on a node edit page. Let's say we have a simple input textfield that allows entering multiple ...
-1
votes
1answer
37 views

Create a simple download link using twig

I want to create a simple download link on twig using Drupal8 but as easy as it can seems, I didn't find anything that was matching for me, it will always be the same file to download, it will be ...
1
vote
1answer
67 views

Error: Undefined index: render element

I encountered an error: Error message Notice: Undefined index: render element in Drupal\Core\Theme\ThemeManager->render() (line 200 of core/lib/Drupal/Core/Theme/ThemeManager.php). ... I found ...
0
votes
0answers
20 views

Add a class to a “view” depending on the value of the exposed filter

I have a view with a exposed filter, the view have the following structure. <div class="view"> <div class="view-content">...</div> </div> The exposed filter is select type, ...
1
vote
2answers
154 views

Hide title if 404 error

I have a custom 404 error page, and I just want a quick module that hides the 404 page title, if the user arrives at a 404 error. I've found a D7 function that looks like it would work, checking for ...
0
votes
0answers
42 views

How to use Paragraph components inside of Paragraph components

I have a component-based system using Paragraphs. I create the markup in Twig (Drupal 8), then pass the values of Paragraph fields to the component's properties. So for a super basic example: {# card....
-1
votes
0answers
34 views

How to design a page that completely ignores the base theme and and css?

I am creating a block which I want to be displayed on 50% of the screen area. I am keeping the block as a sidebar and am manipulating css of the block but I am not getting the required result. Is ...
-3
votes
0answers
28 views

How to Calculate number of days between two dates in Webform using Twig [duplicate]

I am using Drupal 8.7.6 + Webforms 8.x-5.4 I am building a form to for booking Vacation (time-off or annual leave). It has a Start date field and an End date field. I want to add a Computed Twig ...
0
votes
0answers
24 views

Divide menu tree parents and children links into columns

I have the following menu tree for my main navigation: Parent 1 (= level 0) SubParent 1 (= level 1) SubChild 1.1 (= level 1) SubChild 1.2 (= level 1) SubChild 1.3 (= level 1) SubSubParent 1 (= ...
0
votes
1answer
62 views

Rendering a responsive image style in Twig

I am working on template views-view-fields--myview.html.twig. But I do not think it matters what template you are working with for this to work. I found this Twig that can add Drupal responsive ...
0
votes
1answer
24 views

How to display the content of the view in Twig?

I created a view with the machine name administration_utilisateur_abonnement_license I want to add a class under the div views-row. I created in my theme a twig file for the view views-view-fields--...
0
votes
1answer
52 views

How can I get the module path in twig?

I have a module and created twig templates there. I just followed the documentation here: https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-for-custom-module I want to include a ...
1
vote
1answer
49 views

Cache pages/variables in hook_preprocess() for anonymous user

So I am having trouble understanding the caching of variables set in hook_preproccesses for anonymous users. It seems that the entire page is cached, and not rebuilt, even when set to no caching. With ...
0
votes
1answer
18 views

Why can't I debug twig templates with intellij idea?

I can't get intellij idea to break on twig files. It is breaking on theme and module files fine. This means that xdebug must be setup correctly. I don't believe that it is caching as I've deleted the ...
0
votes
0answers
11 views

twig access variable from sub-rendered item

here's my current twig template menu-levels.html.twig as I've hooked preprocess_menu_levels(&$variables) {$variables['display']='mobile';} => I get display variable in the first parent twig ...
0
votes
0answers
34 views

How can I override the form-element-label.html.twig template?

In a view, I have checkboxes displayed using the better-exposed filter. Ajax setting is true. Currently, there is no template suggestion for overriding form-element-label.html.twig. Somehow by adding ...
0
votes
0answers
25 views

How to print paragraph image title/alt in custom twig template?

How to display the alt and title text in drupal twig template? I already enable the alt and title field, but don't know how to print the field. Here is the code in custom twig template. I want to ...
0
votes
1answer
40 views

How to discover the currently active twig template

I need to find out the currently active Twig template from within my module preprocess function. function mymodule_preprocess_field(&$variables, $hook) { // How do i retrieve the currently ...