View previous topic :: View next topic |
Author |
Message |
CDee Smarty n00b
Joined: 21 May 2003 Posts: 1
|
Posted: Wed May 21, 2003 10:49 pm Post subject: Nested Directories containing templates |
|
|
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 |
|
djhmateer Smarty n00b
Joined: 30 May 2003 Posts: 3 Location: Melbourne
|
Posted: Fri May 30, 2003 1:26 am Post subject: |
|
|
Hi
Did you resolve your problem? I am considering something very similar.
Regards
Dave Mateer.
djhmateer@hotmail.com |
|
Back to top |
|
eadz Smarty Regular
Joined: 30 Apr 2003 Posts: 61 Location: Auckland, New Zealand
|
|
Back to top |
|
djhmateer Smarty n00b
Joined: 30 May 2003 Posts: 3 Location: Melbourne
|
Posted: Fri May 30, 2003 4:24 am Post subject: |
|
|
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 |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Fri May 30, 2003 5:03 am Post subject: |
|
|
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 |
|
fbronx Smarty Rookie
Joined: 28 May 2003 Posts: 11 Location: Stekene, Belgium
|
Posted: Fri May 30, 2003 9:21 am Post subject: |
|
|
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 |
|
djhmateer Smarty n00b
Joined: 30 May 2003 Posts: 3 Location: Melbourne
|
Posted: Tue Jun 03, 2003 3:43 am Post subject: Thanks |
|
|
Many thanks for your commants and suggestions.
Regards
David Mateer. |
|
Back to top |
|
|