📜 ⬆️ ⬇️

Create a theme for Drupal. Part 3

image
Part 1 , Part 2

Templates


We will add templates to sites / all / themes / mytheme / templates . Create templates page.tpl.php - for pages, node.tpl.php - for content, block.tpl.php - for blocks, comment-wrapper.tpl.php - for block with comments, comment.tpl.php - for one comment, header.tpl.php - for the header, footer.tpl.php - for the basement, region.tpl.php - for the regions. Also, by analogy with preprocesses, we can create files like node-story.tpl.php to display material like story or block-user.tpl.php for the user block. This allows temizirovat separately different types of site content.

I will not give HTML templates. Make up to your taste. I will tell only about the variables available for each template.

page.tpl.php


The main template for the page.
Available variables:

')

node.tpl.php


Content output template.
Available variables:


region.tpl.php


Region output template.
Available variables:


block.tpl.php


Block output template
Available variables:


comment-wrapper.tpl.php


The template block output comments.
Available variables:


comment.tpl.php


Single comment display template.
Available variables:


header.tpl.php


Website header template. We defined all variables for this template in preprocess-header.inc.
Available variables:


footer.tpl.php


Site Basement Template. We defined all variables for this template in preprocess-footer.inc.
Available variables:


What is the result


As a result, we have a very flexible topic. We can add templates for different regions, materials, blocks just by creating a new file. We can add new ones to new templates just by creating a new file and adding a couple of lines to it. We have selected all the regions with separate templates, as well as the header and basement, which allows us not to duplicate their code in the templates for different pages. All you have to do is to create and add styles and scripts to taste (do not forget to write them in the info file).

Where does it come from


Most of the information and ideas are taken from the ZEN and SKY topics.

Successes in creating those!

Source: https://habr.com/ru/post/86463/


All Articles