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

Nested Directories containing templates

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


Joined: 21 May 2003
Posts: 1

PostPosted: Wed May 21, 2003 10:49 pm    Post subject: Nested Directories containing templates Reply with quote

Hi all,

Not sure if this is possible, I tried in vain to do it but failed...

Creating an application that is module based (users, sites, catalog) using a directory structure thus:
root/modules/core <- Code for Core
root/modules/core/templates <- templates used by core.
root/modules/SectionA <- Code for SectionA
root/modules/SectionA/templates <- templates used by SectionA
root/modues/SectionB <-Code for SectionB
root/modules/SectionB/templates <-templates for SectionB
root/smarty <- smarty files and compile dirs
root/index.php <- processes url for module and Section, including from core.

I'm doing this as the last version of this code had over 300 files in the root and it became a bit of a nightmare, the move to smarty might double that, but as it's a rewrite from the ground up I thought I'd try at least to implement a logical plan.

So as I have failed so far in making this work, does anybody have any tips? Or indeed if the above is a daft way to do it...

Thanks in advance,
Colin.
Back to top
View user's profile Send private message
djhmateer
Smarty n00b


Joined: 30 May 2003
Posts: 3
Location: Melbourne

PostPosted: Fri May 30, 2003 1:26 am    Post subject: Reply with quote

Hi

Did you resolve your problem? I am considering something very similar.

Regards

Dave Mateer.
djhmateer@hotmail.com
Back to top
View user's profile Send private message
eadz
Smarty Regular


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

PostPosted: Fri May 30, 2003 3:23 am    Post subject: Reply with quote

Search the forum, there are at least 3 threads about this
_________________
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
djhmateer
Smarty n00b


Joined: 30 May 2003
Posts: 3
Location: Melbourne

PostPosted: Fri May 30, 2003 4:24 am    Post subject: Reply with quote

In the Smarty documentation one of the examples given is:

/web/www.example.com/smarty/guestbook/templates
/web/www.example.com/smarty/guestbook/templates_c etc...

Does this infer that other vertical applications like polls, forums can easily have their own subdirectories?

I'm developing an application that I'd like to be extensible... and simple! So considering concepts at the moment.

Regards

Dave.
Back to top
View user's profile Send private message
boots
Administrator


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

PostPosted: Fri May 30, 2003 5:03 am    Post subject: Reply with quote

Hi Dave.

djhmateer wrote:
In the Smarty documentation one of the examples given is:

/web/www.example.com/smarty/guestbook/templates
/web/www.example.com/smarty/guestbook/templates_c etc...

Does this infer that other vertical applications like polls, forums can easily have their own subdirectories?


You should note that the templates_c directory referenced in the example is not a template path. templates_c is the directory for compiled templates and is used internally by Smarty.

Never-the-less, you can have multiple template directories in the "template search path" by assigning an array of directories:
[php:1:8ecd7ec3e0]<?php
$smarty->templates = array( '/pathto/template/dir', '/pathto/a/different/template/dir' );
?>[/php:1:8ecd7ec3e0]
As mentioned, Smarty treats this as a search path -- starting with the first, it looks for the requested template (eg. my/template.tpl) in each assigned template directory in the array until it finds it. This means that if you have a 'my/template.tpl' in more than one templates directory, the first one found will be used.
Back to top
View user's profile Send private message
fbronx
Smarty Rookie


Joined: 28 May 2003
Posts: 11
Location: Stekene, Belgium

PostPosted: Fri May 30, 2003 9:21 am    Post subject: Reply with quote

Hi,

I'm working also on a CMS like you're doing and I have the following structure:

/
/modules
/modules/user
/modules/user/templates
/modules/user/config
/themes
/themes/default
/themes/default/templates
/themes/default/config
/templates_c

I only have one compile directory. The problem was to make sure that no compiled template got overwritten by another one. This is solved as follows:

1. I use the full path to fetch a template:
For example in my class that extends from Smarty I put this:
$this->fetch($this->path . 'templates/' . $tpl);
2. Themes are loaded as a resource
For example: {include file='theme:main.tpl'}

See my post about {include_dir} and compile_id for more info on 2.
Back to top
View user's profile Send private message
djhmateer
Smarty n00b


Joined: 30 May 2003
Posts: 3
Location: Melbourne

PostPosted: Tue Jun 03, 2003 3:43 am    Post subject: Thanks Reply with quote

Many thanks for your commants and suggestions.

Regards

David Mateer.
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 -> 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