|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
dirtdrgn Smarty n00b
Joined: 05 Nov 2003 Posts: 3
|
Posted: Thu Nov 06, 2003 10:25 pm Post subject: Dynamic include not working |
|
|
main.tpl
<{include file="header.tpl"}>
<{include file="leftbar.tpl"}>
<{include file="$disdis.tpl"}>
<{include file="rightbar.tpl"}>
<{include file="footer.tpl"}>
index.php
<?php
error_reporting(E_ALL);
require_once('/home/storm/public_html/desertstorm/include/meta.php');
if (!isset($action)) {
$action = "index";
}
$smart->assign('date',date("l, F j Y"));
if(file_exists("smarty/templates/{$action}.tpl") && (!$action=="leftbar" || !$action=="rightbar" || !$action=="header" || !$action=="footer" || !$action=="index") ) {
$smart->assign('disdis',$action);
}
else {
$smart->assign('disdis','index');
}
$smart->display('main.tpl');
?>
Now, I thought I had this perfected, but now the page will only load "index.tpl." I had a smarty-using friend of mine look at the syntax, and he couldn't find anything wrong with it. He said that there was a problem with dynamic includes, but I saw an example somewhere on here and can't find it again...sorry if this has been asked somewhere obvious. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Fri Nov 07, 2003 10:01 am Post subject: |
|
|
I wonder if you are using caching. If so, check out Multiple Caches Per Page. |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Fri Nov 07, 2003 11:26 am Post subject: |
|
|
- use $smart->template_exists() instead of file_exists().
- to me it looks the part after && is always true anyway.
you are testing if $action is not-equal "leftbar" *or* not-equal "rightbar". obviously it's always not equal at least one of them.
so only the file_exists can cause the if-condition to fail. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|