Login
Donate to Zikula
Wiki : ModuleProgrammingPart2
Documentation Home :: Categories :: Page Index :: recent changes :: Search :: Help :: Log in
last edit 2006-09-11 14:09:34 by Landseer

Additions:
Do not rely on the return value! If the module variable does not exist, pnModGetVar() returns false. If your module var is likely to hold a boolean, you might get into trouble. Better store such data as 'on' for true and 'off' for false to avoid problems. delete all module vars in one step
edited 2006-06-21 20:54:24 by markwest fixed wiki words

Additions:
Deletions:
edited 2006-06-15 09:53:25 by patrick.c adde navigation

Additions:
Next step: Module Programming Part 3
Oldest known version of this page was edited on 2006-06-09 17:05:14 by Chestnut [ From Old doku doc - Module Programming part 2 ]
Zikula can store variable for a module in it's registry. We dont need to concern ourselves with any data access as we have three standardised calls which will get, set and delete values.
pnModSetVar?($module, $name, $value)
One would normally initialise module variables in the modules initialisation script pninit.php. This is done at module installation time only and registers the variables with the Zikula registry.
pnModGetVar?($module, $name)
Back to our 'hello world' module lets add a function greetings to pnuser.php
pnModDelVar?($module, $name)
This function would normally be used during the uninstall of a module in pninit.php It removes the variables from the registry.
DeveloperDocs
CategoryDeveloperDocs
Additions:
Do not rely on the return value! If the module variable does not exist, pnModGetVar() returns false. If your module var is likely to hold a boolean, you might get into trouble. Better store such data as 'on' for true and 'off' for false to avoid problems. delete all module vars in one step
- 'helloworld');
edited 2006-06-21 20:54:24 by markwest fixed wiki words
Additions:
pnModSetVar()
pnModSetVar($module, $name, $value)pnModGetVar()
pnModGetVar($module, $name)pnModDelVar()
pnModDelVar($module, $name)Deletions:
pnModSetVar?()
pnModSetVar?($module, $name, $value)pnModGetVar?()
pnModGetVar?($module, $name)pnModDelVar?()
pnModDelVar?($module, $name)edited 2006-06-15 09:53:25 by patrick.c adde navigation
Additions:
Next step: Module Programming Part 3
Oldest known version of this page was edited on 2006-06-09 17:05:14 by Chestnut [ From Old doku doc - Module Programming part 2 ]
Module Variables
Zikula can store variable for a module in it's registry. We dont need to concern ourselves with any data access as we have three standardised calls which will get, set and delete values.
pnModSetVar?()
pnModSetVar?($module, $name, $value)
One would normally initialise module variables in the modules initialisation script pninit.php. This is done at module installation time only and registers the variables with the Zikula registry.
// pninit.php
function helloworld_init()
{
pnModSetVar('helloworld', 'myname', 'Fred Bloggs');
pnModSetVar('helloworld', 'myage', 32);
return true;
}
function helloworld_init()
{
pnModSetVar('helloworld', 'myname', 'Fred Bloggs');
pnModSetVar('helloworld', 'myage', 32);
return true;
}
pnModGetVar?()
pnModGetVar?($module, $name)
Back to our 'hello world' module lets add a function greetings to pnuser.php
// pnuser.php
function helloworld_user_greetings()
{
// get the variable 'myname' which belongs to the module 'helloworld' from the registry
$myname = pnModGetVar('helloworld', 'myname');
// get the variable 'myage' which belongs to the module 'helloworld' from the registry
$myage= pnModGetVar('helloworld', 'myage');
$greeting = "Hello World. My name is $myname and I am $myage";
// function returns to Zikula Application Framework.
return $greeting;
}
function helloworld_user_greetings()
{
// get the variable 'myname' which belongs to the module 'helloworld' from the registry
$myname = pnModGetVar('helloworld', 'myname');
// get the variable 'myage' which belongs to the module 'helloworld' from the registry
$myage= pnModGetVar('helloworld', 'myage');
$greeting = "Hello World. My name is $myname and I am $myage";
// function returns to Zikula Application Framework.
return $greeting;
}
pnModDelVar?()
pnModDelVar?($module, $name)
This function would normally be used during the uninstall of a module in pninit.php It removes the variables from the registry.
// pninit.php
// function to uninstall module
function helloworld_remove()
{
pnModDelVar('helloworld', 'myname');
pnModDelVar('helloworld', 'myage');
return true;
}
// function to uninstall module
function helloworld_remove()
{
pnModDelVar('helloworld', 'myname');
pnModDelVar('helloworld', 'myage');
return true;
}
DeveloperDocs
CategoryDeveloperDocs

latest author:
Owner: