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

Optimized images in custom theme

All of the image optimization modules are for images you upload through the admin portal as an Image content-type, but how would one optimize images that are in your images folder in your custom theme?...
0
votes
0answers
26 views

Drupal TWIG rendoring cleanup

I'm trying to get my head around how twig get rendered out. I just wrapped up working on my first Drupal site, which I really struggled with. So I spun up a local instance, to try somethings out. I ...
-2
votes
1answer
47 views

Why is my custom block template not being picked up?

I am working on a custom slider programmatically. I create a custom module (block_example) and make a block (BlockExample.php) and a twig file (blockexample.html.twig) and also a module file (...
0
votes
2answers
649 views

Views: Multiple Rows & Mutliple Columns

I've been twisting and turning the View module but can't get simple tasks done. Well it should be simple but yet Drupal don't have a good solution ...yet. How to create 2 columns where column A have ...
0
votes
1answer
376 views

How do I get link the files in libraries.yml with absolute url path

In my libraries.yml files the css files are linked with the relative url paths. Eg : /css/mycss.html So when in the page source the linked url shows as relative. How do I link those files with ...
0
votes
1answer
473 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
0answers
29 views

Content translation not working on the front page

I have a translation problem on my site in drupal 9.1.3. I have a content type for my homepage that contains two fields: field_slides which is an EntiyReferenceRevisionFieldItemList to a Paragraphs ...
0
votes
0answers
17 views

Set background picture only within the text field, not the entire page

How should I make the background image appear within the text field (in the Basic page content type) but not the entire page? I am using the Background Image Formatter module, running on Drupal 7 with ...
0
votes
1answer
20 views

Render link in twig with 'entity:node/n' as uri in array

With the module "config pages" I've set some variables global to render in templates. In mytheme.theme I've added a function: function mytheme_preprocess(array &$variables, $hook) { $...
0
votes
2answers
513 views

Default user image in user account menu!

I am trying to add a default image to render in the user account menu when the user does not have an image. CODE: function nestle_preprocess_menu(&$variables) { if($variables['menu_name'] == "...
7
votes
2answers
5k views

How do I theme a taxonomy term page?

I am working on Drupal 8, trying to get a page template for each vocabulary. I have tried using hook_theme_suggestions_HOOK_alter() to achieve this, but I was not able to do it. I tried using Devel ...
3
votes
1answer
535 views

How to get node url/address from entity reference (content type)?

Is there a way to fetch or print the node url/address from a entity reference to my twig template. I have already tried {{ related_links.entity.uri }}, {{ related_links.entity.url }} or {{ ...
1
vote
1answer
75 views

How to put the Bootswatch theme locally?

I am using this sub-theme and I can't find any help. bootstrap-barrio-installation barrio-starter-kit I am currently using Bootswatch Flatly in CDN mode. I want to put everything locally. Here is ...
0
votes
0answers
30 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 ...
0
votes
2answers
2k views

Modify “head-placeholder” in html.html.twig

that's the first time I approach to Drupal or a CMS more generally but I've been working since years as FE dev. I'm creating a theme based on a template created from scratch for the Italian Public ...
2
votes
2answers
1k views

How can I apply different templates based on taxonomy hierarchy?

I'm new to Drupal and I don't have extensive knowledge so I'm hoping I can get this question answered. I want the taxonomy pages of lower hierarchy to be displayed differently from the higher by ...
2
votes
2answers
9k views

How to access session in twig?

I wondering how to access to session in twig ? In my Controller I have this part of code : $tempstore = \Drupal::service('user.private_tempstore')->get('mdm_user'); $tempstore->set('...
0
votes
1answer
1k views

How can I get the module path in twig?

I have a module and created twig templates there. I just followed the documentation here: https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-for-custom-module I want to include a ...
0
votes
1answer
622 views

Insert a collapsible fieldset or region in a panels layout

I created a custom layout for a panels display and I would like to have a region or multiple regions in my custom layout be collapsible with javascript/jquery. Ideally the state of the collapible ...
0
votes
1answer
676 views

Theme file upload form element

I want to theme all the file upload fields on my site but I don't know how to name the template file. I want to alter the form-element.html.twig file but as I have multiple file fields I don't think ...
0
votes
1answer
26 views

Page title and body field of specific page

I have a page--front.html.twig file. I can't figure out how to show a specific node title and body summary on the frontpage with only using twig. I know I can create a view of something like that and ...
2
votes
1answer
3k views

How can I specify inner elements template in custom login page?

I am new in Drupal 8. I want to create a new theme to according to my HTML. What is the best practice to integrating a custom build theme to drupal engine. I have covered all sections in Drupal 8 ...
1
vote
1answer
736 views

Passing variables to JS from theme folder .tpl files

I use many template files in my modules via hook theme. In order to pass variable to JS files I use the method described here: https://www.drupal.org/node/304258 in the .tpl.php files: $my_settings = ...
0
votes
1answer
19 views

I cannot sign into my drupal site. The login page just refreshes and there are no error messages

I cannot login into any account from the login page. I can get to the admin page by doing drush user-login but if I log out of admin and try logging in again, the login page just refreshes and I do ...
0
votes
2answers
1k views

How to set body content using preprocess_node?

I need to alter the body html for a specific content type which will be processed by the Pagination module. I think preprocess_node will work, but I'm having trouble figuring out how to change the ...
1
vote
1answer
622 views

Block Settings not applying to Zen sub theme

I've created a Zen sub theme using the Starter Kit enabled it, and set it as the default (I've changed very little from the Starter Kit). If I go to Structure > Blocks there is only a tab for the Zen ...
1
vote
2answers
4k views

Pass variables from controller to existing node template file

In the Drupal 8 documentation I have found a way how to pass variable from controller to custom twig template https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-...
0
votes
1answer
15 views

Moved Site - Can't find original CSS for look other than in the ADVAGG

I've inherited a drupal 7(I'm a beginner) site that had ADVagg installed. I added a stanza in my nginx config to take care of those files. What I'm running into is that there is a button on the ...
0
votes
2answers
366 views

Print password confirm field in user register template file

I'm trying to theme the user registration form in Drupal 8. I have defined a custom template for user registration form and printing the fields with the following code. {{ form.field_profile_title }} ...
0
votes
1answer
30 views

How can I add Commerce Wishlist share mail template variables from form?

I am trying to add 2 additional form fields to the Wishlist Share form where the user input will be rendered in the email. I have been able to add the fields to the form, but I am not sure how to add ...
1
vote
1answer
49 views

how to create template suggestion for image like image--NODE-TYPE--VIEW-MODE

I'm trying to create a suggestion like image--NODE-TYPE--VIEW-MODE, but in mytheme_theme_suggestions_image_alter() $vars i haven't node related info thanks for help
9
votes
5answers
12k views

How can I count a multivalue field's values in twig?

I want to count the number of values of unlimited field in twig tempalate I tried {{ node.field_mytext.count }} => faced with error and in another try {{ content.field_mytext.count }} => nothing ...
1
vote
1answer
2k views

How do I get navigation menu on top with narrow viewport?

I'm running Drupal 7.28 with Zen 7.x-5.5. In the default setup, there is a region on the right side named "First sidebar" which contains a block named "Navigation". I have put my navigation links ...
1
vote
1answer
1k views

jQuery dialog is duplicated when set on a form that uses AJAX

Im using jQuery dialog on my form. Drupal.behaviors.custom = { attach: function (context, settings) { $('.form-container').once('form-cont', function () { Drupal.custom.modalLinks(); })...
0
votes
1answer
1k views

Getting values on twig node template

I have installed ECK module in my website. Using it I have created a "report eck" entity in which I have different bundles like section, notes, etc., each containing different fields. I have my ...
1
vote
0answers
9 views

Access custom block link field url in twig template

I have a custom block with four fields like this : I want to display in twig the value of image's uri. I've tried something like that in field--block-content--field-linkedin-link--rs.html.twig ...
-2
votes
1answer
37 views

Is there a way to sort view asc or desc using twig

Is there a way to sort view asc or desc using drupal_view('vn', 'vmn', sort order) in twig or Can sort we views_embed_view() in controller
0
votes
2answers
369 views

theme_debug doesn't work

I wrote into my settings.php file (into default.settings.php file too): $conf['theme_debug'] = TRUE; $settings['theme_debug'] = TRUE; $settings['theme_auto_reload'] = TRUE; (These files have 777 ...
1
vote
1answer
731 views

JS not work in bootstrap subtheme

I am using bootstrap 3.6 sub-theme/cdn, I've added scripts[] = js/custom.js and I can see it in the source code of the page. But... javascript is not working. I copied some javascript code modules ...
5
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 ...
1
vote
2answers
545 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 -->...
1
vote
3answers
74 views

How can I override the markup of a view I printed in a template file?

I installed the Twig Tweak module on my site to render Views on the home page. I want to make the display mode frontpage_tasks for the current user, his account, his stores and his groups. {{ ...
3
votes
3answers
3k views

How to add extra classes to <div view-content> in Views?

Is there a way to add an extra class to the View content wrapper, which outputs as <div class="view-content">? To make it clear: I use Semantic views to generate a nice UL for a slider, but I ...
1
vote
1answer
846 views

How can I add a separate template for the user login form?

So I want to create a separate user login page for my website. I create a twig file called page--user--login.html.twig which is great for the outer container. I still want to edit the form divand or ...
1
vote
4answers
1k views

How to change the markup for a field

I'd like to change the output from the field formatter view from the Field API. I'd like a cleaner markup without unnecessary tags. What's the best way to clean up field formatter view output? Many ...
0
votes
0answers
17 views

How can I render single Simplenews fields in Twig?

I had a Drupal 7 site and I have build my newsletter with print render. Example: print render($build['field_title']); print render($build['field_image']); print render($build['field_description]);...
0
votes
2answers
934 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 ...
0
votes
2answers
35 views

Theme suggestion template is not being picked up

I add template suggestion in my discount module: function discount_theme_suggestions_field_multiple_value_form_alter(array &$suggestions, array $variables) { if ($variables['element']['#...
0
votes
1answer
877 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
1answer
403 views

how to display dynamic field values to template?

I am making a module, each time user make content type and add fields to it, all its field values get rendered into static template dynamically. For This i am using noad_load_multiple() to get all ...