question about smarty
am 06.11.2009 00:14:18 von Sudhakar
--000e0cd2e302010c030477a7e3e3
Content-Type: text/plain; charset=ISO-8859-1
i am using smarty template engine at work place, following is the situation
i already have 1 template that has already been created example =
http://localhost/sites/template1.com this works fine
following is the folder structure i have for smarty on xampp
1. C:\xampp\htdocs\sites\template1.com where i have .htaccess index.php and
siteconf.php
2. C:\xampp\htdocs\sites\_templates\templates\template1
in the siteconf.php file there are all the major variables defined which are
accessed in other tpl file of the templates example in aboutus page,
contactus page etc of this template1
now i have created another template called template2 and this also has the
same structure
1. C:\xampp\htdocs\sites\template2.com where i have .htaccess index.php and
siteconf.php
2. C:\xampp\htdocs\sites\_templates\templates\template2
my question is the look and feel when i access
http://localhost/sites/template1.com and
http://localhost/sites/template2.com
is the same the only thing that needs to be done is for template2 when i
access http://localhost/sites/template2.com ONLY the header image should be
different compared to the header i have for
http://localhost/sites/template1.com this is the only change i need
i am not aware as to the php code i need to write so that when i access
http://localhost/sites/template2.com the header image changes and this new
header image remains for the entire pages of
http://localhost/sites/template2.com
presently in header.tpl of template1 is written as follows
{if strpos($Data.KEYWORD,"rv rental") === false}
style="background:url(images/header_{$siteData.COUNTRY3}.gif ) no-repeat top
left;">
{else}
style="background:url(images/header_{$siteData.COUNTRY3}_rv. gif) no-repeat
top left;">
{/if}
so i need to chane the {if} {else} where i need to mention that if i am
accessing http://localhost/sites/template2.com then the header image should
be different.
any help will be greatly appreciated.
please advice.
thanks.
--000e0cd2e302010c030477a7e3e3--
Re: question about smarty
am 06.11.2009 08:26:44 von Fernando Castillo Aparicio
--0-1390071945-1257492404=:47396
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
I'm not sure where is the problem, but can't you just define every changing=
part in your template as variables and assign them as needed from php?=0A=
=0AIf you need to change the image url, just make it a variable, like in=0A=
=0Abackground:url(images/{$img})
Then you just assign the variable as =
needed in each file:
//template1.php=0A$img =3D 'mi_image_1.gif';=0A$s=
marty->assign( 'img', $img );
//template2.php=0A$img =3D 'mi_image_2.g=
if';=0A$smarty->assign( 'img', $img );
That way you don't need to use =
the {if} inside smarty and make your template lighter.
=0A______=
__________________________=0ADe: Sudhakar =0APara:=
php-general@lists.php.net=0AEnviado: vie,6 noviembre, 2009 00:14=0AAsunto:=
[PHP] question about smarty
i am using smarty template engine at work=
place, following is the situation
=0Ai already have 1 template that h=
as already been created example =
http://localhost/sites/template1.com =
this works fine
following is the folder structure i have for smarty on=
xampp
1. C:\xampp\htdocs\sites\template1.com where i have .htaccess i=
ndex.php and=0Asiteconf.php
2. C:\xampp\htdocs\sites\_templates\templa=
tes\template1
=0Ain the siteconf.php file there are all the major vari=
ables defined which are=0Aaccessed in other tpl file of the templates examp=
le in aboutus page,=0Acontactus page etc of this template1
now i have =
created another template called template2 and this also has the=0Asame stru=
cture
1. C:\xampp\htdocs\sites\template2.com where i have .htaccess in=
dex.php and=0Asiteconf.php
2. C:\xampp\htdocs\sites\_templates\templat=
es\template2
=0Amy question is the look and feel when i access=0Ahttp:=
//localhost/sites/template1.com and=0Ahttp://localhost/sites/template2.com=
is the same the only thing that needs to be done is for template2 whe=
n i=0Aaccess http://localhost/sites/template2.com ONLY the header image sho=
uld be=0Adifferent compared to the header i have for=0Ahttp://localhost/sit=
es/template1.com this is the only change i need
i am not aware as to t=
he php code i need to write so that when i access=0Ahttp://localhost/sites/=
template2.com the header image changes and this new=0Aheader image remains =
for the entire pages of=0Ahttp://localhost/sites/template2.com
present=
ly in header.tpl of template1 is written as follows
{if strpos($Data.K=
EYWORD,"rv rental") ===3D false}=0A
kground:url(images/header_{$siteData.COUNTRY3}.gif) no-repeat top=0Aleft;">=
=0A{else}=0A
$siteData.COUNTRY3}_rv.gif) no-repeat=0Atop left;">=0A{/if}=0A
s=
o i need to chane the {if} {else} where i need to mention that if i am=0Aac=
cessing http://localhost/sites/template2.com then the header image should=
=0Abe different.
any help will be greatly appreciated.
please adv=
ice.
thanks.
--0-1390071945-1257492404=:47396--