StirCrazy Posted July 18, 2008 Share Posted July 18, 2008 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} Link to comment https://forums.phpfreaks.com/topic/115458-extracting-contructing-data-from-an-infinate-loop-until-finished/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.