Jump to content

extracting & contructing data from an infinate loop until finished


StirCrazy

Recommended Posts

Hi folk,

Need some of that 'ol phpfreaks magic :)

 

I'm trying to contruct a page (as a whole) from lots of sub template files. Some of these sub template files call other sub template files (a bit like you would use 'include' to call a php file).

 

I'm currently using this function, but it only constucts the page up to the first sub level template (it doesn't get templates within templates).

function contructpage($template) {

global $subdir;

$templateincludes = getStrsBetween('{template:','}', $template);	

if (isset($templateincludes)) {
	foreach ($templateincludes as $value => $tplfile) {
		if(!($includedtemplate = @file_get_contents($subdir['templates'] . '/' . $tplfile))) {
			error('no_sub_tpl', $tplfile);
		}
		$template = eregi_replace('{template:' . $tplfile. '}', strval($includedtemplate), $template);
	}
}

  return $template;

}

 

$template = file_get_contents('main_template.tpl')
$whole_template = contructpage($template);

 

 

 

Can anyone help making a function that keeps going until the whole page is made?

 

 

 

EG:

 

index.tpl:-

<header>

<body>

{template:file1.tpl}

{template:file2.tpl}

{template:file3.tpl}

{template:file4.tpl}

<footer>

 

 

file1.tpl:-

{template:subfile1.tpl}

{template:subfile2.tpl}

 

subfile1.tpl:-

{template:infinity_other_tpl_files.tpl}

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.