My favorites | Sign in
Logo
             
Search
for
Updated Oct 22, 2008 by qhiiyr
Labels: Phase-Implementation, Featured
TemplateDocumentation  
The tutorial for template designers.

Introduction

The template system in Kure is reasonably simple. When processing templates, Kure looks at several files:

admin_footer.html
admin_header.html
doclist.html
doclist_footer.html
doclist_header.html
entry.html
footer.html
header.html
postlist.html
postlist_footer.html
postlist_header.html

These files serve as the structure of the pages they represent. Some, however, will function differently than others.

For instance, the page entry.html will be used for displaying individual posts as well as for displaying individual docs, since their layout is so similar.

On the other hand, some pages -- like the homepage or the doc listing page -- will use more than one template file to be processed. As an example, when viewing the homepage, the first template file to be processed will be postlist_header.html, and the last will be postlist_footer.html. The file postlist.html will actually be processed several times -- one time for each post there is to be displayed.

Conditional Statements

Some of these situations bring up the need for templates to use conditional statements ("if" statements) during their processing. There are three general conditional statements that templates can use anywhere:

{IF:DOCDATES} // true if dates are being shown on individual doc pages
{IF:DOCSPAGEDATES} // true if dates are being shown on the doc listing page
{IF:ADMINLINK} // true if the admin link is being shown

The outcomes of these statements depends on the current configuration of the Kure installation in question. An example of using one of these conditional statements could be:

{IF:ADMINLINK}<a href="admin/">admin</a>{/IF:ADMINLINK}

in which the admin link would show only if Kure's configuration is set to let it show. Note that conditional statements are ended by putting a forward slash after the first brace: {/IF:ADMINLINK}

In addition to these three general conditional statements, the template file entry.html will have two more available to it:

{IF:POST} // true if the current entry being displayed is a post
{IF:DOC} // true if the current entry being displayed is a doc

These will help template authors distinguish between posts and docs when they are creating the entry.html page (which, remember, is used for displaying both posts and docs).

Variables

In addition to conditional statements, templates will have many variables available to them at any given time. Like conditional statements, there are three general, always-available variables for templates to use:

{TITLE} // the current blog title
{SUBTITLE} // the current blog subtitle
{VERSION} // kure's current version

There are also several available to individual pages, listed below:

entry.html
  {ENTRYTYPE} // either "post" or "doc"
  {ENTRYTITLE} // title of the current entry
  {ENTRYADDRESS} // filename of the current entry, without .txt (e.g. "First_post")
  {ENTRYDATE} // preformatted date of the current entry (e.g. "October 22nd, 2008")
  {ENTRYCONTENT} // content of the current entry

postlist.html
  {POSTTITLE} // post title
  {POSTADDRESS} // post filename (as above)
  {POSTDATE} // post date (as above)
  {POSTCONTENT} // post content

doclist.html
  {DOCTITLE} // doc title
  {DOCADDRESS} // doc address (as above)
  {DOCDATE} // doc date (as above)

Hooks

Note: Be sure to read up on hooks before implementing them into a template.

Because templates carry all the weight of display, they also are responsible for setting up hooks throughout their code. Hooks are very simple to attach to templates; the format for their template code is

{PAGE-LOCATION}

So, to put a hook at the top of the doc listing page, you would use

{DOCS-TOP}

To see a full list of Kure's hooks, see the HookList page. Remember to convert them into the proper format before putting them into a template, though -- for example,

$rack['kure']['navdocs_after']

would be

{KURE-NAVDOCS_AFTER}

And $rack['posts']['post-date_after'] would become {POSTS-POST-DATE_AFTER}, etc.

Hooks are an important thing to include in your template, because without them, plugins will not be able to coexist with your code! If you need assistance, the forums are always open.


Sign in to add a comment
Hosted by Google Code