flamerail Posted April 4, 2006 Share Posted April 4, 2006 In phpbb it uses {blalblabla} as var areas in the templates. Hows does it load the template file and process it and load those with the wanted crap?I dug thought the phpbb source code and found nothing that made sense as to that. Any ideas would be most welcome :) Quote Link to comment https://forums.phpfreaks.com/topic/6597-hows-does-phpbb-load-the-template-files-and-fill-in-the/ Share on other sites More sharing options...
obsidian Posted April 4, 2006 Share Posted April 4, 2006 here's the short of it... obviously, it's a little more in-depth, but the basic idea is here. you create an array with the tag names and values that you want to substitute for the tags. for instance:[code]$tags = array( 'TITLE' => 'My Page', 'AUTHOR' => 'obsidian');[/code]now, you can set as many tags like this as you like. then, basically, you just load the template file into a string and run a str_replace() on all the tags and output the result. see if this continuation to the prep above helps make sense:[code]// set your tag values$tags = array( 'TITLE' => 'My Page', 'AUTHOR' => 'obsidian');$template = "This page is called \"{TITLE}\" and it was written by {AUTHOR}.";// prep for your str_replace() call$find = array();$replace = array();foreach ($tags as $key => $val) { $find[] = '{' . $key . '}'; $replace[] = $val;}// replace it!$out = str_replace($find, $replace, $template);echo $out;[/code] Quote Link to comment https://forums.phpfreaks.com/topic/6597-hows-does-phpbb-load-the-template-files-and-fill-in-the/#findComment-23952 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.