Questions tagged [theming]
Use it for questions about rendering or modifying the HTML markup produced by a module/theme.
10,683
questions
0
votes
0
answers
20
views
How to unfold the main menu on Olivero?
I have a web site with Drupal 9 and the Olivero default theme.
I created submenus in the main menu.
On desktop no problem, but when the header goes into mobile mode, I want the menu to display the ...
-3
votes
1
answer
50
views
How can i preprocess variables php to js
Hello everybody I'm new to Drupal and I'm working on a new payment module. This module provides a block and I need to pass some variables from the controller to the blocks twig template.
I have a ...
0
votes
1
answer
21
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
37
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
32
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 &...
-3
votes
0
answers
23
views
Throbber effect is not working in custom ajax call [closed]
I am trying to implement a throbber effect on custom ajax call but throbber is not working
function my_details_table(public) {
var my_params = '?public='+ public;
var my_table_url = '/admin/public'...
0
votes
1
answer
38
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 ...
-2
votes
0
answers
15
views
Drupal 9 "Add to cart" theming hide color attribute from custom display view
I need little assists,
I am following Commerce 2 "Add to cart theming" Link
And I cannot hide my custom display view the "color" attribute, what's wrong with it?
{#
/**
* @file
*
...
0
votes
1
answer
20
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 ...
0
votes
1
answer
38
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 ...
0
votes
0
answers
23
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
38
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
19
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() ...
0
votes
0
answers
47
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 ...
-2
votes
0
answers
23
views
PDF template page numbers
I am currently trying to insert page numbers to generated PDFs.
I tried the following solution with CSS counters, in the entity-pring.css file.
.page {
padding: 20px;
}
.page img {
max-width: 100%...
0
votes
0
answers
65
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 ...
0
votes
1
answer
24
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
19
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 ...
0
votes
2
answers
21
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
62
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
vote
1
answer
80
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
236
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 ...
1
vote
1
answer
30
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 ...
1
vote
0
answers
27
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 ...
0
votes
1
answer
39
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
27
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 ...
0
votes
0
answers
39
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
129
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) ...
1
vote
0
answers
30
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
28
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
70
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
57
views
Cannot make page--node--nid to work
For a node whose content type is Page and whose ID is 112, I created the page--node-112.html.twig template file, but Drupal is still using the page--page.html.twig template file.
How can I make Drupal ...
-1
votes
1
answer
15
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
110
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.
...
2
votes
1
answer
37
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 ...
0
votes
0
answers
28
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, ...
0
votes
1
answer
58
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 :...
-1
votes
1
answer
63
views
View plain text field causing rendering issues for translations
Our news section has a plain text field for article header. At the time of development this seemed like a good idea, however, having gone live, some languages like French has special characters which ...
0
votes
2
answers
68
views
How do I add HTML markup to the title?
I am trying to alter my title to include html. I have tried the following
function MODULENAME_views_pre_render(\Drupal\views\ViewExecutable $view) {
if ($view->id() == 'products_test') {
...
1
vote
0
answers
45
views
Need help regenerating images after image cache flush
TL;DR - Flushed image cache for an image style that is used in basically every blog. They are not regenerating on page load. They regenerate when i edit and save the node. Looking for ways to ...
0
votes
0
answers
70
views
How to render html video body in twig
I have following code in my CustomVideoBlock.php file
foreach ($video_result as $video){
$title = $video->title;
$video_body = $video->body_value;
}
$video_data = filter_var($...
0
votes
1
answer
39
views
Twig Template - Div Element Being Inserted in Link URL [duplicate]
I have a link field type that I'm referencing in a Twig template. I'm using this code:
<div class="outlined">
<a href="{{content.field_3_column_image_link}}">{{content....
0
votes
0
answers
51
views
How to target a specific table with Twig on a specific page?
I have a table I would like customize in CSS but first need to target it with Twig. The problem I am running into is that the twig template is global so it is for ALL tables. If I edit this table with ...
0
votes
1
answer
38
views
How to add a boolen attribute to a form?
I am trying to add the boolean attribute "novalidate" to all my forms.
I have tried numerous approaches in my theme_preprocess_form function but no luck. I see in some preprocess functions, $...
0
votes
1
answer
116
views
Check if a field is empty inside a twig paragraph template
I know how to check if a field is empty in a twig template (example node--lorem.html.twig):
{% if node.field_lorem.value is not empty %}
<p>not empty</p>
{% else %}
<p>...
0
votes
1
answer
125
views
How to render a view in a custom twig template?
I created a custom twig template to override views-view-fields in an unformatted view. What I would like to do is get rid of the rendering loop and explicitly display the variables in certain ...
0
votes
0
answers
39
views
How to theme a paragraph form
I would like to create a twig template for the form displayed inside the paragraph widget.
The only way I found is:
function mymodule_field_widget_paragraphs_form_alter(&$element, &$form_state,...
0
votes
1
answer
23
views
Referencing media from theme settings and display it on front page
In a custom subtheme of classy base theme, I made a theme setting for referencing an image media file. Contents of file theme-settings.php:
<?php
use Drupal\Core\Form\FormStateInterface;
use Drupal\...
0
votes
0
answers
40
views
hook_theme_suggestions_node_alter() doesn't work for new files
I implemented hook_theme_suggestions_node_alter() and added a new suggestion for a custom template file. In the inspector, I can see the suggestion is picked up. I created that file, but it doesn't ...
0
votes
0
answers
34
views
Getting error while adding/rearranging sort in Views. Drupal\Core\TempStore\TempStoreException: Couldn't acquire lock to update
I am trying to add/rearrange a sort criterion in view in drupal 8.x, but getting error - Drupal\Core\TempStore\TempStoreException: Couldn't acquire lock to update item 'search' in 'tempstore.shared....