2012-04-16, 07:42 PM
I'm attempting a project that makes use of templates similarly to how MyBB does, but I'm royally stuck.
What I have in the template is this:
What I want my function to do is replace the {url} with the value of $settings->load("url"), but I want it to be relatively dynamic so that {SETTING} can be replaced with the value of it's respective setting.
I don't want to have it do a str_replace for each and every setting as that doesn't allow for people to include custom settings in the templates without a manual file edit and if there's a bugfix in the templates class, either the fix has to be applied manually or they have to replace their str_replace commands for every setting.
Here's the $templates->load code:
What I have in the template is this:
<form action="{url}/member.php?do=login">
<strong>Username</strong>
<input type="text" /><br />
<strong>Password</strong>
<input type="password" /><br />
<input name="login" type="submit" value="Login" />
</form>
<a href="{url}/member.php?do=lostpw">Forgot Password</a>
What I want my function to do is replace the {url} with the value of $settings->load("url"), but I want it to be relatively dynamic so that {SETTING} can be replaced with the value of it's respective setting.
I don't want to have it do a str_replace for each and every setting as that doesn't allow for people to include custom settings in the templates without a manual file edit and if there's a bugfix in the templates class, either the fix has to be applied manually or they have to replace their str_replace commands for every setting.
Here's the $templates->load code:
function load($template){
global $settings;
$query = "SELECT `template` FROM `{$this->tbl}` WHERE `name` LIKE '{$template}' LIMIT 0,1";
$sql = mysql_query($query) or die ("Query failed: ".mysql_error());
$result = mysql_fetch_array($sql) or die ("Query failed: ".mysql_error());
print $result['template'];
}