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
8
votes
1answer
5k views

Restrict content to a user role in a template file

I want to restrict a single node to anonymous users in Drupal 8. I don't want to use any module for it as its useless for single restriction as per me. I know that I can do it with something like ...
6
votes
1answer
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
2answers
7k views

How to create a custom Twig Template for Menu Block

I'm using a menu block to output a section of my main menu into a region so I can have a "In This Section" type of sub menu on every page. Unfortunately, I can't find a way to pinpoint in menu.html....
10
votes
4answers
24k views

Rendering an image field in page.html.twig with a custom image style

I'm trying to set up a slideshow that's unique to each page. The code for this needs to be in page.html.twig. I've got the slideshow mostly working, but I can only call the full image URL, not a ...
5
votes
1answer
3k views

Use a twig template instead of a render array in a custom module admin page

I have a Drupal 8 custom module, and I want to display its configuration page using the admin theme. Usually, for this kind of pages I use, in the _controller property of my route, rather : a class ...
4
votes
1answer
8k views

Render image field from node in page.html.twig

I make my first steps with Drupal 8. I have a site with a header image. On a specific content type "Blog" I want to replace the standard header image with a node specific header image. So in the ...
4
votes
1answer
6k views

How do I add a class to a row based on the value of a field in that row?

I have a view with a page display showing a list of events. I'd like to add a class to the rows of those events that are in the past. The problem I have is that views-view-list.tpl.php doesn't have ...
3
votes
3answers
3k views

Specific field tag based naming conventions (overriding views-view-field.html.twig for specific fields)

I've scoured the documentation and I simply cannot find an answer to this question regarding naming convention for twig files given a tagged view with the override of a specific field. Let me create a ...
8
votes
1answer
5k views

How to programmatically render a contact form in a theme in D8

How to get the side-wide contact form (feedback) individually displayed in a custom block or other page then /contact (e.g. frontpage)? I've tried this code, but it is not working (are contact forms ...
6
votes
5answers
6k views

How do I load a third party PHP library?

I have a third party php library which I would like to use in a module. How do I do that in Drupal 8? In drupal 7, I have done things like the following code, but libraries_get_path() doesn't exist in ...
6
votes
3answers
4k views

Turn off Twig cache

I did Disable Drupal 8 caching during development step by step ( also finally rebuild the cache) but yet my changes in twig files not take effects without rebuild the cache. sites/default/services....
4
votes
1answer
3k views

showing an image field from solr index on custom solr search page

I use the Apache Solr Views module to create a View that displays only items from a specific content type. I would like to include an image as well on the view. I managed to get the images on my site ...
3
votes
1answer
2k views

Installing extra/additional plugins for standalone CKEditor module library

I have the CKeditor plugin installed by itself (i.e. not using WYSIWYG module.) Then, it uses a CKEditor library located in sites/all/libraries/ckeditor. This works fine. I'd like to add more plugins ...
2
votes
3answers
2k views

Using custom JavaScript

Is there a location where I can drop in a custom JavaScript file in Drupal 7.x? It just includes simple event actions for menus, and I don't want to edit the theme/module files. Or do I have to just ...
2
votes
5answers
7k views

Move title display below other fields

When viewing a node, I'd like the Title to display below one of the other fields in the Content Type, but it's not available to arrange in the Manage Display tab. With all of the flexibility and ...
2
votes
3answers
3k views

How to add a class to the image tag

The input in file field.html.twig is normally like this: {% for item in items %} <div{{ attributes }}>{{ item.content }}</div> {% endfor %} And you get the output in HTML like this: <...
5
votes
2answers
15k views

In drupal 7, How to override theme_pager?

I am using drupal 7 and zen theme. And am not able to override the theme_pager using zen_pager function in template.php. Any suggestion pls?
5
votes
3answers
1k views

Add custom class to a particular menu

I need to know how to add extra class to a perticular menu.For example i have custom menu "menu-header-let",This menu is rendering like below, <ul class="menu"><li class="leaf first"><...
4
votes
4answers
10k views

Get node alias in template

I create a about-us with Basic Page content type, and with path alias aliased it to \about-us( nid = 2),Now in template file I want to get path alias <li><a href="{{ ??????? }}">{{ '...
4
votes
1answer
5k views

Set weight for JavaScript files loaded via theme.libraries.yml?

Im loading a JavaScript file via my theme's libraries.yml file. How can I change the weight of this file? I need the file to load before the core and module's JavaScript files. If I set header: true ...
3
votes
2answers
8k views

Preprocess function for node.tpl.php file

I've watched a million videos and read a million tutorials trying to figure out how to create a new variable for use in a version of a node.tpl.php file by utilizing preprocessing functions, but can't ...
3
votes
1answer
2k views

Rename “Read More”

I wanted to rename "Read more" in teaser (node--blog--teaser.html.twig) to something like "Continue" or anything else. How can I achieve this?
3
votes
1answer
722 views

Add class to term-reference output

I'm trying to add a simple class to a link outputted via print render($content['field_tags']). I'm using the Bootstrap theme. These are the approaches I've tried so far: Hooking into ...
2
votes
2answers
4k views

How to preprocess view field?

I have view with one date field. Now I want to preprocess this date field(lets say I want to change the date format). Twig file override : views-view-field--field_date.html.twig Prepocess code I ...
2
votes
1answer
423 views

Override a template for only one route

I want override the region default template. I did that with a hook theme from my module. I want override the region custom template but only for the front page. How can I do that?
1
vote
1answer
1k views

Remove jQuery and find out what is asking it to be included

I'm using drupal 7 and I simply don't want jQuery included at all. It seems like most people are advocating modify the js in a theme hook. That's fine I suppose, but it seems like this is dangerous ...
1
vote
0answers
893 views

{{ directory }} in Twig template in base theme breaks subtheme

Given a base theme called parent that is a child of stable, and a sub-theme called child whose base theme is parent, a Twig template implemented in the parent theme renders the wrong value for {{ ...
3
votes
3answers
4k views

$ is not a function in drupal 7 theme

$(function(){ $('.slider').mobilyslider({ content: '.sliderContent', children: 'div', transition: 'horizontal', animationSpeed: 500, autoplay: true, autoplaySpeed: 9000, ...
2
votes
1answer
2k views

Drupal Commons site has no style after installation

Drupal Commons site has no style after installing it: It looks like campus-24.com. Note the JavaScript and CSS files are in: /home/vhost/WWW/campus-24.com/sites/default/files/js /home/vhost/WWW/...
2
votes
2answers
8k views

How can I remove Javascript files?

I wanted to remove some JavaScript files, since they conflict with my custom JavaScript on my mobile theme. I tried with the following code, but it is not working in hook_preprocess_page(), which I ...
1
vote
1answer
648 views

Popup module is not working in custom front page [closed]

I am using the Popup module. I want to display a particular block content in popup. So I used this module. it's working good except in my custom front page (page--front.tpl.php).I don't know why. My ...
1
vote
3answers
6k views

Load external php library in custom module

I’ve read a lot of topic on this but i can’t figure why it is not working for me. I’ve built a custom module. It is working fine since return $output; in my controller class is working : I can see in ...
1
vote
2answers
566 views

Adding script conditionally

In the module I am developing I need to add script which require jQuery.The will be added depending on configuration settings. Hence I am using template_preprocess_module(&$variables) where I am ...
1
vote
6answers
5k views

How to Override CSS for a core module?

I would like to make some changes to the core toolbar module across all my sites, and I don't want to modify the actual core's css. It looks like I should be able to override the core css found in ...
0
votes
2answers
6k views

How do I render a Twig template and load a CSS file from a controller?

Is this considered a good practice for rendering a Twig template and loading a CSS file from a controller? DefaultController.php namespace Drupal\acme\Controller; use Drupal\Core\Controller\...
0
votes
2answers
3k views

How to create custom menu link wrapper function in Drupal 7?

As you know default wrapper for menu item in Drupal 7 can be modified via function theme_menu_link(). by overriding theme_menu_link($variables) {} function we can modify the rendered html output ...
0
votes
2answers
105 views

file pattern name for content type

What is Drupal 8 file pattern name for a specified content type? Suppose I have a Movie content type. What is the pattern name for its page? Is it page--node--movie.html.twig?
0
votes
2answers
2k views

tb-megamenu how to click to open/close sub menu in mobile

We are attempting to get submenus to only appear when the user "taps" the menu option on a mobile browser. This functionality works good on hover but some mobile devices don't work with hovering. We ...
25
votes
1answer
14k views

Can regions be printed within a node template?

Can regions be printed within a node template, or are regions strictly confined to page templates?
27
votes
4answers
24k views

How can I insert search box in page.tpl?

How can I insert search box(search block) in my theme programmatically?
6
votes
2answers
22k views

Show all nested menu links in Drupal 7

How do I display all nested links in <ul><li> format in Drupal 7? The default code only displays the 1st level links even though they are arranged in the Drupal admin menu as nested: <?...
15
votes
2answers
5k views

Changing the HTML produced by Panels: Is it possible?

I like to use panels, however panels is a pain in the butt to style because of the massive amount of div's it generates. Also the classes it applies to those divs make no sense and are way too bulky ...
25
votes
6answers
45k views

Adding form placeholders to text input fields

Is there a way to convert a regular form and add placeholders with a module, or should this be done with a form template or with jQuery?
11
votes
3answers
22k views

Pass Variable to Custom Block template file

I want to create my custom block with custom content in Drupal 8,in start I create Block with just simple text on it, and work correctly, my Problem is how can I pass my custom variable to it? I saw ...
11
votes
4answers
9k views

How do I theme a link from a template file?

A twig template is rendering a list of links that come with classes. The basic: {{ mylink }} twig code will output something like <a href="#" class="someclass" >the text</a> Not all ...
10
votes
3answers
20k views

How to get an image URL from a field in a twig template

I have a node that contains various fields. I am able to get the values of text fields but not an image field. Below is the relevant output of the node variable being dumped in the twig template: '...
12
votes
1answer
18k views

How to render a template in Drupal 8

I am trying to render a template in Drupal 8. In Drupal 7, I would create a theme with hook_theme, make a templates directory in my module, drop the template file in and I could display it with theme()...
7
votes
1answer
12k views

How to get Media entity image (Entity Reference Field) URL in TWIG theme

Apologies if this question has already been asked. However, in my research I found the answers have been for simple image fields which are in default install of Drupal 8. However, in order to have ...
12
votes
5answers
5k views

Export/Deploy Drupal site/page to static? (no cache)

I wonder if there is an existing module that can help in the subject. I am not looking for a caching module (like Boost or Varnish), but a way to export my whole site (or only certain pages) into ...
12
votes
4answers
6k views

Right way to add JS and CSS to node/edit and other forms

I am making a site with a lots of JS, and I am wondering where I should put the JS code. Optimally I would like to keep the JS with each module and not the theme layer. Some content could be exposed ...

1 2
3
4 5
20