About Sitellite       Screenshots       Downloads       Forge      Documentation       Community       Support

You are here: Home / Documentation / Template Modes

Template Modes

Creating an Alternate Output Mode: DocBook

First, we'll need to create the default template for our new output mode. Save the following DocBook markup to a file named docbook.default.tpl in your template set. In SiteTemplate, you can do this by entering "docbook" in the Output Mode field, and "default" in the Template Name field.

<xt:tpl version="1.0"><xt:xmldecl version="1.0" encoding="UTF-8" />
<xt:doctype
	root="book"
	access="public"
	name="-//OASIS//DTD DocBook XML V4.3//EN"
	uri="http://www.docbook.org/xml/4.3/docbookx.dtd"
/>
<article>
	<articleinfo>
		<title xt:content="head_title">Title</title>
		<abstract>
			<para xt:content="description">Description</para>
		</abstract>
	</articleinfo>
	<section>
		<title xt:content="title">Title</title>
		<para xt:replace="body">Body</para>
	</section>
</article>
</xt:tpl>

Next, we'll create an output filter to translate the HTML in the body field. Save this to the file inc/app/myapp/lib/DocBook.php

<?php

loader_import ('saf.HTML.Messy');

/**
 * Converts various HTML tags to their DocBook equivalents.  Please note that
 * this list is far from complete.
 *
 * @access public
 * @param string
 * @return string
 * @package Myapp
 */
function myapp_docbook_content_filter ($body) {
	$m = new Messy;
	$m->transform = array (
		'p' => 'para',
		'b' => 'strong',
		'i' => 'emphasis',
		'em' => 'emphasis',
		'ul' => 'itemizedlist',
		'li' => 'listitem',
		'h1' => 'title',
		'h2' => 'title',
		'h3' => 'title',
		'h4' => 'title',
		'h5' => 'title',
		'h6' => 'title',
	);
	$body = $m->clean ($body);
	$body = strip_tags ($body, '<para><strong><emphasis><itemizedlist><listitem><title>');
	return $body;
}

?>

Finally, we'll add the following new block to the modes.php file:

[docbook]

content_type    = "application/docbook+xml"
filter 1        = "body: myapp.DocBook"

Our new output mode is now ready to be viewed. You can try it out by going to the following URL in your own Sitellite installation:

http://www.example.com/index/mode.docbook


Page 1: File Format
Page 2: Content Filters
Page 3: Creating an Alternate Output Mode: DocBook
Page 4: Another Quick Output Mode: PDF

All Tutorials

Members

Note: You can use your SitelliteForge.com account here and vice versa.

Username

Password

Forgot your password?

Not a member? Click here to register

Sitellite 5 Beta


Copyright © 2008, SIMIAN systems Inc.
All rights reserved. Privacy policy
Some of the icons on this site were created by the Gnome Project.