|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
xces Smarty Regular
Joined: 09 Apr 2004 Posts: 77
|
Posted: Thu Dec 08, 2005 3:54 pm Post subject: [cms] CMS widgets? |
|
|
Aloha, i have the following idea;
Currently i have a CMS with only 1 smarty object.
The structure is like this:
\_templates_c
\_templates
\code
\inc
Let me explain
When i have core functions (e.g. login) it would be like this:
\_templates_c
\_templates\core
\code\core
\inc\core
When i have the photo widget it would be like this:
\_templates_c
\_templates\photo
\code\photo
\inc\photo
etc. etc.
But now i want to be able to distribute those "widgets" to multiple sites, so i am thinking of a directory structure like this:
\_templates_c
\widget\photo\_templates
\widget\photo\code
\widget\photo\inc
So if i want to install the photo widget on a new server, all i have to do is copy the "photo" directory and all should work
Is this possible with only 1 smarty object? |
|
Back to top |
|
CirTap Smarty Pro
Joined: 04 Jun 2003 Posts: 106
|
Posted: Sun Dec 11, 2005 1:22 pm Post subject: |
|
|
Hi,
with the "native" Smarty class, it'd be easier to have
/cms/templates/photo
/cms/templates/foobar
and then set $template_dir to "/cms/templates". You can then {include} and {fetch} files in your templates using a relative path, avoiding the non-portable*) "file:/full/path/to/foobar.tpl".
That'd give you two folders to copy:
/photo/*.*
/templates/photo/*.*
You may also register a "CMS" template resource which does the directory juggling for your, in case you wanna stick to one folder per "widget" with all its code. Then use
$smarty->display("cms:photo/foobar.tpl")
and
{include file="cms:photo/foobar.tpl"}
I like to have all templates in one folder structure, as it's easier (IMHO) to switch themes|skins, and "installing" a new widget, site-section or weblication is done by distributing it's folder to the various themes -- if any. I actually have much less themes then widgets, sections, or apps.
Another advatage of this is that you can ZIP 'em, give it so someone for re-design and this person has all the HTML in one place.
Code: | -- global stuff for any page
/templates/meta.tpl
/templates/footer.tpl
-- the "green" theme
/templates/green/page_default.tpl
/templates/green/header.tpl
/templates/green/main.tpl
/templates/green/forms/login.tpl
/templates/green/news/tickerbar.tpl
-- the "sunny" theme
/templates/sunny/page_default.tpl
/templates/sunny/header.tpl
/templates/sunny/main.tpl
/templates/sunny/forms/login.tpl
/templates/sunny/news/tickerbar.tpl |
The Theme is then a global (config) variable which is used as part of the file name for display() and {include}
[php:1:5bddb30e68]$theme = 'green';
$smarty->display($theme.'/forms/login.tpl');
<!-- login box -->
{include file=$theme.'/forms/login.tpl'}
[/php:1:5bddb30e68]
Have fun,
CirTap
*) by non-portable I mean you may not simply use the same templates on two servers or OS (Win, Linux) having different pathnames w/o constantly updating the pathnames in all templates. Hence "relative" pathnames (or a dedicated tpl-resource handler) are the easiest way to go. |
|
Back to top |
|
|
|
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
|