On Sun, 08 May 2011 16:14:46 +0100, Fernando Martins <ferna...@cmartins.nl> wrote:

I'm afraid I can't understand what you are trying to achieve there. What is the effect of the tal:define="callback 'display-list'" ?? what do the quotes do to display-list? and how would I use the callback? Sorry, very confused...

I've meant using callback (macro called from macro) instead of slots.

e.g. your code modified to use callbacks:

<html   metal:define-macro="main"  tal:define="people php:peopleGet()">
<head>
</head>
<body>

<div metal:use-macro="${callback}" tal:comment="will call any macro named in callback variable">
</div>

</body>
</html>


<html metal:use-macro="person.zpt/main" tal:define="callback string:myfile.zpt/content_main" tal:comment="variable tells main macro to call content_main below"><head>
</head>
<body>
<div metal:define-macro="content_main">
<ul>
<li tal:repeat="user people" tal:content="user/name"></li>
</ul>
</div>
</body>
</html>


I have a main page template person.zpt which defines the layout for all the pages of the web site. Every other page, say people.zpt, meeting.zpt, team.zpt merely fills in the slots. All I wanted was to avoid redefining common variables in all pages. Just factoring out the common data into the common template.

If you have certain variables on all pages, why not simply set them from PHP?

In PHPTAL slots are executed in context where fill-slot is used, not in context where define-slot is, so what you're trying to achieve is not possible with slots.

I wasn't aware that in Zope context is different. Can Zope's fill-slot use variables from both its context and the macro? If both macro and context of fill-slot have variable with same name, which one "wins"?

--
regards, Kornel Lesiński

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

Reply via email to