Location: PHPKode > projects > Open Power Template > docs/Opt/extending.instructions.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml" lang="pl">
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<meta name="robots" content="all" />

	<title>New instructions - Open Power Template</title>
	<link rel="stylesheet" type="text/css" href="design/generic.css" media="all"  />
	<link rel="stylesheet" type="text/css" href="design/print.css" media="print" />
	<!--[if lte IE 6]><link rel="stylesheet" href="design/ie.css" type="text/css" /><![endif]-->	
	<!--[if IE 7]><link rel="stylesheet" href="design/ie7.css" type="text/css" /><![endif]-->

<div id="wrap">
	<div id="header">
		<h1>Open Power Template 2.0</h1>
		<h2>New instructions</h2>
		<p class="generated">@ 02.09.2010</p>
		<p class="location"><a href="index.html"><strong>User manual</strong></a> &raquo; <a href="extending.html">Extending OPT</a> &raquo; <a href="extending.instructions.html">New instructions</a></p>
	<div id="content"><dl class="location"><dt><a href="extending.html">5. Extending OPT</a><br/>5.8. New instructions</dt><dd class="prev">5.7.4. Format plugins<br/><a href="extending.data-formats.plugins.html">&laquo; Previous</a></dd><dd class="next">5.8.1. Processor overview<br/><a href="extending.instructions.processor-overview.html">Next &raquo;</a></dd></dl>	<h1>5.8. New instructions</h1><h4>Table of Contents</h4><ul class="toc"><li><a href="extending.instructions.processor-overview.html">5.8.1. Processor overview</a></li><li><a href="extending.instructions.generating-php.html">5.8.2. Generating PHP code</a></li><li><a href="extending.instructions.parsing-attributes.html">5.8.3. Parsing attributes</a></li><li><a href="extending.instructions.xml-manipulations.html">5.8.4. XML manipulations</a></li><li><a href="extending.instructions.system.html">5.8.5. $system special variable</a></li><li><a href="extending.instructions.data-formats.html">5.8.6. Using the data formats</a></li><li><a href="extending.instructions.node-variables.html">5.8.7. Node and compiler variables</a></li><li><a href="extending.instructions.tips.html">5.8.8. Tips and tricks</a></li><li><a href="extending.instructions.plugins.html">5.8.9. Instruction plugins</a></li></ul><p>Instructions are undoubtedly the most demanding, but also the most powerful way to extend Open Power Template. Most of the library functionality is stored in instructions. In this chapter, we will take a closer look at their architecture and ways to create new ones. However, please note that this requires a bit of knowledge abot the template compiler and how it works.</p>

<h2>How the instructions are handled?</h2>

<p>The instructions are parsed with the <em>instruction processors</em>. From the technical point of view, it is hard to say, what the instruction really is. In fact, a single processor can handle multiple instructions, a single instruction can be handled by multiple processors, a single instruction may consist of several XML tags and a single XML tag in the <code>opt:</code> namespace can be supported by different instructions. In this chapter, we are going to talk about the instruction processors and how you will split the provided features into instructions - it is up to you.</p>

<p>The instruction parsing is very easy. The processor registers the XML tags and attributes it recognizes (they must lie in one of the namespaces registered in OPT, for example <code>opt:</code>) and since then, the compiler redirects all the occurrences of these items to this processor. Now we must generate a suitable PHP code for them.</p>

<h2>What the instruction processors could do?</h2>

<p>Note that the tags and attributes in the special namespaces do not appear in the output. The only signs of their occurrence are the results they produce:</p>

<li>PHP code generation for the template.</li>
<li>Manipulating the XML tree structure.</li>
<li>Manipulating the compiler settings which could affect other processors.</li>
<dl class="location location-bottom"><dt>5.8. New instructions<br/><a href="extending.html">5. Extending OPT</a></dt><dd class="prev"><a href="extending.data-formats.plugins.html">&laquo; Previous</a><br/>5.7.4. Format plugins</dd><dd class="next"><a href="extending.instructions.processor-overview.html">Next &raquo;</a><br/>5.8.1. Processor overview</dd></dl>		</div>
	<div id="footer">
		<p>Copyright &copy; <a href="http://www.invenzzia.org/">Invenzzia Group 2008-2009</a></p>
		<p>Available under the terms of license: <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License 1.2</a></p>
		<p>Generated by <strong>TypeFriendly 0.1.4</strong> by <a href="http://www.invenzzia.org/">Invenzzia</a></p>

Return current item: Open Power Template