In diesem Tutorial wird die Erstellung und Verwendung von Taglibs erklärt. Dies sind PHP-Klassen, die wie HTML Tags im Template verwendet werden können. Die Lektüre des "DocumentController" Tutorials wird vorausgesetzt.
Um eine Taglib zu erstellen, legt man unter "org/sample" einen neuen Ordner "taglibs" an, in welchem man die Datei "taglib.php" erstellt.
<?php
class sample_tl_SampleTaglib extends cube_node{
function getOutputValue(){
return "taglibs are cool and useful";
}
}
?>
Um diese Taglib nun zu verwenden, muss sie zuerst importiert werden:
<cube:addTagLib namespace="org.sample" file="taglibs/taglib" prefix="tlib"/>
<tlib:SampleTaglib/>
<?@ cube:documentcontroller namespace="org.sample" file="controllers/formcontroller" class="formcontroller" ?> <cube:stylesheet> <cube:addTagLib namespace="org.sample" file="taglibs/taglib" prefix="tlib"/> <html> <body> <tlib:SampleTaglib/> </body> </html> </cube:stylesheet>