Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Classes in plugins
edit: Solved – thanks Manfre!
function jmd_example($atts)
{
global $jmd_example_instance, $thisarticle;
/*
$jmd_example_instance is a public-side global variable.
you could also call it $jmd_example - we've already got
jmd_example() and JMD_Example, so why not?
*/
$jmd_example_instance = new JMD_Example($thisarticle['title']);
return $jmd_example_instance->doStuff();
}
function jmd_example_baz($atts)
{
return $GLOBALS['jmd_example_instance']->doOtherStuff();
}
class JMD_Example
{
public $name;
public function __construct($title)
{
$this->name = $title;
}
public function doStuff()
{
return $this->name;
}
public function doOtherStuff()
{
return strtoupper($this->name);
}
}
edit: prefixed the class and instance
Last edited by jm (2008-03-29 06:21:06)
Offline
Pages: 1