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
29 views

How do I apply HTML IDs to field output result?

I'm trying to build a block for tb_megamenu of a view of items of a certain content type. I want to use some JavaScript so that when the end user hovers over a title then associated content appears on ...
0
votes
0answers
25 views

How to get drupal to check for a twig template in the active theme folder before checking the module folder?

I'm developing a contrib module for Drupal 8 that sends email notifications to group members when new content has been posted in groups they have subscribed to. The module defines some new view modes ...
3
votes
2answers
264 views

How should I include <link> or <style> inside <head>?

I'm trying to use a Google font, which requires adding either a <link> or <style> section inside the <head> per the below instructions. I am using a subtheme and can modify the ...
-4
votes
1answer
43 views

How do I add CSS classes to all the form elements?

How can I add the same CSS class (form__text) to form elements in Drupal 8?
0
votes
0answers
37 views

Add a region to the page--front.html.twig

I've created a few new region in my yml regions: header: "Header" jumbotron: "Jumbotron" chiffres: "Chiffres" steps: "Etapes" presentation: "Presentation des formules" ...
0
votes
1answer
34 views

How to check if custom variation field is null in twig?

I would like to know how to check if a custom variation field has content in a twig template (commerce-product.html.twig with variations injected). I have tried with some filters and conditions but ...
0
votes
0answers
12 views

Mode display specific Media Image formater template

i am having this template suggestion function amu_www_theme_suggestions_image_formatter_alter(array &$suggestions, array $variables) { $entity = $variables['item']->getEntity(); $...
2
votes
1answer
31 views

How to pass field value to referenced node template?

I have content type A. It has field reference to content type B. I'm rendering referenced node B from content type A twig template like: {{ content.field_referenced_object }} And that works well. ...
0
votes
0answers
40 views

How to display field_tags of a node in html.html.twig? [duplicate]

I want to display fields "field_summary" and "field_tags" of a node in html.html.twig (without using a module for that). I was already able to get "field_summary" value in html.html.twig with this ...
1
vote
1answer
49 views

twig template suggestion for comment reply form

there is no template suggestion for a comment reply form in Drupal 8, how can i create one? i am not talking about the reply form displayed in the node for which Drupal suggest a template : field--...
0
votes
4answers
92 views

How can I design the standard user login form with twig?

I want to change the labels "Username" and "Password" and delete "Create new account" link of the standard login form of Drupal 8. Is it possible to do this with twig?
0
votes
1answer
30 views

Why do I get an error after adding a .theme file?

After creating (e.g empty) .theme file in my template folder, I get the following error message: The website encountered an unexpected error. Please try again later.RuntimeException: Failed to ...
0
votes
1answer
65 views

Why does my do-nothing subtheme break the parent theme?

I'm trying to get started with sub theming in Drupal 8. I followed the example from the Drupal documentation and created what I thought was supposed to be an unmodified inherited copy of the Bartik ...
0
votes
0answers
24 views

How do I add a link to the fontawesome field?

I am trying to wrap the font awesome field with a link in another field. I'm using modules which provide 2 filters. fontawesome which implements Font Awesome Icon Formatter linked_field which has a ...
0
votes
0answers
20 views

View only part of an image?

I am not sure if this can be done with core or Module settings, or require some tricky CSS work. I have an image that is part of a slideshow that goes all the way across the page no matter how wide ...
0
votes
1answer
34 views

Manually laying out specific articles on page

I'm making a newspaper site and would like to manually lay out and embed a specific set of articles for the front page. Is there a way I can manually code the layout in columns and embed specific ...
0
votes
1answer
19 views

render call in hook_node_presave uses admin theme

I am using hook_node_presave() to render my node and then save the output to a field field_node_cache. However, when I do this, the renderer uses the admin theme, whereas I would like to use the site'...
1
vote
1answer
47 views

Suggested template file is not working for Custom Search's template

I have installed Custom Search module for my drupal7 setup. I am trying to modify template files for search-result and search-results. By default its using template files from contrib module's theme ...
0
votes
1answer
29 views

Modify user profile page, not login page

I'm trying to edit the user profile page, not the login page. However, with Drupal 7, the template for the profile and the login page is the same. I tried to modify page--user.tpl.php, but it also ...
0
votes
0answers
51 views

How to add variable to customize mail which is send after completed order?

I have created a custom field "field_jour" (type = selection list) in Commerce Order Type, for Checkout process. I would like to customize Mail which is send when order is completed (file = modules/...
0
votes
0answers
62 views

Add Is-Active class on custom link in view

How can I add Is-Active class on custom link path in view. I have created block of taxonomy term name and format is Grid view. I have added field "Name" and in its configuration given custom path link....
0
votes
0answers
22 views

Get rank form a list to show on node twig html

D8 question: I need to show country population rank. How can I show the country's own ranking on the country node (eg:4 for italy). What I tried: I've tried to get rank via block but view result ...
0
votes
1answer
41 views

Remove dots ( … ) from default search results descriptions ( snippet )

I want to remove dots from search results items descriptions to search result page ( Default Search ), i have used Drupal default search for the search result page so how to remove the dots from the ...
0
votes
0answers
38 views

Not able to load data from cookies until I clear cache [duplicate]

In my Drupal application, I have set some cookies through a javascript onClick method. However, am not able to access the data until I clear the cache(admin/config/development/performance/clear ...
0
votes
2answers
39 views

How to get different image styles in the same view?

I'am a newbie, and I want to make a simple view with an image field (in article nodes), that looks like this layout : And for this, I don't want to use CSS rules to resize the view rows images, for ...
1
vote
2answers
22 views

Custom home page not recognized by system

I have set up a Drupal 8 site with a custom home page using page--front.html.twig. The content displays at domain.com/front. When I go into Administration to change to the new home page, it says that ...
0
votes
0answers
31 views

How to reference on Computed Twig in another Computed Twig

I am creating a webform that collects data on the number of private offices that a company wants in their workspace and then does calculations based on those quantities. I can easily do the basic ...
0
votes
1answer
55 views

Twig escapes tags when using raw value in template

I am printing fields in a node template, but Twig is escaping my tags and ruining my day. My .tpl looks like this: <blockquote> <p class="title">{{ content.field_myfield.0 }}</p&...
0
votes
2answers
114 views

How to access webform field labels in a twig template?

The YAML below represents a webform. Theming is simple using the twig template also found below, but the label for email is inline with the input field by default. How can the labels in the webform be ...
1
vote
0answers
69 views

How to render webform element in twig file template for HTML display

I want to override the HTML display for webform submissions. So, I have copy this file "webform-submission.html.twig" in my template folder and rename it in: "webform-submission--testform--html.html....
2
votes
1answer
61 views

How can I remove all contextual links except in layout builder?

When using the layout builder module, the contextual links module is a hard dependency. This works quite well in the context of the layout builder. But I don't want those links anywhere else, because ...
0
votes
1answer
151 views

How to preload a css/js library programmatically after module installation? is there api for changing *.library.yml file?

i would like to develop a module where i cached internally html,css,js statically for pages. 1) in a admin setting page i can add a bundle with 1 html page + css/js files. 2) for each bundle i have ...
2
votes
0answers
72 views

Is it possible to use libraries-extend from a module (instead of theme)?

Problem/Motivation I'm interested in altering/overriding the little bit of HTML markup that's output by core, in my case Drupal.theme.mediaEmbedEditButton (from core/modules/media/js/...
0
votes
0answers
13 views

How to alter file remove button html or attributes?

Default file widget functionality. File is uploaded, remove button is added to the page as well. I'm sure that code is running because i'm able to debug it upon ajax upload. Still no new class, no ...
0
votes
1answer
52 views

how to display a media description in a twig template?

i want to display the media description available in the file field of a media ( media of type video, audio, image, etc...), it is an option to activate: Enable Description field The description ...
2
votes
1answer
36 views

How do I strip spaces from a Twig variable?

Example code I'm working with: <a{{ attributes.addClass(classes, 'field__item') }} name="{{ item.content }}">{{ item.content }}</a> In this example, I have created a Brick with a field ...
0
votes
0answers
119 views

How to check the Webform submission values in a twig template

I have an Webform with an option element, (option_one), with 6 options. Below this are 2 option elements with 5 and 2 options. These 2 option elements have a conditional statement to display if the ...
0
votes
0answers
16 views

How can I change the Facet name to a custom name on the front-end?

I would like to use a custom label instead of the name that's displayed on the front end. It's important to understand that I do not wish to change the name of it though. Just the label of it - ...
1
vote
2answers
176 views

How do I add CSS body classes for logged-in and logged-out users?

In Drupal 7 I would add a theme process function to add the body classes needed. function template_preprocess_html(&$variables) { $variables['classes_array'][] = $variables['is_front'] ? 'front'...
0
votes
2answers
21 views

How can I have editors select which blocks to be displayed in what order per page?

I have taken on a site that has hard coded page urls in it's page.html.twig for loading specific sidebar blocks based on the url for related content. eg: {% if 'frozen' in url|render|render %} ...
-1
votes
1answer
26 views

How can I make a multi-column content section with Paragraphs and Bootstrap?

How to adapt this code in php for Drupal 7? https://jimbir.ch/blog/making-multi-column-content-section-drupal-paragraphs-bootstrap drupal-paragraph-multi-column-field.html.twig {% for item in items %...
0
votes
0answers
63 views

render different fields of a content type (media) in a twig templates

For the video media type of drupal 8 i want to render the fields of it into a tag. i created the template field--media--video.html.twig copy of field.html.twig i render the field like this : {% ...
2
votes
1answer
46 views

HTML tags being removed after theme_preprocess_node

I am using theme_preprocess_node to modify an HTML tag, but the tag is being stripped somewhere in the theme layer. mytemplate.twig {% if node.field_embedded_media.value %} {{ content }} mytheme....
0
votes
0answers
22 views

Converting embedded images from Media module to Markdown

My Drupal 8.8 site (media embed is now in core) uses the Markdown module for the Body text of nodes. I created a custom view mode, Ebook export, which has some twig templates that output the raw ...
0
votes
1answer
120 views

How to access fields value in views-view--[viewid]--[view-display-id].html.twig template [duplicate]

I'm trying to customize a View in Drupal 8 where I display a Bootstrap Carousel. What I've managed to do so far was the right template name, by specifying the viewid and view-display-id. The view ...
1
vote
1answer
26 views

How can I restrict libraries to attach to my custom controller only?

I have a custom module that creates its own page and displays some stuff. I have some CSS and JS to add, and I'm using a library. The CSS and JS are being added, but to every page on the site. Can ...
0
votes
1answer
30 views

In hook_form_alter how can I attach libraries on frontend only?

I'm trying to attach a js file to a form using hook_form_alter() but I don't want to js to be loaded on the administration template. How can I achieve something like this? With what do I need to ...
0
votes
3answers
86 views

My custom CSS is not taken into account

I add a CSS file (mymovies.css) to a custom form (SeenMovies) in a custom module (eric) with this code I inserted at the end of buildForm $form['#attached']['library'][] = 'eric/mymovies'; and this ...
1
vote
1answer
74 views

How can I prevent user data being cached and showing the wrong username?

I have built a Drupal 8 site, we are showing the user name and last name on a block, this is my code on preprocess from .theme file: $user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->...
0
votes
3answers
33 views

Change CSS class based on number (length) of entity reference items, in a paragraph entity

In my paragraph twig file paragraph--call-to-actions.html.twig, I want to render and build up the entity reference items (the child items from a certain Paragraph type). There could be 3 or 4 items. ...