Le jeudi 24 avril 2008 à 23:31 +0200, Thomas Müller a écrit :

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Guillaume Lecanu schrieb:
> > Le mercredi 23 avril 2008 à 17:49 +0200, Christoph Frick a écrit :
> > 
> >> On Wed, Apr 23, 2008 at 05:07:47PM +0200, Guillaume Lecanu wrote:
> >>
> >>
> >>> Like index.php and about.php have the same menu, I have added a
> >>> /templates/macros.html page.  In this macros.html, I have added the
> >>> menu div with the attribute metal:define-macro="menu".  In the 2
> >>> others templates pages, I have set the menu sample to uses the
> >>> macros.html version, for that I have used
> >>> metal:use-macro="macros.html/menu" 
> >> You should read up the parts about define-slot and fill-slot in the
> >> phptal docs.
> > 
> > Yes I have read it, but I haven't really understand the concept of
> > slots.
> > 
> > But I have just found a solution with macros.
> > I know have a /templates/template.html with the proper html/head/body
> > and I call the macro on the body tag I call the content of the other
> > page :
> > metal:use-macro="$template/content"
> > 
> > $template is the template file name of the template to see (from
> > $_SERVER['SCRIPT_NAME'])
> > 
> > Like that, all working like I want,
> > 
> > Thanks for your help !
> 
> hi, try following construct (works fine for me):
> 
> - - all my references are like href="?view=home" or href="index.php" (access
> to all template-files is limited to localhost)
> 
> - - index.php:
> $template = new PHPTAL(Controller::getView('view'));
> // result of Controller::getView('view') for href="?view=home" is
> 'path/to/home.html'
> 
> - - layout.html:
> <span metal:define-macro="page" tal:omit-tag="">
> <html>
> <head>...</head>
> <body>
>   <span metal:use-macro="path/to/header.html/header">Include Header</span>
>   <span metal:use-macro="path/to/nav.html/nav">Include Navigation</span>
>   <span metal:define-slot="content">Include Content</span>
>   <span metal:define-slot="contentNav">Include ContentNav</span>
> </body>
> </html>
> </span>
> 
> - - home.html
> <div metal:use-macro="path/to/layout.html/page">
> <div metal:fill-slot="content" tal:omit-tag="">
>   content
> </div>
> <div metal:fill-slot="contentNav" tal:omit-tag="">
>   contentNav
> </div>
> </div>
> 
> greetings, thomas mueller

Hi Thomas,

Thanks for your solution but I will finally uses a simple system like
that :
a global /templates/template.html :
<html>
<head>
...
</head>
<body>

(some global <div></div> like the login system, menu etc)

<div metal:use-macro="$template/content"></div>

</body>
</html>

And like that I'm using always this template.html and I have just to
assign the $template value to the template I want to see (index.html,
about.html ....)

So in about.html for example I have
<html>
<head>
...
</head>
<body>

(some global <div></div> like the login system, menu etc)

<div metal:define-macro="content">
Here, all the content of the about.html page to show.
</div>

</body>
</html>

With this solution, I have only to adapt the "content" macro of each
templates pages.
It's a good solution for my needs :-)

Thanks for your help.
_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to