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
-2 votes
1 answer
93 views

Custom Template for Comment links

I would like to have a custom template for links (edit, reply, deleted) for my custom Comment Type. (Drupal 9) Twig Debugging of course enable. I have tried to use hook_theme_suggestions_link_alter ...
  • 3
0 votes
0 answers
16 views

Why did twig suggestions disappear when i reference bootstrap layouts

All twig suggestions disappeared when I added the "bs-2col-bricked--node-pbr-home.html.twig" file to my custom templates directory and the template is not benig referenced. What have I done ...
1 vote
1 answer
99 views

Theming embeded entities

I'm using the entity_embed contrib module (8.x-1.2) in drupal 9.4. I embedding entities inside a node body in ckeditor. The function mytheme_theme_suggestions_block_alter() is not called for block ...
  • 154
0 votes
0 answers
19 views

How can I make a theme region expand height to fit content of several blocks, pushing all following region content down?

After a long hiatus from Drupal work, I now need to meet a request to modify a Drupal 7 site. In the existing theme I need one more full-width theme region than what's available. (At one point I had ...
  • 225
0 votes
1 answer
52 views

Custom HTML for a form widget

How can I change a node edit form so that boolean fields use a toggle switch instead of a checkbox? Currently they look like this and I would like to update them to be more intuitive like this (https:...
  • 131
0 votes
1 answer
274 views

How to access a property in twig that begins with a hash

I'm trying to get to the name of a media file in twig. The name is located at: mediaitem[0]->#values[name][x-default] in the rendered entity passed into the template with field_media_item|...
0 votes
1 answer
195 views

How to theme a pager with twig?

I've added a pager to a custom page rendered programmatically from a controller. I want to customize the pager. How can I do it without overriding the standard pager twig? This is the hook_theme: ...
1 vote
0 answers
34 views

How do I use specific css to taxonomy-term in teaser?

On the front page a list of teasers is shown for different content types. For one of these content types I want to use different css depending on the value of the taxonomy term. Content type name : &...
  • 69
-2 votes
1 answer
194 views

How iterate through output from "views-view-field.html.twig" file? [closed]

I have views with 6 results. However they are displayed in 2 different ways. 2 first in one way, 2 next in second way, next in first way and last in second way. I know it is quite confusing. I have ...
  • 9
0 votes
0 answers
32 views

Advagg breaks the site for logged in users

Recently started having issues with Advagg module. If I set the AdvAgg Cache Settings to anything other than Development, it breaks the site (one of the CSS file goes in redirect loop). Only happens ...
  • 161
1 vote
0 answers
87 views

How do i programmatically change the active theme and make it work with administrator and anonymous users?

I have 2 themes. I want to use one for the desktop and the second for mobile devices. Everything works fine, except it doesn't work for anonymous users. This is the code I am using. ns_mobile_detect....
0 votes
0 answers
20 views

Changes text on form alter [duplicate]

I want to changes the text new information to Latest information Below is object and contain protect string as [string:protected]. How I can i changes text. stdClass Object ( [__CLASS__] => Drupal\...
0 votes
0 answers
10 views

How to Modify Placement of Elements in a view based of a field selected in the content

I have a content type with 4 fields namely title, body, image, and position, my goal is to set the placement of these fields based on the value selected in the position field e.g. if the value of ...
0 votes
0 answers
31 views

I Want to set position of Text and Image based on position selected by radio button provided in the content type

The content type has 4 fields - Title, Body, Image, Position Radio Button (Top, Left, Right) Based on the selection of the position image should be placed at the respective position with the title and ...
1 vote
0 answers
32 views

Trying to customize template of a form rendered by a view

I'm using Drupal commerce and it's cart form for a client's site and I cannot manage to find an accurate template to customize it. The cart's form is rendered from a view. I'm trying to suggest a ...
0 votes
1 answer
74 views

Making field value available in template page-title.html.twig

My page content type contains the field field_subheading. How can I make this field available in the template page-title.html.twig? Below code doesn't work, probably because $variables['node'] isn't ...
0 votes
1 answer
284 views

How to pass variable value from html.html.twig to page-title.html.twig

Adding a dump 'dd()' to parent html.html.twig template file when rendering a 'page type' page I get, among others, the following pair: "node_type" => "page" that I can render ...
  • 17
0 votes
0 answers
45 views

Send username recovery email in html format [duplicate]

I have installed the Forgot My Username module (Version: 8.x-1.2) and it creates subject and body options in the configuration account setting but it seems to use plain text rather html mail. I want ...
0 votes
1 answer
45 views

How do I override the template file of a view so that it no longer displays links in my view, but only the plain text?

How do I override the template file of a view so that it no longer displays links in my view, but only the plain text? This is a body field where the titles of the refenced entities are displayed as ...
0 votes
1 answer
52 views

cant get file uri using field preprocess

Im trying to use function theme_preprocess_field to get the file path of a file field. I have tried different variations of below. function mytheme_preprocess_field(&$variables) { if ($...
0 votes
2 answers
468 views

Twig adding extra spaces around output

I am trying to output the label of a node in twig with Quotations around it like this: <h2>"{{ label }}"</h2> The output for some unknown reason though is: " My Node Title &...
0 votes
1 answer
203 views

add wrapper div to form element in content type [closed]

Is there a way to add wrapper div around few form element in admin theme? I have a content type that i want to style its admin theme. I already have m sub-theme. I couldn't find the file that is ...
0 votes
1 answer
105 views

How to generate templates suggestion for media.html.twig for a specific field in a content type?

I have a content type (say Article) with an entity reference field to another content type (Author). I have used layout builder together with a view mode to display the content of the Author field in ...
  • 858
0 votes
1 answer
136 views

How to show admin bar in custom theme?

I am trying to create custom themes with bootstrap for Drupal 9. If I use the bootstrap5 theme as the base theme, I can access to the admin bar when viewing content. If I use any core themes as base ...
  • 15
0 votes
0 answers
92 views

I having trouble getting Layout Builder Styles Module to work correctly

I'm trying to use Layout Builder Styles on Drupal 9 to style my blocks and sections in layout builder. The problem is none of the styling is being applied to the displayed content. This is the ...
1 vote
0 answers
184 views

Theme suggestions file-video.html.twig

I have a block with the media field video bundle (drupal 9) and it renders the video through the file-video.html.twig. I have copied template to my custom theme from core. What do i need is to ...
0 votes
2 answers
131 views

How do I print an exposed filter block in a template file?

I have a view with an exposed taxonomy filter. I configured it to be displayed as a separate block so that I can print it another twig template. I tried this. /** * Implements hook_preprocess_block() ...
  • 858
0 votes
0 answers
56 views

I lose template suggestions when an ajax event is called

I'm generating theme suggestions based on the formdazzle module, I made my own variant because I needed another level of granularity of theme names and it works fine. Well, in the alter hook I have ...
  • 401
0 votes
0 answers
394 views

How to render fields in nested paragraphs?

I'm trying to create a paragraph that will allow me to display several children's paragraph fields. I added the children-paragraph to the parent paragraph via Entity reference revisions. I created 3 ...
  • 101
0 votes
1 answer
529 views

How can I add classes to an item in field.html.twig

I have a typical content type, with a field, let's say field_name. I can output each field using the field.html.twig file. In the file, to output each item, there is a line <div{{ item.attributes ...
0 votes
0 answers
73 views

User error: "1" is an invalid render array key. How do I find where the error is coming from?

I get this error on every page. How do I debug or find what is causing it? I thought it might have been changes to a twig template, but I tried other themes, and still had the error. I've disabled all ...
  • 155
0 votes
2 answers
42 views

How to list Links/Attachments in sidebar second

When managing fields for a given content type in Drupal 9, I would like to be given the option to list all items of a given field (e.g. Links, Attachments, ... ) in a specific region (say, sidebar ...
0 votes
1 answer
265 views

How can I access row field values in the parent views template?

In views-view-fields--myview.html.twig I can print a views fully formatted/rewritten field with a variable like: {{ fields.field_my_view_field.content }}. I am wondering if there is some way to print ...
  • 1,008
1 vote
1 answer
565 views

What is the correct way to get the rendered fields values in a block view twig template?

I have a block on the main page of my website that displays most recent news stories from the News page (3 latest entries). This is a view, here is its settings: I'm trying to make this block look ...
1 vote
2 answers
267 views

What does #markup mean?

I meet this array key all the time in Drupal (for example in Symphony's dpm()) yet I am not able to find any documentation about it, what it does, how can I use it? How do I display something that is ...
  • 297
1 vote
1 answer
49 views

Check for block type in THEME_preprocess_menu_local_task

I want to make changes to local task tabs of a certain custom block type (mini_layout). I can do this for certain node types in my theme with THEME_preprocess_menu_local_task(), and there I can use ...
  • 470
1 vote
0 answers
42 views

How to wrap select list in custom html?

I have a select list created by views exposed filters. When I debug the templates used. I have the exposed filter template, then the select list is in a seperate template. I tried just putting my html ...
  • 155
0 votes
1 answer
133 views

How to display the current year in the template of a block?

I'm trying to rewrite the "Powered by Drupal" block. I want to display the current year in my code but cale does not work. The website displays a blank page with the message "The ...
0 votes
0 answers
29 views

How to get node object from entity referance in paragraph twig template [duplicate]

I created a content type named "programs", with an image, short description field. Then I created a paragraph type and added a field as entity reference of programs. Now in the paragraph ...
  • 1
0 votes
0 answers
116 views

How do I programatically change a webform's element type?

I am using a webform element 'select_other' in the webform. We got a requirement that the Other field should only appear if certain conditions are satisfied. I already have a Webform Handler In place, ...
0 votes
2 answers
1k views

Pass a PHP array to Twig? [closed]

I want to be able to access an array in my Twig template that is built in PHP but it always appears blank, am I missing something? mytheme.theme function mytheme_preprocess_page(array &$variables) ...
  • 131
1 vote
0 answers
32 views

Drupal 8 Theme suggestions for form children elements [duplicate]

What is the best way to define template name suggestions for children elements of form in drupal 8? In myTheme.theme I can define hook like this: function myTheme_theme_suggestions_alter(array &$...
0 votes
1 answer
203 views

theme_preprocess_menu is not seeing main menu

Background: I have an event website where I want to hide the event registration menu item when registration for the event is closed. theme_preprocess_menu is not triggering on anything except '...
2 votes
1 answer
124 views

Set Body Class if Facet is active

I need to set a body class if a facet filter is active. It should be done in yourtheme_preprocess_html if Facet is active then $variables['attributes']['class'][] = 'facet-active'; for fulltext ...
-1 votes
2 answers
69 views

Cannot make page--node--nid to work

I created the page--node-112.html.twig template file for a Page* node whose ID is 112. Drupal is still using the page--page.html.twig template file. How can I make Drupal use the template file I ...
-1 votes
1 answer
25 views

How do I add additional social media platforms to the social media block in this theme?

I have found the zymphonies.com theme: composer require 'drupal/drupal8_parallax_theme:^2.0 a useful addition to my toolkit. It comes with a banner slideshow built in, is designed to be mobile-first ...
1 vote
1 answer
130 views

Extend core select widget

Please help with the following: I need a new widget (just a slightly altered select) that can be setup from the UI by anyone. I have done the following: Created a new custom module and enabled it. ...
  • 11
2 votes
1 answer
52 views

Is there a way to add a page element to all unpublished pages?

I am trying to add an "unpublished" graphic on all content that is unpublished so editors can clearly see that the page is unpublished, but I have about 15 different content types. Is there ...
  • 141
0 votes
0 answers
29 views

Why isn't the template file used?

I have created a template. Its file name is exactly as specified by the file name suggestions. However, the template is not used. In the screenshot you can see the suggestion for the file name, ...
  • 465
0 votes
1 answer
161 views

How to create a vertical table

Can anyone please help me to render theme_table data in vertical format instead of horizontal format ? Currently horizontal table is overflowing the page and breaking breaking points. My current code :...