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 ???

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.