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
Filter by
Sorted by
Tagged with
5
votes
0answers
961 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 ...
4
votes
1answer
1k 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
1answer
257 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
2answers
754 views

Get paragraph delta/weight in template

I have defined a paragraph type that has a text field and an image field. At the moment the twig template is something like this <div class='paragraph_wrapper'> <div class='text-container'&...
4
votes
1answer
114 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
0answers
525 views

What is the use of Drupal.settings.ajaxPageState object?

I am working on a Drupal site on which a functionality breaks because the value of Drupal.settings.ajaxPageState.js gets reset to an empty array instead of an object containing the list of js files. ...
4
votes
3answers
950 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
2answers
1k 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
1answer
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
0answers
223 views

Contextual links in block disabled when using Twig Tweak and UUID

In my taxonomy-term--NAME.html.twig I use a reference field to load a 'block_content'. {% for item in term.field_blocks %} {% set uuid = item.entity.uuid.value %} {{ drupal_block('block_content:'...
3
votes
1answer
610 views

How to change the title of a modal window?

I have a link that displays a modal window. The link redirects to a page view. When I click on it, it is marked in the title of the modal window Array. How to customize the title ? <?php ...
3
votes
1answer
72 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
0answers
159 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 ...
3
votes
0answers
122 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
1answer
185 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
0answers
571 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
1answer
1k views

Manipulating Theme Suggestion Priorities

I'm adding in some theme suggestions using mytheme_theme_suggestions_alter(), when certain criteria is met. My issue is, for some reason these additional theme suggestions are appearing at the top of ...
3
votes
1answer
120 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
1answer
106 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
1answer
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
0answers
962 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
0answers
641 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
0answers
3k 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 ...
3
votes
2answers
480 views

Customize menu local task links

I am looking for a way to customize 'edit', 'view', 'delete' links. I use bootstrap theme, but i use bootstrap v4 styles for it. I want to add 'nav-link' class to each link. And find a way to ...
3
votes
0answers
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
2answers
358 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
1answer
204 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
0answers
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
2answers
551 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
1answer
377 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
1answer
279 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
0answers
1k 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
0answers
188 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
2answers
233 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
1answer
148 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
1answer
224 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
1answer
539 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
1answer
326 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
1answer
427 views

Templating JSON

Is there a Drupal way to template the results of ajax query that returns JSON. The JSON is is being returned to some php module code. If there is not a Drupal way I was thinking of using something ...
3
votes
2answers
288 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
1answer
444 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
1answer
702 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
1answer
70 views

Why is libraries-override not removing assets?

My attempt to remove CSS and JS assets is not working. I have placed the following declarations in my module's *.info.yml file. But after clearing the cache, I still see the assets in the head of ...
2
votes
1answer
27 views

How to add highlighting to exposed views_autocomplete_filter in Drupal 8

Is there a way (a hook perhaps) that would allow me to modify the autocomplete fields returned by an exposed views_autocomplete_filter field? I'd like to style the text typed into the field ...
2
votes
1answer
23 views

How can I theme the markup for the labels in a set of radio options on a specific form item?

Given this form item defined in a custom module; $form['my_items'] = [ '#type' => 'radios', '#title' => $this->t('Items'), '#options' => $optionsSet // array of options pulled from ...
2
votes
0answers
253 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'][...
2
votes
0answers
290 views

How can I use Html::getUniqueID in Twig

The Drupal Twig |clean_id filter calls HTML::getId, which is inferior because accessibility tests fail if your ID appears twice, for example, when the template is placed twice on a page. In the vast ...
2
votes
1answer
101 views

Twig whitespace controls have no effect on fields

I am trying to iterate over a Paragraph field and apply a comma after each Paragraph item. In the field template that outputs the Paragraph, I am trying: {%- for item in items %} {{ item.content }}...
2
votes
1answer
175 views

Avoid random number cached in preprocess hook

I have a random set of images that appear on the homepage which needs to show each time the page is refreshed. My holding page was doing this comfortably in PHP, but since building the whole site and ...
2
votes
1answer
262 views

Adding Price Attributes

I am searching how to add price values to existing product attributes in Drupal Commerce 2.X For Example: T-shirt price = $10.00 A product variation/color = Red = +$2.00 A product variation/size = ...

1
2 3 4 5
50