Creating a Tag Class
When creating a tag class, you can inherit from one of four base classes:
| Tag Type | Description |
|---|---|
| SilentCompilerDirective Tag | Silent compiler directive tags are instructions for the compiler and do not have corresponding Components. They also do not normally generate output in the compiled template. |
| CompilerDirective Tag | Compiler directive tags do not have corresponding server Components, but they render their contents into the compiled template. |
| ServerComponent Tag | Server component tags have a corresponding server component that represents an API (Application Programming Interface) used to manipulate the marked-up portion of the template. |
| ServerTagComponent Tag | Server tag component tags are ServerComponent Tags that also correspond to an HTML (HyperText Markup Language) tag. |
Here is an example tag class definition:
class CoreIncludeTag extends CompilerDirective {
}
Override Template Methods
After defining your class, you can now override the appropriate TemplateMethods to provide the functionality of your tag. See CodeWriter for information on how to generate code for a template.
Code Generation Methods
preGenerate
function preGenerate(&$code)
Generate Template code before the contents of your tag.
generateContents
function generateContents(&$code)
Generate Template for the contents of your tag.
postGenerate
function postGenerate(&$code)
Generate Template code after the contents of your tag.
Parser Interface Methods
CheckNestingLevel
function CheckNestingLevel
Called by the parser to check for proper usage and nesting.
preParse
function preParse
The result of this method tells the parser whether to parse the contents of this tag. Allowable return values are:
- PARSER_FORBID_PARSING
- PARSER_REQUIRE_PARSING
- PARSER_ALLOW_PARSING
prepare
function prepare
This method is called on your tag when the entire document tree has been parsed. This is an opportunity to manipulate the tree or initialize variables before code generation begins.
Component Methods
The following methods are only used for ServerComponent Tags and ServerTagComponent Tags:
generateConstructor
function generateConstructor(&$code)
Generate code in this method which is used to construct the Component which corresponds to your class
generateExtraAttributes
function generateExtraAttributes(&$code)
getRenderedTag
function getRenderedTag
DataSource Methods
Override the following two methods to make your tag a DataSource:
getDataSource
function &getDataSource()
getDataSourceRefCode
function getDataSourceRefCode
Debugging
Some basic functionality for debugging templates as you develop them is provided by the Dev Source Tag and the Dev Tree Tag.
More Info
For further information see Developing_A_Calendar_Component_Tag and Developing_A_Data_Table_Component_Tag.