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

include files

 
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
myov
Smarty n00b


Joined: 29 Mar 2004
Posts: 3

PostPosted: Mon Mar 29, 2004 4:32 am    Post subject: include files Reply with quote

How can I tell smarty to use body.html from the current directory?

My directory structure is:
folder1/index.php
folder1/body.html

My smarty template uses the body.html content in the right place.
But, when I created folder2 with the same structure, it started using folder1's content.

Can this be done?
Back to top
View user's profile Send private message
ShenKong
Smarty Rookie


Joined: 20 Jan 2004
Posts: 27

PostPosted: Mon Mar 29, 2004 5:30 am    Post subject: Reply with quote

$smarty = new Smarty;

// Set the template_dir

$smarty->template_dir = "folder2";
_________________
Something comes soon ...
http://www.showtop.net
http://www.openphp.cn
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
myov
Smarty n00b


Joined: 29 Mar 2004
Posts: 3

PostPosted: Mon Mar 29, 2004 7:21 am    Post subject: Reply with quote

didn't work. folder 1 worked (which is now the root), folder 2 worked, but going back to the root used folder2's content.

I'm guessing it's because the filenames are the same, so when Smarty compiles the page it uses the wrong one.


Is it possible to do the include from a variable? ie:
{include file="$pathToFile"}
Then I could just pass that in to the template.
Back to top
View user's profile Send private message
boots
Administrator


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

PostPosted: Mon Mar 29, 2004 7:29 am    Post subject: Reply with quote

Yes you can include dynamically--use that Smile [actually, one of my favourite techniques]

It appears that your problem is that you have a single compile_dir for multiple template_dir's which each have the same file layout. It occurs to me that there are some threads related to that here at the forum, but I could not find them easily.

It also appears that your problem arises because you are point your template dir to your webroot (and perhaps your compiled and cached dirs as well). This is not recommended and if possible, you should restructure your app (again, threads are available here and it is a topic available from a good google search as well Wink).
Back to top
View user's profile Send private message
myov
Smarty n00b


Joined: 29 Mar 2004
Posts: 3

PostPosted: Mon Mar 29, 2004 7:43 am    Post subject: Reply with quote

n/m, figured out that the answer is yes Smile
Back to top
View user's profile Send private message
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