how to use smarty ?
| From: | Pupeno | Date: | Tue, 11 Jun 2002 01:44:46 +0000 |
| Subject: | how to use smarty ? | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-4760@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I would like to know how do you use smarty...
now I'm using my own template system, but smarty is much more advanced, but
I'm founding hard to fit my needs with smarty, what I'm doing is this.
I have an index.html which is my main template, it has the header and some
layout for all the pages (it places the menu at the left, the header at the
top and the contents of the rest of the window, etc, etc), it also has the
commands to call the css files, etc, etc. The title, description (meta tag),
body, header and menu are variables that are filled by my template system,
so, I load that file wit hthat variables and then I load another file wich
fill that variables, if you access diferents pages I load diferents templates
to show diferent contents with diferent title, description, etc... I'll show
you an example (you'll this very simiar to FastTemplate, I based my class in
that one):
index.html
<html>
<head>
<title>MySite: {title}</title>
</head>
<body>
{header}
{body}
</body>
<html>
I have a special function call that I use to that file that will asing all the
file to a single variable, so I call the functio nand I assign that to
variable called main, then I load template home, so I load
en/home.html
<html>
<head>
<title>MySite: <!-- start template title -->HomePage<!-- end template title
- --></title>
</head>
<body>
<!-- start template body -->
Welcome the the homepage
..rest of the body...
<!-- end template body -->
</body>
</html>
and maybe en/header.html
<html>
<head>
<title>HEADER</title>
</head>
<body>
<!-- start template header -->
- -=(THIS IS THE HEADER)=-
<!-- end template header -->
</body>
</html>
as you can see, everything is prepared to be edited by a WYSIWYG editor, if I
don't want to go to the home page, instead to the products page, instead of
loadin en/home.html I will load en/products.html which will also define title
and body templates but with other contents, if I want the page in spanish,
instead of loading en/* I load es/* (and the header will change too).
So, how can I acomplish this with smarty ? or something similar ? I'm open to
any good-working framework.
Thank you.
- --
Pupeno: pupeno@pupeno.com
http://www.pupeno.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE9BVYRLr8z5XzmSDQRAiCuAKDVBTTaCvsekEWbJAvngAs11MLWkwCg0aAL
xuNkc5hQMEC88P1Er3LYlwg=
=hUxM
-----END PGP SIGNATURE-----