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

Themeing - best practices ?
Goto page Previous  1, 2
 
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 -> Tips and Tricks
View previous topic :: View next topic  
Author Message
mohrt
Administrator


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

PostPosted: Wed May 28, 2003 8:41 pm    Post subject: Reply with quote

eadz wrote:

I havn't needed a compile id before, but IMHO I think this is a perfect use. If it's not supposed to be used in this situation, what situaltion is it supposed to be used in.


compile_id is typically used when you want several compiled versions of the same template files, such as re-using templates for different languages. This minimizes the runtime processing, as opposed to using the same compiled files and dynamically building the language text.

There is nothing keeping you from using separate template_dir for each theme, but in my experience it is easier to stick with one template_dir and one compile_dir and let the templates handle which theme to display. This way you retain the ability of using compile_id for separate languages, the complexity at the application level is minimal and the templates are kept most flexible. Multiple template_dirs may also add an element of confusion for someone looking at the directory structure then looking at the template output and having to figure out how the application is swapping around the template_dir root.

Monte
Back to top
View user's profile Send private message Visit poster's website
[SuB]
Smarty Rookie


Joined: 18 Jun 2003
Posts: 5

PostPosted: Wed Jun 18, 2003 9:56 am    Post subject: Reply with quote

We are sourcing multipple the templates from a database structure, so I, without having actually got to the part of implementing this, I think setting the compile_id to the ID of the template set so the compiled templates don't overwrite each other.
Back to top
View user's profile Send private message
deixu
Smarty Rookie


Joined: 27 Jun 2003
Posts: 9
Location: Wolfsburg, Germany

PostPosted: Fri Jun 27, 2003 11:34 pm    Post subject: Reply with quote

hi...

this is my approach for multiple themes:

Code:

define(ROOT_PATH, "/home/www/testsite/html/");

class sysSmarty extends Smarty {

   var $template_name = '';

   function sysSmarty($template = "") {
      if(!$this->set_template($template) && $template != "") {
         die('Error: Template "'.$template.'" does not exist');
      }
   }
   
   function set_template($template) {
      if($template && file_exists(ROOT_PATH."templates/themes/".$template)) {
         $this->Smarty();
         $this->template_dir = ROOT_PATH.'templates/themes/'.$template;
         $this->compile_dir = ROOT_PATH.'templates/compiled/'.$template;
         $this->template_name = $template;
         return 1;
      } else {
         return 0;
      }
   }
}
Back to top
View user's profile Send private message
ZeroFill
Smarty Rookie


Joined: 31 Aug 2003
Posts: 28

PostPosted: Sun Aug 31, 2003 6:57 am    Post subject: Reply with quote

cool. thanks for the code deixu, this'll really be handy Very Happy, but in part of your code, did you mean to have the first if statement to be
Code:
if(!$this->set_template($template) || $template == "") {

so it checks if a template was entered at all?
Back to top
View user's profile Send private message
JonBoy
Smarty Rookie


Joined: 09 Oct 2003
Posts: 6
Location: Madison, Wisconsin, USA

PostPosted: Thu Oct 09, 2003 6:22 pm    Post subject: CSS Stylesheets? Reply with quote

I dunno about you, but I use the templating in Smarty to format table widths and arrange elements on the page. Then I use a selection of static CSS stylesheets to allow different users to select different colors and background sets for their personal view.
Back to top
View user's profile Send private message
BloodRath
Smarty Rookie


Joined: 06 Jul 2003
Posts: 23
Location: France

PostPosted: Wed Nov 19, 2003 11:39 pm    Post subject: theme Reply with quote

just a stupid question but don't u think themes are definitely CSS domain ?

A look at css Zen Garden http://www.csszengarden.com/ could convince u
Wink
_________________
froggies forever.... Wink
Back to top
View user's profile Send private message
andre
Smarty Pro


Joined: 23 Apr 2003
Posts: 164
Location: Karlsruhe, Germany

PostPosted: Thu Nov 20, 2003 8:07 am    Post subject: Reply with quote

Shocked Shocked Very cool site, thanks for the tip!
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 -> Tips and Tricks All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
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