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

	<title>Format plugins - 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]-->
</head>
<body>

<div id="wrap">
	<div id="header">
		<h1>Open Power Template 2.0</h1>
		<h2>Format plugins</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.data-formats.html">New data formats</a> &raquo; <a href="extending.data-formats.plugins.html">Format plugins</a></p>
	</div>
	
	<div id="content"><dl class="location"><dt><a href="extending.data-formats.html">5.7. New data formats</a><br/>5.7.4. Format plugins</dt><dd class="prev">5.7.3. Sections<br/><a href="extending.data-formats.sections.html">&laquo; Previous</a></dd><dd class="next">5.8. New instructions<br/><a href="extending.instructions.html">Next &raquo;</a></dd></dl>	<h1>5.7.4. Format plugins</h1><p>Data formats can be packed as plugins, however, they need a more sophisticated format. Open Power Template requires the format plugins to:</p>

<ul>
<li>The file name must be in the format: <code>format.Foo.php</code></li>
<li>The class name must be in the format: <code>Opt_Format_Foo</code>, where <code>Foo</code> must be the same, as in the file name.</li>
</ul>

<p>A sample instruction plugin can be found below:</p>

<pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// format.Plugin.php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> Opt_Format_Plugin <span style="color: #000000; font-weight: bold;">extends</span> Opt_Compiler_Format
<span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// ...</span>
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// end Opt_Format_Plugin;</span></pre>

<p>Note that you can also register the data format manually:</p>

<pre class="php"><span style="color: #000088;">$tpl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">register</span><span style="color: #009900;">&#40;</span>Opt_Class<span style="color: #339933;">::</span><span style="color: #004000;">OPT_FORMAT</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Foo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// Registers &quot;Foo&quot; from &quot;Opt_Format_Foo&quot; class</span>
<span style="color: #000088;">$tpl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">register</span><span style="color: #009900;">&#40;</span>Opt_Class<span style="color: #339933;">::</span><span style="color: #004000;">OPT_FORMAT</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Foo'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Some_Class'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Registers &quot;Foo&quot; from &quot;Some_Class&quot; class</span></pre>
<h4>See also:</h4><ul><li><a href="extending.plugins.html">5.1. Introduction to plugins</a></li></ul><dl class="location location-bottom"><dt>5.7.4. Format plugins<br/><a href="extending.data-formats.html">5.7. New data formats</a></dt><dd class="prev"><a href="extending.data-formats.sections.html">&laquo; Previous</a><br/>5.7.3. Sections</dd><dd class="next"><a href="extending.instructions.html">Next &raquo;</a><br/>5.8. New instructions</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>
	</div>
</div>

</body>
</html>
Return current item: Open Power Template