Part 1 ,
Part 2Templates
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:
- $ head_title - page title
- $ head - all the information in the head
- $ styles - styles
- $ scripts - scripts
- $ classes - body classes
- $ header - the header we rendered in a separate template
- $ REGION_NAME - variables with region names
- $ messages - system messages
- $ tabs - tabs
- $ content - content
- $ feed_icons - RSS icons
- $ footer - the basement we rendered in a separate template
- $ base_path - base site path
- $ is_front - main page or not
- $ logged_in - whether the user is logged in
- $ is_admin - admin or not
- $ language - an object containing data about the current language
- $ node - node
- $ front_page - link to homepage
- $ logo - logo
- $ site_name - site name
- $ site_slogan - site slogan
- $ mission - the mission of the site
- $ search_box - search block
- $ closure - the variable is inserted before the closing / body tag; some modules write scripts to it. Thanks to habrayuzer juliv
')
node.tpl.php
Content output template.
Available variables:
- $ node - node object
- $ classes - classes for node
- $ user_picture - user avatar
- $ picture - node picture, overridden by modules
- $ page - node page or teaser list
- $ unpublished - published or not
- $ display_submitted - by whom and when published
- $ terms - categories
- $ content - content
- $ links - links
- $ title - title
- $ date - creation date
- $ name - author name
- $ node_url - link to node
- $ comment_count - number of comments
- $ type - material type
- $ uid - author id
- $ zebra - class for zebra
- $ teaser - teaser or whole node
- $ sticky - stuck or not
- $ status - node status
- $ comment - are comments included
- $ is_front - on main or not
- $ logged_in - logged in or not
- $ is_admin - admin or not
region.tpl.php
Region output template.
Available variables:
- $ classes - classes for the region
- $ content - content
- $ region - the name of the region
- $ is_front - on main or not
- $ logged_in - logged in or not
- $ is_admin - admin or not
block.tpl.php
Block output template
Available variables:
- $ block - block object
- $ classes - block classes
- $ title - title
- $ content - content
- $ edit_links - block editing links
- $ zebra - zebra
- $ block_id - block id
- $ is_front - on main or not
- $ logged_in - logged in or not
- $ is_admin - admin or not
comment-wrapper.tpl.php
The template block output comments.
Available variables:
- $ classes - classes
- $ node - node
- $ content - content
- $ display_mode - way to display comments
- $ display_order - display order of comments
- $ comment_controls_state - is there a form for managing comments?
comment.tpl.php
Single comment display template.
Available variables:
- $ classes - classes
- $ picture - author's avatar
- $ title - title
- $ new - new or not
- $ unpublished - published or not
- $ author - author
- $ created - creation date
- $ content - content
- $ links - links
header.tpl.php
Website header template. We defined all variables for this template in preprocess-header.inc.
Available variables:
- $ front_page - main page or not
- $ logo - site logo
- $ search_box - search block
- $ header_line - a region named header_line
footer.tpl.php
Site Basement Template. We defined all variables for this template in preprocess-footer.inc.
Available variables:
- $ footer_line - a region named footer_line
- $ page_bottom - a region named page_bottom
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!