Questions tagged [drupal-templates]

Theme templates are part of Drupal's theming system and allow for the customization of Drupal sites.

The template files are files used in Drupal to render a page, or part of a page; for example, Drupal uses a template file to render a node, and third-party modules can use a template file for their own pages, or for the theme functions they implement.

87 questions
8
votes
3 answers

How does hook_theme() work?

I am having a hard time understanding what hook_theme() does. My understanding is that it has something to do with making it possible to override templates. I was looking at: $theme_hooks = array( 'poll_vote' => array( 'template' =>…
Chris Muench
  • 17,444
  • 70
  • 209
  • 362
8
votes
2 answers

Using preprocess hook on specific node type in Drupal 8

I've had success using preprocess page hooks such as: function mytheme_preprocess_page__node_front(&$variables) { ... } and function mytheme_preprocess_page__node_12(&$variables) { ... } which correlate with custom templates named…
ConorBaumgart
  • 493
  • 1
  • 3
  • 18
6
votes
1 answer

Drupal Token Replacement in Template File

Can I use token replacements in Drupal template files? I'm trying this: $author_uid = "[node:author:uid]"; $nid = "[node:nid]"; But it's not working. How can i properly use token replacements in my node.tpl.php template?
hanleyhansen
  • 6,304
  • 8
  • 37
  • 73
6
votes
1 answer

Drupal 7 preprocess_views not working

I have the following code in my Drupal 7 template.php file: function mytheme_preprocess_views_view__videos__videos(&$vars) { drupal_add_css(drupal_get_path('theme', 'mytheme') . "/css/qwembed-jquery-1.0.css"); …
Cybercampbell
  • 2,486
  • 11
  • 48
  • 75
5
votes
2 answers

Drupal 7 views_embed_view and templates

In Drupal 7 created a block view (called *super_gallery*) of grid format added a template specialization views-view-grid--super-gallery--block.tpl.php cleared theme registry cleared all caches Using preview in view editor I can see output modified…
Alessandro Pezzato
  • 8,603
  • 5
  • 45
  • 63
5
votes
5 answers

Adding a JavaScript file

I'm trying to insert reference to the Javascript file in the header by using drupal_add_js(). I placed this line inside the template preprocess function in template.php. The result that the code is not working at all: There is no script link in…
Andrew
  • 1,035
  • 7
  • 22
  • 40
4
votes
3 answers

Core search module, change markup

I want to remove the Search results string added in the search page from line 119 of core/modules/search/src/Controller\SearchController.php. if (count($results)) { $build['search_results_title'] = array( '#markup' => '

' . $this->t('Search…

Patrick
  • 104
  • 1
  • 12
3
votes
3 answers

Drupal 7 comment.tpl.php overwrite for specific node type is not working

I've created a comment--track.tpl.php file in order to theme the comments of my "track" type node but I can't get Drupal to use it. It keeps using my themename/comment.tpl.php file. I made sure to clear cache, I also set the Devel module to rebuilt…
vxcriss
  • 31
  • 1
  • 4
3
votes
3 answers

Accessing the referencing / parent element in twig (paragraphs)

I have an entity reference field inside a (parent-)paragraph, which references multiple child-paragraphs. Is it possible to access field values of the referencing paragraph in the children's (referenced paragraph's) twig templates? Actually I'm just…
3
votes
1 answer

Using Drupal Views VS templating

I have recently started working with Drupal on the side and have had to tackle the limitations I come up against in the Views API. More than not I find it faster and more powerful to code it myself. It is hard to create custom views that have a…
JeroenEijkhof
  • 2,232
  • 2
  • 25
  • 39
3
votes
5 answers

Drupal 7: Template for user registration page?

How would I make a template for the user registration page? I want to theme the entire page, not just the form. I've tried page--user-register.tpl.php but that does not work.
Dustin
  • 4,314
  • 12
  • 53
  • 91
2
votes
1 answer

drupal7 change format of comment's $created

I have been trying for some time now to reformat the date that appears below the avatar when a comment is made to a blog post. I have found no way of doing it through any settings, so I have moved over to the template files. Changing the date format…
2
votes
3 answers

Unique id to recurring field in twig - Drupal 8

I have a Drupal content type that uses multiple referenced entities of the same type (say, "related products") I want to give the title field of every related product a unique ID. It can be the product name, an iterator, the ID of the product's…
Zsolt Balla
  • 533
  • 2
  • 7
  • 16
2
votes
3 answers

drupal_set_message() not working in node.tpl.php template on Drupal 7

My problem is with in node.tpl.php In node.tpl.php, I have also done to find out if the theme template is set correctly. The answer is yes. I also have…
logii
  • 320
  • 1
  • 3
  • 15
2
votes
1 answer

Override item-list.html.twig & time.html.twig inside a view

I've created a view that outputs a
    with a