1
nyman
Use of object in smarty template
  • 2005/1/28 17:22

  • nyman

  • Just popping in

  • Posts: 11

  • Since: 2004/1/9 1


Hi all

I have a class:

## file class/my_class.php

class myClass
{
var $data;
function myClass()
{
$data = "this is data";
}
function oneMethod()
{
echo ("result");
}
}

## file index.php

include "header.php";

$xoopsOption['template_main'] = 'controlcenter.tpl';

if($xoopsConfig['startpage'] == "controlcenter"){
$xoopsOption['show_rblock'] =1;
include XOOPS_ROOT_PATH."/header.php";
make_cblock();
}else{
$xoopsOption['show_rblock'] =0;
include XOOPS_ROOT_PATH."/header.php";
}

$myObject = new myClass();

$xoopsTpl->assign( 'object', $myObject );

include XOOPS_ROOT_PATH."/footer.php";
?>

... of course, header.php includes class definition ...


Then, I have a template

If I put

<{$object->data}>

It installs and runs perfectly ... So I see "this is data"
so smarty knows myClass object definition ...

But my problem is when I write:

<{$object->oneMethod()}>

Then I can't update module so It says:

Fatal error: Call to a member function on a non-object in bla bla bla

I've tried smarty with PHP out of XOOPS and I do can do what I want ...

Any one can help me ??? how can I call object method from xoops/smarty ???


Thanx is advance !!!

Login

Who's Online

251 user(s) are online (151 user(s) are browsing Support Forums)


Members: 0


Guests: 251


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits