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

How can I theme a file link in a specific file field? [duplicate]

I have a file field (pdf_via_email). I need to do some heavy theming to the link of this field, so I would like to know how I can create a custom file link template specific to this field. I tried the ...
Il Felice Android's user avatar
0 votes
1 answer
60 views

How to send variables to a custom theme from a custom module

I'm trying to pass a variable from a custom module to a custom theme. I have a Controller class in a custom module <?php namespace Drupal\course_catalog\Controller; use Drupal\Core\Controller\...
Dynamdilshan's user avatar
1 vote
0 answers
29 views

empty variables when i use a region template for a specific node

My goal is to serve the drupal header region on a specific URL so another application can get my drupal header and consume it. my menu is well working, and is called in region--header.html.twig like ...
SupFrig's user avatar
  • 113
0 votes
1 answer
134 views

Override Default Theme's 'page' TWIG template, but not the original page template pre-process hook

I'm using the default theme, Bootstrap Barrio, but for certain pages I'm overriding the page.html.twig template to re-arrange the layout, however I still want the pre-processing done by my theme in ...
micbay's user avatar
  • 13
3 votes
1 answer
597 views

Struggling to enable twig debugging

Update: I've realized that neither my settings nor settings.local files are doing anything. I placed die() and print statements throughout both files, rebuilt cache, and see nothing. I'm stumped. ...
Evan's user avatar
  • 33
0 votes
1 answer
24 views

['#attributes']['class'] variable is not being rendered on the page

I'm working on an old Drupal 7 site. In the template file paragraphs-item--user-block-paragraph.tpl.php the content is being rendered, but the class is not added to the element. Here is the code: $...
Ben Alan's user avatar
  • 111
0 votes
0 answers
27 views

How to access Block Layout data and add to render array for rendering in a Twig template?

I'm a relatively new Drupal developer, and this ticket for my job has been proving extremely difficult for me to figure out through research. I want to access the block layout data (/admin/structure/...
user111115's user avatar
0 votes
0 answers
165 views

How to simply inherit all Olivero regions into my sub-theme?

I am trying to create a subtheme for the Olivero default theme. My problem is that not all Olivero regions are inherited into the sub-theme. For example, some of the regions that are missing are "...
alhemist's user avatar
1 vote
2 answers
144 views

Adding a class to a URL object

function mytheme_preprocess_menu_local_tasks(&$variables) { if (!empty($variables["primary"]["entity.node.edit_form"]["#link"]["url"])) { $url = $...
̷c̷h̷x̷'s user avatar
0 votes
1 answer
285 views

How to set a webform default value for anonymous user?

I have been using hook form alter for a webform, to set a default value for a webform added as a block to a page. Below is the code, the code only works for users who have logged, but for anonymous or ...
Jake13's user avatar
  • 49
0 votes
1 answer
486 views

How can I correctly use an if-condition along with a for-loop in Twig 3.x?

The Upgrade Status module tells me this code is no longer valid for Drupal 10 but I'm not sure how that needs to be changed. {% for paragraph in card_page.entity.field_paragraphs if not break %} {% ...
jtjones's user avatar
  • 11
0 votes
1 answer
52 views

All variables invisible to twig files

I created a theme whose minimal.theme file contains the following lines (among others). /** * Implements hook_preprocess_HOOK() for node templates. */ function minimal_preprocess_node(&$...
Ben Alan's user avatar
  • 111
0 votes
1 answer
935 views

How can I pass existing variables to a custom module template?

I'm having trouble working out how to pull existing variables into my custom module TWIG template. I can create my own variables and pass them, but do not know how to expose variables that already ...
micbay's user avatar
  • 13
0 votes
1 answer
294 views

GET /sites/default/files/js/js_xxxxxx.js - No such file or directory

This is my first post, I just started to learn and use Drupal, and I wish to install a fresh new site on my local Windows machine using composer. The issue is that it has a file not found error from ...
Jeffrey1862's user avatar
0 votes
1 answer
344 views

How can I confirm a path is internal?

In my theme's theme file I'm using preprocess_node to create variables for a node based on the section of my site its in, and that's figured out by checking the path's alias. So for example a path ...
fallenturtle's user avatar
-1 votes
1 answer
182 views

Content type with 3 paragraphs fields: How can I output to different parts of page.html.twig? [closed]

I have a content type called (My Page) with 3 paragraph types, for a slider to display images, for text to display text, and for sidebar content. (The sidebar is a <div>, not a Drupal region/...
user avatar
-3 votes
1 answer
98 views

External CSS file isn't loaded

I am trying to load an external CSS file to globally effect my website. I have tried the following in /core/themes/olivero/olivero.libraries.yml but no change occured after cache rebuild. global-...
themer's user avatar
  • 1
0 votes
1 answer
76 views

How to load a CSS file from a URL? [duplicate]

I have a raw github page with CSS: https://raw.githubusercontent.com/USER/REPOSITORY/main/website/style.css How to load it in my website to effect the website globally? I tried this in /core/themes/...
themer's user avatar
  • 1
0 votes
2 answers
76 views

How can I get the href value from a link?

I have a link I render in a template file with the following markup. {{ item.caption.link }} I want to show only the href value. None of the following worked for me. {{ item.caption.link[0]['#url'] }}...
developer's user avatar
-1 votes
1 answer
652 views

If conditions in twig to check if field has a value [duplicate]

I have used this below code to check if the field has a value {% if content.field_title is not empty %} <p>{{ content.field_title }}</p> {% endif %} But p tag is rendering even though ...
mahasri's user avatar
0 votes
1 answer
60 views

theme_suggestions_html_alter not being picked

I'm trying to implement a custom template html--front--anonymous.html.twig which replaces html.html.twig. The suggestion is being showed, but its file is not being picked. my_theme.theme function ...
Ricardo Castañeda's user avatar
0 votes
1 answer
123 views

Theming image.html.twig for one paragraph type with custom template suggestion

I have a custom module that when installed, creates a paragraph type called "Gallery". Gallery has one field called "field_gallery_images", which is a media reference. I am trying ...
Droopaluser69's user avatar
4 votes
2 answers
384 views

How can I add inline markup to submit buttons?

I migrate code from Drupal 7 to Drupal 10, in Drupal 7 I often created buttons with an icon and text like showen aboven: Drupal 7 code: $form['submit'] = [ '#type' => 'submit', '#value' => t(...
chris's user avatar
  • 61
0 votes
0 answers
31 views

How to add/insert a value to the end of an array programmatically (in the .theme file) Add a $row

I have some code in the .theme file that renders an array list. I wish to add one additional entry at the end. I found I could do that with a quick and dirty PHP echo statement, and it works just ...
Patrick Man's user avatar
0 votes
1 answer
132 views

How can I check if an element has a CSS class that matches a value in an array?

In Drupal 9, I'm trying to check if an element has a certain css class using hasClass(). <p{{ attributes }}>Does this element have my css class?</p> {% if attributes.hasClass('my-css-...
Tinto's user avatar
  • 61
0 votes
1 answer
35 views

Can I add classes to individual menu links?

I am using the main menu /admin/structure/menu/manage/main There are a couple of links that I want to display only in mobile devices, and then also another couple of links that I want to display only ...
Juc1's user avatar
  • 369
0 votes
0 answers
51 views

How do I style a "Read more" button?

I installed the CKEditor Read More module. I want to style the Read more button to match the page background and change the button text color to blue. I've searched all of the files associated with ...
user78354's user avatar
0 votes
1 answer
406 views

Disabling (or overriding) a css file from contrib module's library

I am using admin_toolbar module and I would like to override the path to a logo file that is by default provided by one of this module's CSS file. I found information that I can achieve this with ...
Adamssef's user avatar
0 votes
1 answer
114 views

Use specific theme [not template file] for 404 and 403 generated for specific path

I have 2 themes, both enabled, assume they are called my_first_theme (default) and my_second_theme. I have /whatever path and lots of the pages under this path, and I have a theme negotiator, which ...
Alex Smirnoff's user avatar
0 votes
1 answer
33 views

How can I prevent a custom node page template is used when editing a node?

I'm theming some specific Drupal 9 pages with custom templates (e.g. page--node--17.html.twig). That said, the theme carries over when I go to https://example.com/node/17/edit. I only want the ...
Brittany's user avatar
  • 241
1 vote
0 answers
167 views

How can I add a CSS class to a #type table render element?

I was trying to add a custom classname to the table in my custom module. But for some reason it's not working (Drupal 9). I can not get the table class name added into the HTML. Any help would be ...
Jahid's user avatar
  • 11
0 votes
0 answers
45 views

Node template suggestion based on date field

I am trying to get different templates for events node based on the date of the event. The content type used will be same for both, ie. Event. This is what I have done so far: Created a content type: ...
Farhan Erooth's user avatar
0 votes
0 answers
40 views

Why does libraries-extend not change part of the styles of the module DropzoneJS?

I use the DropzoneJS module. To change to change part of the styles written here: /modules/contrib/dropzonejs/css/dropzone.widget.css I use libraries-extend. In the files of my theme particle I wrote: ...
nathan111777's user avatar
0 votes
0 answers
80 views

My site is not reading the custom page--user--login.html.twig files I created

I am creating custom user (login) pages for my Drupal 9 sites. I have ensured that the files follow the Twig naming conventions and are in the correct folder: app/web/sites/site-name/themes/our-uikit-...
Eric Sorum's user avatar
0 votes
0 answers
82 views

How to use microsoft graph toolkit within a custom module?

I am creating a custom module and want to use microsoft graph toolkit, specifically the file-list component (https://learn.microsoft.com/en-us/graph/toolkit/components/file-list). I've created a ...
Jordan's user avatar
  • 49
0 votes
2 answers
201 views

Can't get real field value from paragraph

I need to get value from exact paragraph type in paragraph reference field in node, so I can use it in Twig. Here's my current code: function my_theme_preprocess_field(array &$variables, $hook) { ...
mixerowsky's user avatar
  • 1,581
-3 votes
2 answers
178 views

Update entityManager()->getViewBuilder from 5 year old site?

I have a Drupal 8 module which hasn't been updated for 5 years. I m trying to update to current version of Drupal. The error I get is Error: Call to undefined method Drupal::entityManager() The code ...
David's user avatar
  • 21
0 votes
1 answer
55 views

Use a different template file for front end and submission view

I have defined a custom template file referenced via #theme for my custom webform element. public function getInfo() { $class = get_class($this); return [ '#input' => TRUE, '#process' =&...
macbert's user avatar
  • 363
0 votes
0 answers
39 views

Programmatically render block content render array with wrappers [duplicate]

I'm trying to render a custom block, created through the UI, programmatically with a wrapper. I can do this: $block = \Drupal::entityTypeManager()->getStorage('block_content') ->load($bid); $...
Jaypan's user avatar
  • 17.5k
1 vote
1 answer
32 views

Image from field not properly displayed in teaser

On Drupal 10 with Olivero theme, I set image in teaser to be displayed with original size. I also made sure the image field display is enabled in teaser view. Still, the image is shown on the left of ...
Robert Brax's user avatar
0 votes
1 answer
99 views

How to make it so theme function isn't used when editing a node with layout builder

I have the following two functions in my .theme file that I'm using to gleam various bits of information from both the path alias and internal URL of the page being viewed. They are: function ...
fallenturtle's user avatar
1 vote
1 answer
62 views

How can I render comment pager on the top and the bottom of the comments portion of the page

When comments are numerous on a node and you have a high comments per page setting, you have to scroll a lot to get to the pager. My users have requested pager at top as well as bottom of the comments ...
aharown07's user avatar
  • 382
0 votes
1 answer
241 views

When iterating over multi-value fields is it considered best practice to override the field template vs loop over the var in node or block template? [duplicate]

I have a link field that allows multiple (3 max) values on a custom block for which I'm using a twig template. I want to iterate over the values using a for loop. I got this to work the way I wanted ...
user92354's user avatar
0 votes
1 answer
712 views

How to get value from object in twig template file? [duplicate]

I can print the result object by {{ dump(item.value['#result']) }} in theme item-list--search-results.html.twig template file. I want to print the body field value("body"=>"value&...
Ramalingam Perumal's user avatar
1 vote
1 answer
240 views

Barrio Theme 5.5.10 Main Menu submenu does not output list items

I need help with the Barrio Theme submenus. I upgraded our site to 5.5.10 to discover the menu has stopped working. In my attempt to figure this out, I recreated a test site locally and installed a ...
Crystal's user avatar
  • 13
-3 votes
1 answer
38 views

Avoid adding custom CSS to a node editing form?

Situation custom module adding styles don't add styles to node editing form How to avoid adding the style to the editing forms? function crossfade_page_attachments(array &$page) { $page['#...
Interlated's user avatar
  • 1,413
-3 votes
1 answer
438 views

Get MenuLinkContent object values [closed]

get title and link of a menu link object in. I am trying to get title and link of a MenuLinkContent object and below is my code. I want to get title and link value. How I can get the title and Link ...
New Dev's user avatar
0 votes
3 answers
158 views

Error with {{ page.highlighted }} while making a copy of Olivero

I am trying to learn Drupal 9 theming by copying Olivero theme into my themes folder. I copied web/core/themes/olivero to web/themes/olive and then renamed all file names containing 'olivero' to ...
LBRTYCAT's user avatar
0 votes
1 answer
408 views

On android, keyboard comes up momentarily and then disappears when a user clicks the search field (likely due to triggering a js resize event)

Related to this: https://stackoverflow.com/questions/51493956/android-keyboard-appears-and-disappears-when-clicking-search-input We have some javascript that rearranges a couple elements in the page ...
Patrick Man's user avatar
2 votes
1 answer
152 views

How to remove a css file from an already-overridden definition?

I want to create a custom theme and remove a css file from diretory themes/stable/css/filter.caption.css from Stable theme. I found this file in stable.info.yml libraries-override: filter/caption: ...
user avatar