Themes

Theme's folder's structure

Theme consists of the following folders and files

/templates -- templates for page's generation
  navigation.tset.phtml -- template for menu
  index.tset.phtml -- template for index
  message.tpl.phtml -- template for system's messages
  master_layout.tpl.phtml -- header for all templates, contains
                             head section, common for all html files
  html_layout.tpl.phtml -- template for standard view in html
  singlepage_content.tpl.phtml -- template for page inside the single html-file
  singlepage_layout.tpl.phtml -- template for single html file
  chm_layout.tpl.phtml -- template for CHM output

/web -- images, icons, css, javasript

Template is an HTML text with special variables like:

<?php echo $content; ?>

Templates for standard view (html) and CHM

The following variables are available in templates master_layout.tpl.phtml, html_layout.tpl.phtml, singlepage_content.tpl.phtml, chm_layout.tpl.phtml:

path
Path to the current page, i.e., layout/teme.html
bookTitle
Book's title
bookData
Array with options from book_data.yml
pageData
Page's options array from table of contents
rootPath
Path to the book's directory. There is title page in $rootPath.'index.html' file.
rootURL
Link to the book's title page: $rootPath.'index.html'
bookShelfURL
Link to the bookshelf
editURL
Link to the current page's edit interface
editTocURL
Link to the table's of contents edit interface
assetsURL
Link to the folder with the assets: images, css and js
level
The level of current page in the table of contents. 0 -- is the root level
next
Array, containing next page's title ('title') and link ('href'). It could be null if there is no next page (i.e. current page is the last one).
prev
Array, containing previous page's title ('title') and link ('href'). Could be null if there is no previous page (i.e. the current page is the first one)
menu
Current level's menu
upLevelLink
Link to the parent chapter
upTitle
Array with parent chapters titles
curTitle
The title of the current pages
content
Processed page's content
mode
System's mode: export to the html-static or the web-server(default)
editMode
Allows page's edition through the web-interface if true
outputMode
Output mode: html (default), html_single (to one big file), chm (to the chm project)

Export to the single html-file

There is special template for this output, — singlepage_layout.tpl.phtml. The following variables are available:

content
Page's content processed
bookData
Book's parameters array from book_data.yml

Another template, you need is master_layout.tpl.phtml, where the following variables could be used:

assetsURL
Link to the assets folder (images, css, js)
bookTitle
Book's title
outputMode
Output mode: html (default), html_single (single html file), chm (chm project)
content
All book's pages content in one variable

Navigation

Navigation's template is located in navigation.tset.phtml file, and is sectioned template. System calls sections while building menu's fragments. Example template:

<!-- #menu_topic# -->
<li><a href='<?php echo $href ?>'><?php echo $title; ?></a></li>
<!-- #active_menu_topic# -->
<li class='active'><?php echo $title ?></li>
<!-- #toc_topic# -->
<div style='margin-top: 7px;margin-left: <?php echo 20*$level; ?>px'>
<a href='<?php echo $href ?>'><?php echo $title; ?></a>
</div>
<!-- #toc# -->
<div style='margin-top: 0px;margin-left: 40px'><?php echo $content; ?></div>

Variable outputMode (html, html_single, chm) is available from any section.

In menu topic's and TOC topic's sections (menu_topic, active_menu_topic, toc_topic) variables link ($href) and menu topic's title ($title) are available. In the TOC section (toc) the TOC's content is contained in $content variable.

Index's template

The template is located in index.tset.phtml and looks like the following:

<!-- #indexTopic# -->
<p style='margin: 0'>
<?php echo $word; ?> <span style='font-size: x-small'>
<?php foreach ($pages as $page): ?>
[<?php echo "<a href='$rootPath{$page['path']}'>".$page['title']."</a>" ?>] 
<?php endforeach; ?>
</span>
</p>

<!-- #indexSection# -->
<div style="margin-top: 30px">
<p style="font-weight: bold;margin-bottom: 5px"><?php echo strtoupper($curLetter); ?></p>
<?php echo $buffer; ?>
</div>

As usual outputMode variable (html, html_single, chm) could be accessed from all sections

In indexTopic section one can use variables:

word
word for index
pages
paegs, corresponding to the word in array form. Each array element contains page's title (title) and the page's path (path)
rootPath
URL of the books folder, i.e. full page's URL is built like this: $rootPath.$page['path']

In indexSection part $curLetter (The first letter of the words is currently grouped) and $buffer, which contains block of words, grouped by the first letter

System message's template

This template is for displaying messages like "index is successfully rebuilt" with "Back" button. The following variables are available:

assetsURL
Assets folder's URL
bookTitle
Book's title
errstatus
Error status: error, notice or success
message
Message
backLink
Link to the page, which calls this message

String functions

If you're plan to use your theme with both singe and multibyte encodings use special string functions instead of standard ones:

 
//to lower case
function colesoStrToLower($str);
 
//to upper case
function colesoStrToUpper($str);
 
//substring, 
//if length==null, then substring to the end of original string
//will be obtained
function colesoSubstr($str, $start,$length=null);

© H-type, 2008
www.bulldoc.ru