Using modifiers: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| (5 intermediate revisions by 4 users not shown) | |||
| Line 4: | Line 4: | ||
as to add or remove attributes to a node before it is loaded. | as to add or remove attributes to a node before it is loaded. | ||
'''Example of using modifiers:''' | |||
Add the following code in your module_preload.inc (if this file is not present, create it in your module's directory): | |||
<syntaxhighlight lang="php"> | |||
$modifiers[] = 'modules.node'; | $modifiers[] = 'modules.node'; | ||
</syntaxhighlight> | |||
In your | In your module.inc: | ||
<syntaxhighlight lang="php"> | |||
class mod_mymodule extends atkModule | class mod_mymodule extends atkModule | ||
{ | { | ||
function module_node_modifier( | public function module_node_modifier($node) | ||
{ | { | ||
useattrib('atkDummyAttribute'); | useattrib('atkDummyAttribute'); | ||
| Line 20: | Line 24: | ||
} | } | ||
} | } | ||
</syntaxhighlight> | |||
Latest revision as of 07:44, 10 February 2010
|
ATK Howto: Using modifiers
|
Modifiers allow you to modify nodes on before they are used. Making it possible to do such things as to add or remove attributes to a node before it is loaded.
Example of using modifiers:
Add the following code in your module_preload.inc (if this file is not present, create it in your module's directory):
$modifiers[] = 'modules.node';
In your module.inc:
class mod_mymodule extends atkModule
{
public function module_node_modifier($node)
{
useattrib('atkDummyAttribute');
$node->add(new atkDummyAttribute('mydummyattrib','Dummy attribute added by modifier'), 'default',9999999);
}
}