Jump to content

Classes Uncallable from Files included inside functions.


electricshoe

Recommended Posts

I'm modifying a copy of oscommerce to work with a template system I'm building. This template system basically just includes a list of files in the order they are specified in the database and sets their permissions etc.

 

It includes the files through a function, which is limiting the included files from referencing objects/classes/anything.

 

This works:

 

include("store_session.php");
include("../includes/header.php");
include("index.php");

 

This Does Not Work:

 

function includeThis() {include("store_session.php");}
function includeThat() {include("../includes/header.php");}
function includeThisToo() {include("index.php");}

includeThis();
includeThat();
includeThisToo();

 

It returns call to non-object errors on all of the classes. My code is a bit more complex than this, but I have tested the above code and it doesn't work.

 

How can I use includes inside a function and have their class structure still work? Do I need to rethink how the program works? I hope I don't.

 

Here's the page builder function:

 

function pagebuilder()
{
//Load the current page info
query("thispage","pages","id","=",$page,'','','');
queryData("thispage");
//echo 'This Page ID:'.$GLOBALS['thispage']['id'].'<br>This template id: '.$GLOBALS['thispage']['template'].'<br>';

//Load the current page template
query("template","templates","id","=",$GLOBALS['thispage']['template'],'','','');
queryData("template");

//Load module stack - This builds the whole page
query("mod","templatemodules","templateid","=",$GLOBALS['template']['id'],"position","ASC",0);

while ($GLOBALS['modrows'] > 0)
{	
	queryData("mod");
	//echo '<br><p><b>Module Function Run</b></p>';
	moduleBuilder($GLOBALS['mod']['id']);
}

} 

 

Basically I get the page id -> get the template id -> get all the 'modules' with that template id and then use the moduleBuilder() function to load all the modules. How can I do this and not get non object errors?

 

Thanks soooo much in advance, I'm completely in the dark on this one ???

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.