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

some files have same name. Can those use the same cache dir?

 
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 -> Installation and Setup
View previous topic :: View next topic  
Author Message
ewebzerg
Smarty n00b


Joined: 27 Apr 2003
Posts: 4

PostPosted: Mon Apr 28, 2003 2:30 pm    Post subject: some files have same name. Can those use the same cache dir? Reply with quote

I have some directories in which some files have same name. This my site's file structure:

/news :
-----------
/news/index.php
/news/display.php (usage: display.php?id=xx)
/news/templates/index.tpl
/news/templates/display.tpl

/member:
-----------
/member/index.php
/member/display.php (usage: display.php?id=xx)
/member/templates/index.tpl
/member/templates/display.tpl

/Smarty
---------
......

/temporary :
---------------
/temporary/cache
/temporary/templates_c

IS THOSE OK?
"/news/display.php" and "/member/display.php" can use "/temporary/cache" at the same time ??

Smile sorry for my poor english..


Last edited by ewebzerg on Wed May 05, 2010 10:49 pm; edited 1 time in total
Back to top
View user's profile Send private message
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Mon Apr 28, 2003 2:43 pm    Post subject: Reply with quote

I believe it would work because Smarty uses internal cache id's, but I could be wrong.
_________________
"Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane
Back to top
View user's profile Send private message Visit poster's website
ewebzerg
Smarty n00b


Joined: 27 Apr 2003
Posts: 4

PostPosted: Mon Apr 28, 2003 2:49 pm    Post subject: Reply with quote

AZTEK wrote:
but I could be wrong.


Crying or Very sad what's your meaning ?

"/news/templates/index.tpl" and "/member/templates/index.tpl" have the same cache filename: index.tpl.php !!! can they use the same cache directory ?


Last edited by ewebzerg on Wed May 05, 2010 10:49 pm; edited 1 time in total
Back to top
View user's profile Send private message
Wom.bat
Smarty Pro


Joined: 24 Apr 2003
Posts: 107
Location: Munich, Germany

PostPosted: Mon Apr 28, 2003 3:08 pm    Post subject: Reply with quote

try $compile_id
Back to top
View user's profile Send private message
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Mon Apr 28, 2003 7:05 pm    Post subject: Reply with quote

ewebzerg wrote:
Crying or Very sad what's your meaning ?


Smarty has internal id's for caching and if it doesnt automaticly you can pass it in the display() method
_________________
"Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane


Last edited by AZTEK on Mon Apr 28, 2003 7:40 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
boots
Administrator


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

PostPosted: Mon Apr 28, 2003 7:27 pm    Post subject: Reply with quote

From the manual (sorry I can't get the online page for you, but I'm being blocked by a an insanely paranoid firewall at this location)

See Chapter 14: Cache Groups

Quote:
Technical Note: The cache grouping does NOT use the path to the template as any part of the cache_id. For example, if you have display('themes/blue/index.tpl'), you cannot clear the cache for everything under the "themes/blue" directory. If you want to do that, you must group them in the cache_id, such as display('themes/blue/index.tpl','themes|blue'); Then you can clear the caches for the blue theme with clear_cache(null,'themes|blue')


See Also: $use_sub_dirs
Back to top
View user's profile Send private message
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Mon Apr 28, 2003 7:41 pm    Post subject: Reply with quote

See then I was right... sortof Smile
_________________
"Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Apr 28, 2003 8:50 pm    Post subject: Reply with quote

To be safe, use a separate templates_c directory for every template_dir. Otherwise, you could use a different compile_id for each template_dir if you're not using it for something else.

Monte
Back to top
View user's profile Send private message Visit poster's website
messju
Administrator


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

PostPosted: Mon Apr 28, 2003 8:53 pm    Post subject: Reply with quote

but the main question was, if the same template-filenames in different directories are okay. this does not affect caching in the first place, it does just affect the compiled templates and how they are stored.

they are stored with the "full"-path relative to the $templates_dir.
that means:
$smarty->display('dir1/foo.tpl'); and then
$smarty->display('dir2/foo.tpl'); is fully okay and will lead to two distinct files below templates_c.

but
$smarty->templates_dir = 'dir1';
$smarty->display('foo.tpl');
and then
$smarty->templates_dir = 'dir2';
$smarty->display('foo.tpl');

is not okay, and will lead to the same file being overwritten in templates_c!!! you'll have to use a distinct $compile_dir for every $templates_dir you use. it's better to use just one $template_dir, then you are free to use as many subdirectories in that template_dir as you want,
and you are fine.

in both cases (different compile_dirs for for different template_dirs, or different subdirs in one template_dir) there is no need to use compile_ids
(smarty can distinguish the 2 templates without), and no use for cache_ids
(smarty doesn't use any, when compiling a template at all, they are used later).
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Apr 28, 2003 9:08 pm    Post subject: Reply with quote

My point was, if you really wanted to use one compile_dir for all of your template_dirs, you would have to use a separate compile_id for each template_dir. This is fundamentally a misuse of compile_id, so my recommendation would be to stick with a separate compile_dir for each template_dir, same as messju's mention above.

Monte
Back to top
View user's profile Send private message Visit poster's website
messju
Administrator


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

PostPosted: Mon Apr 28, 2003 9:35 pm    Post subject: Reply with quote

yes, monte. it seems our posts just crossed Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ewebzerg
Smarty n00b


Joined: 27 Apr 2003
Posts: 4

PostPosted: Tue Apr 29, 2003 4:04 am    Post subject: OK, now my file structure is: Reply with quote

/Smarty
---------
....

/news:
/news/index.php
/news/display.php
/news/templates
/news/temp/templates_c
/news/temp/cache
/news/temp/config

/member:
/member/index.php
/member/display.php
/member/templates
/member/temp/templates_c
/member/temp/cache
/member/temp/config

/demand:
/demand/index.php
/demand/display.php
/demand/templates
/demand/temp/templates_c
/demand/temp/cache

so many dirs, Crying or Very sad Crying or Very sad Crying or Very sad Crying or Very sad

I don't know how to user compile_id . who can give me a simple e.g ??


Last edited by ewebzerg on Wed May 05, 2010 10:49 pm; edited 1 time in total
Back to top
View user's profile Send private message
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Tue Apr 29, 2003 9:53 am    Post subject: Reply with quote

Lazyness is never an excuse for poor organizational structure. It would be best to just lay it all out now in seperate dirs and not worry about the cache id's.
_________________
"Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane
Back to top
View user's profile Send private message Visit poster's website
eadz
Smarty Regular


Joined: 30 Apr 2003
Posts: 61
Location: Auckland, New Zealand

PostPosted: Mon May 26, 2003 2:20 am    Post subject: Reply with quote

messju wrote:

$smarty->display('dir1/foo.tpl'); and then
$smarty->display('dir2/foo.tpl'); is fully okay and will lead to two distinct files below templates_c.


So this is the reccomended way of doing it?

I am making a program that has "themes" :
/templates/greentheme/
/templates/bluetheme/

and the theme is decided at runtime.
I did have a /templates/xxxx/compiled directory, ( and setting compile_dir and template_dir ) but it becomes cumborsome, as you have to chmod 777 the compiled directory every time you upload it, and if you have a lot of themes, it's a lot of chmoding.

So should I set my template_dir tp /templates/ and use display("greentheme/file.html") ?

If there is a cleaner solution that would be cool..
_________________
bBlog - Smarty based blogging software
I work for Webforce web site design ( Auckland, NZ )
Back to top
View user's profile Send private message 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 -> Installation and Setup 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