Questions tagged [theming]
Use it for questions about rendering or modifying the HTML markup produced by a module/theme.
2,496
questions with no upvoted or accepted answers
11
votes
1
answer
4k
views
How do I use a custom twig template with a render element?
I am fairly new to Drupal 8 module development, so I decided to follow a tutorial at https://docs.acquia.com/articles/drupal-8-creating-elements-theming-elements-and-managing-frontend-libraries, which ...
8
votes
0
answers
1k
views
How do I theme a modal popup?
How can I style Drupal 8 modal window to achieve Instagram style and behaviour?
I'm creating modal through extending ControllerBase class, thus have full control of content. However I can't figure it ...
5
votes
2
answers
3k
views
How to pass a field value as contextual filter argument using Twig Tweak drupal_view?
In Drupal 8, I'm using Twig Tweak to embed a view. I have a contextual filter set to one of the node's fields, field_project_id. If I use a literal for the third argument, it works. If I try to ...
4
votes
0
answers
181
views
Can't make sense of the CSS loading order
I want bootstrap.css to load first, because it's breaking all of my styles. Yet, no matter what settings I use in my module, it always loads last. Every CSS file from a library in my theme loads ...
4
votes
1
answer
362
views
Twig cache files on load-balanced setup
The Twig cache key (twig_cache_prefix) is based the modify timestamp of the Twig template file and a randomly generated key. This gives a problem with a load-balanced Drupal setup where every host has ...
4
votes
1
answer
128
views
Can composer-dependent PHP libraries be used with the Libraries API?
I'm trying to include a PHP library called Geocod.io in my custom module. I am also trying to use the Libraries API. So far I have:
Downloaded geocod.io to sites/all/libraries
composer install'ed in ...
4
votes
3
answers
1k
views
Get field_collection values in field template
I have installed field_collection and have a collection called field_contact,
each entry of which has a field called field_contact_url
I'm trying to customise the display of that field by overriding ...
4
votes
2
answers
2k
views
Adding new rows on a draggable table via jquery
I have a draggable table with preloaded "new items" - sorta like the Power Edit feature of the menu_editor module. Everything works perfect.
However, I want to have a button that adds a new row via ...
4
votes
1
answer
224
views
Why Calling the theme path in a multinlingual site adds a language prefix?
In my template whenever I call the path to my theme in a particular language it adds a language suffix dir like mysite.com/fr/sites/all/themes/mytheme while I'm expecting a path without a prefix (e.g. ...
3
votes
1
answer
1k
views
Site errors out when trying to create a subtheme based on Classy
I'm creating a custom theme in Drupal 9 and am trying to use classy as my subtheme but get the following error:
The website encountered an unexpected error. Please try again later.
Drupal\Core\Theme\...
3
votes
0
answers
146
views
Differences in adding classes to nodes and paragraphs
I'm trying to add some classes to a certain content type.
In mytheme_preprocess_node_contentype() I'm able to use $variables['attributes']->addClass('myclass')
However, in ...
3
votes
0
answers
3k
views
How to preload generated styles and scripts?
I'm trying to preload my main css and js files - these files are generated using the AdvAgg module.
I've tried using the hook_preprocess_html in a theme and in a module, but in the $variables['page'][...
3
votes
1
answer
130
views
How do I capture a page as HTML?
I have a controller that generates a custom 500 page. I have set up a route at the path: '/500'. I would like to capture this as HTML and save as a static file, so that I don't need to bootstrap ...
3
votes
0
answers
140
views
Template name suggestion for multivalue image field in paragraph module?
How can I create a dedicated template name suggestion for paragraphs multi value image field?
The below HTML comments are the theme hook suggestions added by the debug function, for the paragraph ...
3
votes
1
answer
231
views
How to render a @FormElement in Views area plugin
I am doing a custom plugin area for displaying some data in a views footer (Drupal 8).
I do something about just like this : Create a custom area plugin
The only point is, instead of #markup in the ...
3
votes
0
answers
655
views
How do I use the current theme templates to render a node in a module in order to send node content via email?
I'm trying to send a rendered node (which contains multiple entity references) via email for a newsletter.
I'm using workbench moderation and workbench email to manage the different states I need and ...
3
votes
1
answer
144
views
Display comments according to the users roles
I try to create various tabs for my nodes, which show a specific field and the comments of the users according to their roles :
I would like that these tabs are pages, and not in Javascript tabs. ...
3
votes
1
answer
109
views
"Initial Menu Level" config in Block Layout not working
Using Drupal 8...
Goal
There are 2 regions in the header. The top region holds the Level 1 menu links while the bottom region holds the Level 2 menu links (or child links of the top regions).
What ...
3
votes
1
answer
1k
views
Override form.html.twig into module
i need to override a form.html.twig in my custom module.
i used hook_theme_suggestions_alter in my .theme file to add new suggestions.
function MY_THEME_theme_suggestions_alter(array &$...
3
votes
0
answers
2k
views
Trying to set a twig global variable for a function
I have a Twig function in my theme that sets a random ID. The function works well if I include the entire function within any given template and then render the variable for that {{ randomID }} in the ...
3
votes
0
answers
707
views
Theming links in blocks using twig templates
I have a block for the language switcher. I want to override the links in it. I can override a specific language switcher block's markup, and I can override the links markup in all language switcher ...
3
votes
0
answers
2k
views
What Twig variable can i use to view Page Title or Taxonomy Name for a Taxonomy Type page
In Drupal 8 I need a way to get the Current pages title or Taxonomy name/ID.
In the template taxonomy-term.html.twig the variable works:
{{ term.id }}
I need the variable to work in page.html.twig
...
3
votes
2
answers
473
views
Change icon class in "Add to cart" button
I am using Drupal 7, Ubercart, and Bootstrap. The default Add to cart button looks like this:
<button id="edit-submit-270" class="node-add-to-cart btn btn-success form-submit" value="Add to cart" ...
3
votes
1
answer
272
views
Why is 'render element' sometime 'element' and sometime 'elements'?
I notice in Drupal source code, in core modules hook_theme(), some places are 'render element' => 'element' and some places are 'render element' => 'elements' (plural). Why? Even the render ...
3
votes
0
answers
2k
views
8 - Firefox loads JS before CSS, causing flash of unstyled content
My Drupal 8 site will load fine in Chrome and IE, because they both load my CSS before my JS when I look at the Network tab in the console. But when on Firefox, it will load the JS before the CSS. ...
3
votes
2
answers
575
views
How to remove markup from file field
I have added a file field in views and when displaying it has some markup like this
<div id="file-218" class="file file-image file-image-jpeg
contextual-links-region">
<a href="#">
...
3
votes
2
answers
648
views
Link tags in template file auto closing.
I’m having an issue wrapping a link around some output in a template file. I have the right template file; and I can put text like ‘start here’ and ‘end here’ and it prints out where I want the ‘a ...
3
votes
1
answer
319
views
How can can I get theme callback to work for an error page?
I've created a custom error handler for 404 errors (page not found).
I've set up Home » Administration » Configuration » System » Error Pages for 404 errors to point to http://example.com/...
3
votes
0
answers
2k
views
How to update a library through drush or git url? what about update chosen library?
I am new with Drush and git... previously I use to work with Ftp so at the moment I would like to know How I can update a common library by using drush or by using git (library url).
I know that in ...
3
votes
0
answers
189
views
Disable form altering for admin pages on Bootstrap 3
My default theme is Bootstrap but I use Shiny theme as admin theme. Bootstrap theme alters the forms and fields.
And I use Hierarchical Select module, there is a dropbox for multiselection and the ...
3
votes
2
answers
253
views
What to name field collection theme file?
There are several articles here that address theming field collections but none that specifically cover the naming conventions required to actually get them recognized by Drupal.
field--field-field-...
3
votes
1
answer
155
views
Override and add a link to a themed table
Using a custom module, I'm trying to add "Schedule" links to each of the rows of the table on node/%nid/revisions, but can't seem to figure it out. Do I have to override the entire function ...
3
votes
1
answer
225
views
Removing the active language
I'm having some trouble with removing the active language from the Language Switcher Dropdown module. I'm trying to override theme_languageicons_icon() with the following code, but it doesn't seem to ...
3
votes
1
answer
557
views
When reimplementing Drupal.tableDrag.prototype.dropRow(), how do I access classes of would-be parent?
Using code below, I can access classes of a row that's being dropped:
Drupal.tableDrag.prototype._dropRow = Drupal.tableDrag.prototype.dropRow;
Drupal.tableDrag.prototype.dropRow = function(event, ...
3
votes
0
answers
257
views
In tabledrag form, how to prevent certain elements from having children?
I want to use tabledrag to manage 2 kinds of elements. Let's call them branches and leaves. Branch can be parent to both branches and leaves. Leaf cannot be parent to anything. A support for class ...
3
votes
1
answer
348
views
Move drag and drop handle to other side
I want to move the drag and drop handle to the other side of a form, to the same location as the row weight selections. I am talking about the tabledrag handles, as shown below:
I am using ...
3
votes
2
answers
299
views
drupal_find_theme_functions called on every page - is our theme registry being rebuilt?
Our new D7 site was running very slowly so I did some profiling with devel/xhprof and found that D7 was doing millions of preg_grep function calls within drupal_find_theme_functions() in theme.inc. ...
3
votes
2
answers
78
views
Formatting with Views
So I'm using the Views module to list inventory items that include:
Name
Photo
Description
Sales document
I noticed that each item in the view is formatted differently because of size of text, image,...
3
votes
1
answer
451
views
Select an Image style depending on external/dynamic factors (theme region or other field content)
I have a Bean (bundle that generates blocks) which I display in one of 2 different theme regions. Either in the header, or the footer. This Bean contains an Imagefield, which is rendered through an ...
3
votes
1
answer
752
views
How can I theme field collection forms?
I have a field_field_collection in content type (used to field collection module and have unlimited value). It has a number of fields as in the picture below:
And I want customize theme for it as ...
2
votes
0
answers
122
views
Equal-width columns in Olivero
I display an entity reference field that holds 4 images (media items). By default they are displayed in 4 rows one below the other. I want to display them side by side. Olivero is the theme I am using....
2
votes
0
answers
26
views
How do I access current_page value in views twig template?
In views-view.html.twig, I'm trying pager['#views_plugin'].current_page, but don't get any value.
2
votes
0
answers
284
views
How to get content url in views-view-unformatted block template
In Drupal 8, I created template for solr search view views-view-unformatted--solr_search_content--block.html.twig
I am trying to print the content link by {{ row.content['#view'].style_plugin....
2
votes
0
answers
110
views
Theming a file link by adding custom file name suggestions
I want to display a bunch of data inside a view table, where each dataset has up to three different files. The user should be able to download these files by clicking a custom button or image in this ...
2
votes
0
answers
88
views
How do I change layout?
A disclaimer first: I am a professional medievalist, not a programmer or a front-ender. I have some front-end knowledge, but not a lot. So, please, be easy on me.
Now, I am customizing a Bootstrap 4 ...
2
votes
1
answer
353
views
Best practice: Twig logic versus Preprocess functions
I use Twig and Twig Tweak to do most of the processing. However, from time to time I need to rely on Preprocess functions to get the desired result.
This led me to a situation where now most of my ...
2
votes
0
answers
85
views
How do I test for an empty Address webform element?
Using Drupal 9.1.3 : Webform 6.0.0
How to check for the null value of a Webform Address Composite element
{% if webform_token('[webform_submission:values:**ELEMENT_NAME**]', webform_submission, [], ...
2
votes
0
answers
70
views
How to add conditional on Gutenberg's color theme-support?
I've added the Gutenberg theme-support on my custom theme. I want to add conditional based on text color and background color. For example, selecting the black color background will reset the default ...
2
votes
0
answers
183
views
Conditional display mode for entity reference field
i am having a paragraph with 2 fields :
Slider : field_gallery_slider / Booléen
Images : field_gallery_image / Référence à une entité media
How could i change the media display mode if the ...
2
votes
0
answers
78
views
How do you reliably create a GraphQL/Twig theme as a subtheme?
Our theme is built with GraphQL Twig and it's working great. We need to build a subtheme for a different website based on this theme. We're not really having a problem overriding simple Atoms ...