Skip to main content

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
-2 votes
0 answers
31 views

How to print the name of the content type of the node just before the node heading? [duplicate]

I would like to print the name of the content type of the node just before the node H1 heading. I find it good in case the node is part of a very particular series of articles contextwise. <h2>...
0 votes
3 answers
1k views

CSS changes not taking effect in customized styles folder

I am trying to size the banner in a Jackson theme on my site to fit to the 960px wrapper size have in customized folder in sites/all/themes/mytheme/styles/mytheme.css but no matter what I do the ...
1 vote
1 answer
567 views

Theme settings to include different PHP files into template

I'm trying to include a template section into another template under conditions based on the themes settings. page.tpl.php <header> <?php $theme_header_style = theme_get_setting('...
0 votes
2 answers
993 views

How can I rewrite the output of image field to become a div with this image as a background image?

I have a view to display a content that have an image field, and I need to display this image as a background image of a div so I can apply some CSS on it. what I tried to do is to rewrite the output ...
0 votes
3 answers
616 views

Styling label of a select list

I want to style the label of my select list with bold font and give it some color. This is the code for rendering form which I am using in a hook_block_view $form['dropdown_first'] = array( '#...
0 votes
0 answers
41 views

How to print variables in Views Field Template

I have a View of Article nodes here which uses this Views field template, copied from core, to target the Article's image field: views-view-field--myarticles--page_1--field-image.html.twig I can see ...
0 votes
1 answer
49 views

How do you theme the book module?

I am rather new to Drupal and am trying to understand how the themes, templates, layouts, and fields work. When editing the content type in the UI on the website for the book type, and "manage ...
0 votes
1 answer
394 views

How can I print the file size and other file info in a Views field template?

I have created a content type with a number of fields including file fields. In the node template for that CT (node--unit.html.twig) I am able to get the details with the following code: {% if ...
0 votes
1 answer
494 views

Image Styles not creating on one custom style only

I've run into this issue where we have created a custom style (emailthumb) which is to be used when sending out email newsletters via simplenews. The thumbnail is based on 'thumbnail' style but is ...
0 votes
1 answer
509 views

Is there a way to change how a form button looks?

I know how to add a class to a form element and how to add a form submission button, but there are classes that are automatically added to these buttons in my Drupal 8 install. The form I am editing ...
0 votes
4 answers
1k 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') { ...
0 votes
2 answers
423 views

How do I add a region to the Color module?

I have a menu I would like to be able to style with the Color module. I have found many examples for the Drupal 7 Color module and they have led me to believe that if I just add a line to the 'fields'...
0 votes
1 answer
2k views

Rewrite markup of a field in twig template

I want to calculate dynamical a value and give it back in the markup without saving the newValue. I try this with: {% set content.field_my_field[0]['#markup'] = newValue %} This doesn`t work! The "...
0 votes
2 answers
903 views

Add target blank to an image link

How do I add target='blank' to a href in a Drupal 8 custom module? Below I have the image being wrapped by the uri. I don't know how to add target='blank' $element[$delta] = array( '#theme' ...
1 vote
1 answer
412 views

Customize admin content type page design

i have created template file for my contenttype wallpaper but i don't know how to get form design in that page. for example my content type name is wallpaper, so i create template file for page--...
0 votes
1 answer
1k views

How to add markup inside a form radio button div

Currently I have a form displaying radio buttons and I added some markup to it by attaching #suffix to the form element. However, I found that this didn't do exactly what I needed. This created the ...
0 votes
2 answers
599 views

How to let a user switch between blocks that need to be shown?

I have pre-defined blocks A,B and C that are meant to be placed in the sidebar_first region. What I would like to achieve is: a visitor could select the block that needs to be displayed for the ...
0 votes
2 answers
529 views

How can I theme individual fields?

I have views of ubercart products which are displayed in a table by standard drupal view standards. How can i theme individual product fields ? views-view-field.tpl is having the complete product ...
0 votes
1 answer
851 views

Is it possible to add inline css styling to a twig email template?

Is it possible to add inline css styling to a twig email template? Not as a source file reference but by inclusion of css within the template similar to html <style>...</style>...
1 vote
1 answer
673 views

How to use HTML in a webform component's title?

We have a checkbox which's title should have HTML (<sup></sup>) but its rendered as text rather than HTML. How to use HTML in a webform component's title?
0 votes
1 answer
471 views

How to pass theme variables in #theme in a form element?

I need to pass product variable defined in hook_theme() and invoked in #theme but not sure how to pass product variables in #theme Please suggest. function storeinv_theme() { return array( ...
0 votes
1 answer
778 views

How to modify the commerce price formatter label to match shipping service?

Please see attachment. Using Commerce Kickstart 2. I have a working solution, but I am hoping someone can tell me how to improve it, as it 'feels' poor. The footer for the default shopping cart view ...
1 vote
2 answers
741 views

Why is my library not attached when programmatically rendering a block?

I have this block: public function build() { $build = [ '#attached' => [ 'library' => [ 'mymodule/mylibrary', ], ], '#markup' => '<!-- see template -->...
2 votes
2 answers
3k views

how to dynamically set query parameter on menu item

Hello I am a very experienced web dev who is brand new to Drupal and learning to build my first site in it. I have a very simple site I am converting from pure code (html, css, jquery, angular, ...
0 votes
2 answers
769 views

How to display the pager on top and bottom of a custom search results page?

I have used the core Search Page functionality in Drupal 8 to built a search engine on my site. The pager is displayed at the bottom by default. How can i display the pager on the top also? Note: I ...
2 votes
2 answers
2k views

Altering nodes title value

I am trying to alter the title of my nodes to prevent URLS appearing in any title. This is the code I am using. function mytemplate_preprocess_node(&$variables) { $node = $variables['node ']; ...
1 vote
1 answer
584 views

How can I add styles attribute to Global Custom field markup?

I have created a view to display my articles and I would like the article thumbnails to be used as background. So I added the different fields I've hidden. I added a relationship to the image field ...
1 vote
3 answers
2k views

Views to use relative paths for image fields

How can we tell views to use relative paths for dispalying images using image fields. I have created a views slideshow which is displaying images using absolute url which is causing the images to ...
2 votes
1 answer
490 views

jquery.ui libraries-override > Incomplete library definition

I tried to remove the core jquery.ui theme.css by writing into mytheme.libraries.yml the following lines. libraries-override: core/jquery.ui: css: theme: assets/vendor/jquery.ui/...
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
124 views

CSS Junk files in the css folder

What are all those junk CSS files in site/files/css with names like css_ZFCUUB6IIfaVQ-erWDr0M0Na1JbxEsU-8zjQrWAtrbU.css? There are hundreds of them. How do these get generated over time? What do they ...
0 votes
1 answer
488 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 ...
4 votes
3 answers
487 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
1 answer
552 views

Preview is not showing after upload

When i am trying to upload image as a Authenticate user, After upload i am not able to see preview. fields got disappear fully. If i try to do as a admin, i am able to see that. Any suggestions?
0 votes
2 answers
853 views

Author image in comments twig

I succesfully get user name, surname and date to render in comment.html.twig like this function MYTHEMENAME_preprocess_comment(&$variables) { $comment = $variables['comment']; $variables['...
2 votes
1 answer
478 views

Add inline widget to product display

I am trying to integrate our Drupal 7 Commerce install with Digital River's where-to-buy widget. All I need to do is add a little JS to the product page, with a script variable set to the product sku....
2 votes
1 answer
634 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 }}...
0 votes
3 answers
514 views

Remove separator from breadcrumb

How can I remove the < from the breadcrumb I tried implode('<', $value['data']) but no luck function bootstrap_fit_breadcrumb($variables) { $breadcrumb = $variables['breadcrumb'];...
0 votes
0 answers
24 views

Closing div at start of twig template is removed at render

Issue Overview: I have a entity embed container that is added in ckeditor. Theres a custom template suggestion that renders the template. For styling reasons, I need to close out the wrapping div ...
1 vote
1 answer
496 views

How to wrap / manipulate element outputs on a form's checkboxes html?

I have the following form that contains a big list of checkboxes. The first checkbox is the parent of the children below it. In my case it is called "Africa" and the ones below it are "Africa-child" ...
0 votes
2 answers
838 views

Issues with Zen subtheme

I am running a Zen subtheme for another drupal instance and it all worked fine. However, when I copied the folders across to my new Drupal instance, all I see is The name of the site and User menu :...
0 votes
2 answers
1k views

Provide a default image for image field programmatically at theme level

I have an image field on a node, which will not always be populated. In the case where the field is empty (no image), I want to alter the markup to display a random image which always exists in a ...
7 votes
1 answer
787 views

When can uid 1 get an access denied page?

I am having a very strange problem that I can't track down. We have been working on a custom site for a client now for several months. Theme is a Zen subtheme. I can't remember the last time I ...
0 votes
2 answers
598 views

Adding checkbox in admin table display

I'm trying to add a checkbox column in the admin table part of my module. The idea is to add checkboxes at the beginning of each row, like in the normal admin content management form. My table is ...
0 votes
2 answers
2k views

Altering Views Exposed Form Elements and their Associated Labels

I have a series of Views Exposed Forms across a Drupal 8 website. My goal is to generate unique template suggestions so I can theme each individual input and their labels differently as needed. Here ...
-2 votes
1 answer
43 views

contextual menu module - error 400 on URL /contextual/render break contextual links on a limited number of pages

on a fully developed drupal, some contributors noticed me that the contextual menu links are broken on a limited set on pages. After a quick check i see that all those pages have a broken XHR request ...
0 votes
1 answer
482 views

Drupal Array to string conversion hook

I am trying to change the links of the Language Switcher module. I am using the following code, but it doesn't work. function mytheme_links__language_block(&$variables) { // Change variables ...
1 vote
1 answer
1k views

Can't load library path files

I have added a library to the libraries folder. I have the Libraries API module installed and I wrote this code: function my_module_libraries_info() { $libraries['google-api-php-client'] = array( ...
16 votes
2 answers
7k views

How to make a theme hook suggestion for blocks according to region?

Since Drupal 8 it is not possible with template naming conventions to load a specific block template according to the region it is placed in ("Per-region block markup and per-region block templating ...
0 votes
2 answers
2k views

Use of Twig template for webform email

I'm trying to help my father out by building a webform (D8 version) for the 4 theaters his Old Abbey Friends are putting up. I've made the webform, now i'm setting up an email handler so that ...