PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.smarty.general > Refactoring templates folder
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Refactoring templates folder

Réponse
 
LinkBack Outils de la discussion
Vieux 27/10/2006, 17h05   #1
Eric Mueller
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Refactoring templates folder

Hi, I have so many files in my templates/ folder that I'm trying to break it
down into sub-folders.

I can set the templates directory by changing the $smarty->template_dir
variable, but the problem is my templates all {include} common files
(header.tpl, footer.tpl, that sort of thing).

Sooo... is there a way to set the template_dir in the template itself, so I
can be sure the common files are loaded from templates/shared, but then the
main template comes in from a different sub-folder under templates/ ?

thanks,
Eric

_____
Eric Mueller - (323) 852-0883 (Pacific time), (323) 417-4900 fax
Themepark - a specialized web services company
"great web sites, delicious corn dogs!"
http://themepark.com

A Cappella Always, the 24x7 all-a cappella radio station!
broadcasting since 2001 at http://acappellaalways.com

  Réponse avec citation
Vieux 27/10/2006, 17h28   #2
Owen Cole
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Refactoring templates folder

My solution is probably a PITA, but you could include your templates
using a relative path from your template_dir

ie {include file="subdir/templateinsubdir.tpl"}

$smarty->display('subdir/templateinsubdir.tpl');

Eric Mueller wrote:
> Hi, I have so many files in my templates/ folder that I'm trying to break it
> down into sub-folders.
>
> I can set the templates directory by changing the $smarty->template_dir
> variable, but the problem is my templates all {include} common files
> (header.tpl, footer.tpl, that sort of thing).
>
> Sooo... is there a way to set the template_dir in the template itself, so I
> can be sure the common files are loaded from templates/shared, but then the
> main template comes in from a different sub-folder under templates/ ?
>
> thanks,
> Eric
>
> _____
> Eric Mueller - (323) 852-0883 (Pacific time), (323) 417-4900 fax
> Themepark - a specialized web services company
> "great web sites, delicious corn dogs!"
> http://themepark.com
>
> A Cappella Always, the 24x7 all-a cappella radio station!
> broadcasting since 2001 at http://acappellaalways.com
>
>
>

  Réponse avec citation
Vieux 27/10/2006, 18h19   #3
boots
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Refactoring templates folder

Although unsupported, you can make the templates_dir an array of paths. It is searched in order. So put the common templates (eg: templates/shared) first in the array. Another idea: use a custom resource (eg: shared:foo/bar.tpl) -- it means you have to rewrite your templates -- but only once. You can then simply modify your resource to retarget the template locations.

xo boots

Eric Mueller wrote:
> Hi, I have so many files in my templates/ folder that I'm trying to break it
> down into sub-folders.
>
> I can set the templates directory by changing the $smarty->template_dir
> variable, but the problem is my templates all {include} common files
> (header.tpl, footer.tpl, that sort of thing).
>
> Sooo... is there a way to set the template_dir in the template itself, so I
> can be sure the common files are loaded from templates/shared, but then the
> main template comes in from a different sub-folder under templates/ ?
>
> thanks,
> Eric



---------------------------------
How low will we go? Check out Yahoo! Messenger’s low PC-to-Phone call rates.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 13h09.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08853 seconds with 11 queries