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

[cms] CMS widgets?

 
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
xces
Smarty Regular


Joined: 09 Apr 2004
Posts: 77

PostPosted: Thu Dec 08, 2005 3:54 pm    Post subject: [cms] CMS widgets? Reply with quote

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 Wink

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 Wink

Is this possible with only 1 smarty object?
Back to top
View user's profile Send private message
CirTap
Smarty Pro


Joined: 04 Jun 2003
Posts: 106

PostPosted: Sun Dec 11, 2005 1:22 pm    Post subject: Reply with quote

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
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