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
50 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
61 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
19 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
36 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
37 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
38 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
20 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
30 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
37 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
71 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
46 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
52 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
45 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 ...
1
vote
0answers
42 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
33 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
24 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
75 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
17 views

Translation Issue for paragraph and Views

For a couple of days, we are facing an issue in translating the paragraph. While creating the paragraph, we are not able to check the "Users may translate this field" field. So we are not able to ...
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
105 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
25 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
46 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
45 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
76 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
25 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
29 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
81 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
62 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. ...
0
votes
0answers
36 views

Image is “broken” with Custom Email Twig Template sending with Webform

The setup consists of Drupal 8 + Webform (ver. 5.6 - https://www.drupal.org/project/webform/releases/8.x-5.6) + CKEditor Image Upload (https://www.drupal.org/project/ckeditor_uploadimage). This allows ...
1
vote
1answer
29 views

Change Classes in Nav-Tag of Custom Menu

On a Drupal 8 installation, I have a menu in the sidebar first region. I want to add classes to bootstrap classes to the different levels of that menu. For that I created a my own menu template, which ...
1
vote
1answer
194 views

How do I theme the core modal with twig?

Drupal 8 comes with built in modals. This works: <a href="/node/11" class="use-ajax" data-dialog-type ="modal">modal</a> How can I style that modal using twig, to add new classes to the ...
0
votes
1answer
26 views

Why is library not being attached to my email twig template?

I am overriding the commerce-order-receipt.html.twig by adding that file to mytheme/templates/commerce. I then add these lines to mytheme.libraries.yml email: css: base: assets/css/email....
0
votes
1answer
37 views

How to get current language of node in twig?

I have a tranlatable node, and I need to get its translation language. You know, I must to know is current node is in Polish or English. So... below there are my devel dumps from a node in Polish and ...
1
vote
1answer
52 views

How to find the viewid and view-display-id?

I'm trying to customize a view displayed in the homepage. Specifically, I'm trying to build slideshow with Bootstrap Carousel. I've checked this page, but I don't understand how to find viewid or ...
0
votes
0answers
25 views

How to change per node the view mode of a media entity, which is referenced via a paragraph bundle? [duplicate]

A given content type contains a paragraphs field. This field references a paragraph bundle, which in turn references a media entity of type "image". The display of the media images is controlled with ...
0
votes
0answers
20 views

File field edit form change display style attachments

I need help. I would like change display attachments when edit entity. Default Drupal display attachments in table but I need change this to eg. unordered list or anything else - how to? I found many ...
0
votes
1answer
41 views

How do I display the date but not the author?

I want articles to show Submitted on without showing Submitted by. The checkbox on Display settings toggles both, not only one of them. Control/modify display settings (author and date) on posts ...
0
votes
0answers
29 views

Custom module with same twig template and two paths (e.g /pub and /pub/{id} )

I created a custom module to show nodes by taxonomy in a specific html twig. I created a controller that contain two functions. The first function called "content" pass an array to template twig ...
0
votes
0answers
18 views

Better exposed filters, hook form alter to specific template

On a view there are two exposed filters in one page. Rendered by BEF. For the template with BEF, I have a custom template. I need to alter this template. The #form_id and #id are exactly the same in ...
1
vote
1answer
76 views

How do I use PathMatcher::matchPath() for a wildcard path?

I am trying to use PathMatcher::matchPath() to match a string of paths using a wildcard pattern. I'd like to match any path containing /topic* so if the path matches, I'd like to add a body class ...
1
vote
1answer
60 views

How can I embed a view in a template when passing view name and parameters are passed as variables?

Inside my paragraph template I have variables which contain category id and view machine name. So when I print them like this: {{ content.field_category }} {{ content.field_view }} I get correct ...
0
votes
1answer
50 views

How to temporarily replace Drupal with static HTML pages?

I'm a JavaScript dev with no Drupal experience. I'm working with a church to redesign their Drupal site after their dev moved on without leaving any notes/documentation/etc. In the meantime, I'd like ...
-3
votes
2answers
73 views

Load a CSS file only for anonymous users visiting the front page

I want to load a CSS file only for the front page, and only for users who didn't log in. Both conditions should be met; in the other cases, the CSS file should not be added to the page. How do I ...
1
vote
1answer
145 views

Rendering a nested Paragraph's field using Twig

We are using the Drupal 8 Paragraphs module and are have a Paragraph which contains a Paragraph type field, called "Steps" (machine name fs_steps), allowing editors to add a number of "Step" ...
0
votes
0answers
40 views

Theming user-register-form.tpl.php with password set at registration

I'm using Drupal 7 and I've created a user-register-form.tpl.php to override the default user registration page at user/register. It displays all the fields I need except for the password fields. I'm ...
0
votes
1answer
30 views

Show Comment Form on its own Page or Popup

I am trying to figgure out how to show the comment form on its own page. So far I have been able to show it on a seperate page. All I had to do was to go to field comment setting and uncheck "Show ...