- 5.8. New instructions
5.8.9. Instruction plugins - 5.8.8. Tips and tricks
« Previous - 6. Migration
Next »
5.8.9. Instruction plugins
Instructions can be packed as plugins, however, they need a more sophisticated format. Open Power Template requires the instruction plugins to:
- The file name must be in the format:
instruction.Foo.php - The class name must be in the format:
Opt_Instruction_Foo, whereFoomust be the same, as in the file name.
A sample instruction plugin can be found below:
<?php // instruction.Plugin.php class Opt_Instruction_Plugin extends Opt_Compiler_Processor { // ... } // end Opt_Instruction_Plugin;
Note that you can also register the instruction manually:
$tpl->register(Opt_Class::OPT_INSTRUCTION, 'Foo'); // Registers "Opt_Instruction_Foo" $tpl->register(Opt_Class::OPT_INSTRUCTION, 'Foo', 'Some_Class'); // Registers "Foo" in the "Some_Class" class
In this case, the class name does not have to begin with Opt_Instruction. The second line shows, how to register such classes in OPT.
See also:
- 5.8.9. Instruction plugins
5.8. New instructions - « Previous
5.8.8. Tips and tricks - Next »
6. Migration