Including modifiers when extending nodes: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| Line 10: | Line 10: | ||
<span style="color: #000000; font-style: italic;"> | <span style="color: #000000; font-style: italic;"> | ||
function init() | function init() | ||
{ | { | ||
$ret = parent::init(); | $ret = parent::init(); | ||
$oldtype = $this->m_type; | $oldtype = $this->m_type; | ||
| Line 39: | Line 37: | ||
<p></p> | <p></p> | ||
<p></p> | <p></p> | ||
--[[User:Saitta|Saitta]] 13:07, 10 November 2006 (CEST) | --[[User:Saitta|Saitta]] 13:07, 10 November 2006 (CEST) | ||
Revision as of 15:28, 23 November 2006
|
ATK Howto: Including modifiers when extending nodes
|
This howto explains how you can include modifiers when you extend a node.
All modifiers added to a node will be run in the node's init function. Which modifiers that runs however, depends on the m_type of a node, which will be different for any node that extends it. In order to have the modifiers run, some changes has to be made in the extended nodes init node.
An example init_node:
function init()
{
$ret = parent::init();
$oldtype = $this->m_type;
$oldmodule= $this->m_module;
$this->m_type='hours';
$this->m_module='timereg';
global $g_modifiers;
if (isset($g_modifiers[$this->atknodetype()]))
{
foreach ($g_modifiers[$this->atknodetype()] as $modulename)
{
$module = &getModule($modulename);
$module->modifier($this);
}
}
$this->m_module=$oldmodule;
$this->m_type = $oldtype;
return $ret; }
--Saitta 13:07, 10 November 2006 (CEST)