Re: Call to a member function on a non-object
- From: Schraalhans Keukenmeester <nomail@xxxxxxxxxx>
- Date: Thu, 29 Sep 2005 11:45:31 +0200
aaron wrote:
First of all I don't understand why you simultaneously try to parse the variables [title main & footer] in the function call AND refer to the GLOBAL versions of the same variables. In my PHP setup this induces an error.function sidebar($sbtitle,$sbmain,$sbfooter){ global $sbtitle, $sbmain, $sbfooter; $template->set_filenames(array( 'sidebar' => 'sidebar.tpl') ); $template->assign_vars(array( 'SBHEADER' => $sbheader, 'SBMAIN' => $sbmain, 'SBFOOTER' => $sbfooter
)); $template->pparse('sidebar');
}
sidebar('MYTITLE','MAIN','Footer');
What am I doing wrong here? I recieve the Call to a member function error. My main goal is to create a little side bar that can be called with the three variables. So that when using a template engine on the main page I can diplay several of these "sidebar" with different contents. This is what I am working towards on the main PHP page so that I can just have {LASTTHUMB} AND {LASTBLOG} where ever I want in the .tpl page $template->set_filenames(array( 'body' => 'main_body.tpl') ); $template->assign_vars(array( 'COLOR' => $my_color, 'LASTTHUMB' => sidebar('PhotoTitle', 'Myphoto','PhotoFooter'), 'LASTBLOG' => sidebar('BlogTitle','Blog','Blogfooter') ));
$template->pparse('body');
Further I assume $template is an instance of a certain class. Then you try to invoke a MEMBER function (or method) of that class, but sidebar() seems to be a global function. If not, and it IS in te class, your first call to it is not allowed, for the opposite reason.
But I may be misinterpreting all of this... Does this help at all? Sh .
- References:
- Call to a member function on a non-object
- From: aaron
- Call to a member function on a non-object
- Prev by Date: Re: Job submission to background and mail results?
- Next by Date: HTML PHP Presentation and Logic
- Previous by thread: Call to a member function on a non-object
- Next by thread: Re: Call to a member function on a non-object
- Index(es):