Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Dynamic include not working

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
dirtdrgn
Smarty n00b


Joined: 05 Nov 2003
Posts: 3

PostPosted: Thu Nov 06, 2003 10:25 pm    Post subject: Dynamic include not working Reply with quote

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
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Fri Nov 07, 2003 10:01 am    Post subject: Reply with quote

I wonder if you are using caching. If so, check out Multiple Caches Per Page.
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Fri Nov 07, 2003 11:26 am    Post subject: Reply with quote

- 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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP