Questions tagged [theming]
Use it for questions about rendering or modifying the HTML markup produced by a module/theme.
10,737
questions
1
vote
0
answers
63
views
How to programatically and totally vanish the sidebar in the homepage?
Core version 10.1.6 with Olivero theme.
In the <front> webpage or alternatively in the Homepage content type webpage (the homepage), I wish to just totally vanish the sidebar and let main ...
-2
votes
1
answer
27
views
Is it possible to make a theme hook suggestion for blocks according to content type?
I was hoping it was possible to do something similar to this for menus:
* Implementation of hook_theme_suggestions_HOOK_alter() for menus.
* * Make menus themeable:
* e.g. => menu--main--node-...
0
votes
1
answer
36
views
Event listener for button intermittently fails to be added on home page
Background
I have a filtered view for the content type "Change Requests" that I built as a page, and as a block. The block is added to the user's home page and only shows that user's change ...
-2
votes
1
answer
53
views
How can I hide a specific region according to its url?
I need to hide the footer region on all pages with url /people/. Something like with the blocks you put show only in /people/*.
0
votes
2
answers
55
views
How do I change the input type created by views daterange filter?
I am using a view created with the views module. The view displays all change requests, and I wanted to expose a filter to users to be able to filter the change requests by date.
The change requests ...
1
vote
0
answers
54
views
How to prevent HTML entity encoding in Drupal attribute objects?
Is there an easy way to disable the HTML entity encoding of CSS class names?
When I create CSS classes with ampersands or the "larger than" symbol (which might look strange but is ...
0
votes
0
answers
35
views
How do I style the tooltip that displays element title on hover?
Background
I am building a custom Drupal theme for my site. For the most part, the styling is pretty straight forward, but I am struggling to find what js or css controls what appears to be a tooltip ...
1
vote
1
answer
150
views
Upgrade to Drupal 10.1.6, Theme Doesn't Load Outside Maintenance Mode
I'm working to upgrade a site from 9.5.11 to 10.1.6. I followed the instructions provided here:
https://www.drupal.org/docs/upgrading-drupal/upgrading-from-drupal-8-or-later/upgrading-a-composer-based-...
0
votes
1
answer
71
views
How can I render only a region in a controller?
I'm looking to have a page on /templates/header which only renders what there is in the header region of the theme. I am using the following code for a custom controller.
namespace Drupal\...
0
votes
0
answers
64
views
I can't manage to render empty fields
I have a custom template file for List (text) fields. I need to display these fields using the Layout builder module.
Everything works perfectly, until no value in those fields is selected. (The ...
1
vote
1
answer
67
views
Stylesheets not loading
Has anyone successfully dealt with this kind of error? [Error] Did not parse stylesheet at 'https://*****.***/core/assets/vendor/jquery.ui/themes/base/core.css?s2pf9q' because non CSS MIME types are ...
0
votes
1
answer
49
views
How to hide a region in a node (most preferably without a module)?
I want to hide the sidebar region only in my homepage.
CSS display:none for the sidebar region is not enough because main content won't expand to cover the actual region so I think about using a ...
0
votes
0
answers
53
views
View breaks the page output
Has anyone encountered this problem or can at least help me debug it?
The views is displayed as standard if the parameters are specified.
Format:Unformatted list | Settings
Show:Field
If I change it ...
0
votes
1
answer
53
views
Image field and links not showing in view block template
I have a CT team_members with the following fields.
field_team_member_image
field_team_member_name
field_member_designation
field_social_media_links(Multiple values with links to twitter, instagram,...
-4
votes
1
answer
49
views
building a subtheme using stark as the base theme but getting this error in the info.yml
i keep getting this error. The error goes away when i remove the info.yml file from the subtheme. I upload the subtheme in the root theme directory. I've added the error message along with the info....
1
vote
1
answer
33
views
How can I get the numeric ID for a block from within the block template or hook_preprocess_block?
How can I get the numeric ID for a block from within the block template or hook_preprocess_block().
By numeric ID, I mean the ID that we see in the edit link for a block. For example, mysite.com/...
0
votes
1
answer
59
views
file_url() produces no output [duplicate]
I have a custom block, and a block--inline-block--hero-video.html.twig template file. The block has a field_video field.
If I put {{content.field_video[0]}} in my theme, the output is the following (...
1
vote
2
answers
158
views
Why can't I disable CSS caching?
Background
I am developing a custom theme for my Drupal 10 site. I found myself constantly flushing the cache, so I have been looking up ways to disable the cache on my local dev site. My end goal is ...
-2
votes
1
answer
37
views
View not showing result based on taxonomy term contextual filter
I have a view and same in D7 and same I created in Drupal 10 but the output is not as expected. I found in Drupal 10 we don't have Filter Value type in Drupal 10
Below is the Drupal 7 view query:
...
0
votes
0
answers
42
views
Does disabling the Drupal cache also disable the CSS Cache? [duplicate]
I am having trouble disabling caching in Drupal 10. To be more specific, I am trying to disable the cache using the Admin interface so that I don't have to manually edit any files in case I ...
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 ...
0
votes
1
answer
50
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\...
1
vote
0
answers
28
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 ...
0
votes
1
answer
73
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 ...
2
votes
2
answers
235
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.
...
0
votes
1
answer
16
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:
$...
0
votes
0
answers
21
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/...
0
votes
0
answers
105
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 "...
1
vote
2
answers
85
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 = $...
0
votes
1
answer
119
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 ...
0
votes
1
answer
215
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 %}
{% ...
0
votes
1
answer
51
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(&$...
0
votes
1
answer
374
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 ...
0
votes
1
answer
161
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 ...
0
votes
1
answer
145
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 ...
-1
votes
1
answer
102
views
Content type with 3 paragraphs fields: How can I output to different parts of page.html.twig?
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/...
-3
votes
1
answer
50
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-...
0
votes
1
answer
43
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/...
0
votes
2
answers
55
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'] }}...
-1
votes
1
answer
310
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 ...
0
votes
0
answers
17
views
How do I add cusom settings for the "Rendered entity" view mode?
When using the "Rendered entity" field formatter for an entity display, there's a dropdown where you can select the View mode.
Is there a way (programmatically or otherwise) to add settings ...
0
votes
1
answer
43
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 ...
0
votes
1
answer
87
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 ...
4
votes
2
answers
205
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(...
0
votes
0
answers
26
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 ...
0
votes
1
answer
104
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-...
0
votes
1
answer
29
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 ...
0
votes
0
answers
35
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 ...
0
votes
1
answer
227
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 ...
0
votes
1
answer
80
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 ...