Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Themes

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
Jerc
Smarty Rookie


Joined: 26 Jan 2010
Posts: 23
Location: Slovenia / Ljubljana

PostPosted: Wed Jun 13, 2012 2:38 pm    Post subject: Themes Reply with quote

Hi.

Maybe you guys could solve my problem or give me the best solution.
I would like to achieve something like Drupal Theme system.

I have created default design:
Code:
/themes/default/

with files:
Code:
index.tpl
head.tpl
foot.tpl


Code:
$smarty->setTemplateDir('/themes/default/');


Then i've added new theme "basic"
Code:
$smarty->addTemplateDir('/themes/basic/');

with one file
Code:
head.tpl


I would like: if the template exists in the /basic folder, then smarty should use /themes/basic/head.tpl and not /themes/default/head.tpl

I don't want to change my entire code and add
if template exists in the basic folder then
display it from basic folder
else
display default template

i wish to keep the code as it is:
display head.tpl or {include file="head.tpl" in the template

Thanks for the solutions.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 4671
Location: Hamburg / Germany

PostPosted: Wed Jun 13, 2012 7:03 pm    Post subject: Reply with quote

With your code Smarty does search the folders in the wrong order (default first and then basic).

Use
Code:

$smarty->setTemplateDir(array('/themes/basic/','/themes/default/'));
Back to top
View user's profile Send private message
Jerc
Smarty Rookie


Joined: 26 Jan 2010
Posts: 23
Location: Slovenia / Ljubljana

PostPosted: Fri Jun 15, 2012 5:35 am    Post subject: Reply with quote

It's working now.

Many thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development 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