Page Template: how to reference objects in the folder above this one?
If I have the following objects /dcII /dcII/add_contact /dcII/add_contact/index_html /dcII/standard_footer /dcII/standard_header and .../index_html is a page template, how to I reference /dcII/standard_{header,footer}? I tried both of the following: <span tal:replace="/dcII/standard_html_header">header</span> <span tal:replace="here/../standard_html_header">header</span> -- Skip Montanaro - skip@pobox.com http://www.mojam.com/ http://www.musi-cal.com/
Hi Skip,
If I have the following objects
/dcII /dcII/add_contact /dcII/add_contact/index_html /dcII/standard_footer /dcII/standard_header
and .../index_html is a page template, how to I reference /dcII/standard_{header,footer}? I tried both of the following:
<span tal:replace="/dcII/standard_html_header">header</span> <span tal:replace="here/../standard_html_header">header</span>
... and the third combination in this row would be <span tal:replace="here/dcII/standard_html_header">header</span> which should work from anywhere. If You are inside of the "dcII", You can use the simpler tal:replace="here/standard_html_header". If You do not understand why this works You may want to revisit the "Acquisition" chapter in the Zope book. cheers, clemens
>> <span tal:replace="/dcII/standard_html_header">header</span> >> <span tal:replace="here/../standard_html_header">header</span> Clemens> ... and the third combination in this row would be Clemens> <span tal:replace="here/dcII/standard_html_header">header</span> Thank you. Actually, as it turns out <span tal:replace="here/standard_html_header">header</span> is sufficient (once you add "structure " to the replace expression). Clemens> If You do not understand why this works You may want to revisit Clemens> the "Acquisition" chapter in the Zope book. Maybe so, but what information I see about acquisition appears to be buried in a chapter entitled "Dynamic Content with DTML", not the first place I would think to look, especially because I'm trying to avoid DTML. Not surprisingly, examples in that chapter such as <dtml-var standard_html_header> won't help a new user much with the syntax necessary how to get the same result using page templates. What examples the page template chapters contain don't seem to deal with acquisition at all. -- Skip Montanaro - skip@pobox.com http://www.mojam.com/ http://www.musi-cal.com/
Skip, A new version of the Zope Book that has a chapter on acquisition is available at http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition. I hope to make this the "current" edition soon, although I'm battling a lack of "tuits" to do the necessary work. - C On Mon, 2002-11-04 at 12:59, Skip Montanaro wrote:
>> <span tal:replace="/dcII/standard_html_header">header</span> >> <span tal:replace="here/../standard_html_header">header</span>
Clemens> ... and the third combination in this row would be
Clemens> <span tal:replace="here/dcII/standard_html_header">header</span>
Thank you. Actually, as it turns out
<span tal:replace="here/standard_html_header">header</span>
is sufficient (once you add "structure " to the replace expression).
Clemens> If You do not understand why this works You may want to revisit Clemens> the "Acquisition" chapter in the Zope book.
Maybe so, but what information I see about acquisition appears to be buried in a chapter entitled "Dynamic Content with DTML", not the first place I would think to look, especially because I'm trying to avoid DTML. Not surprisingly, examples in that chapter such as
<dtml-var standard_html_header>
won't help a new user much with the syntax necessary how to get the same result using page templates. What examples the page template chapters contain don't seem to deal with acquisition at all.
-- Skip Montanaro - skip@pobox.com http://www.mojam.com/ http://www.musi-cal.com/
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Chris> A new version of the Zope Book that has a chapter on acquisition Chris> is available at Chris> http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition. Thanks for the reference. I'll check it out. Are page templates featured more prominently outside the chapters which directly address them? Thx, Skip
On Mon, 2002-11-04 at 13:42, Skip Montanaro wrote:
Chris> A new version of the Zope Book that has a chapter on acquisition Chris> is available at Chris> http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition.
Thanks for the reference. I'll check it out. Are page templates featured more prominently outside the chapters which directly address them?
No, other chapters really haven't been rewritten to give page templates as much airtime as DTML, unfortunately. - C
Hi Skip, ... snip ...
<span tal:replace="here/standard_html_header">header</span>
is sufficient (once you add "structure " to the replace expression).
The problem is, you should not try to 1:1 translate DTML examples to ZPT. If you do so, you would undermine its use. Instead of assembling a page out of small parts (like DTML does), in ZPT you use template pages which look like the resulting page, for example like this: <html metal:define-macro="master"> <head>...</head> <body> <div class="yourheader">Headernavigation... whatever</div> <div class="side">Side of the page</div> <div class="body" metal:define-slot="contents">contents of the page - should be more structured</div> </body> </html> If you view this page, you can see the HTML and design it to your needs, even scripts can run there, for example to build navigation elements or more. Then you would start designing an actual content page like this: <html metal:use-macro="here/mastertemplate/macros/master"> </html> [x] expand macros when editing and press "Save Changes" Then your page looks like this: <html metal:use-macro="here/mastertemplate/macros/master"> <head>...</head> <body> <div class="yourheader">Headernavigation... whatever</div> <div class="side">Side of the page</div> <div class="body" metal:fill-slot="contents">contents of the page - should be more structured</div> </body> </html> Note that define-slot now becomes fill-slot. This is the part you will change in your page. There can (and probably should) be more then one slot in the page where you can change the contents Regards Tino
Tino> The problem is, you should not try to 1:1 translate DTML examples Tino> to ZPT. If you do so, you would undermine its use. Instead of Tino> assembling a page out of small parts (like DTML does), in ZPT you Tino> use template pages which look like the resulting page, for example Tino> like this: ... Thanks, that helps. Tino> Then you would start designing an actual content page like this: Tino> <html metal:use-macro="here/mastertemplate/macros/master"> Tino> </html> Tino> [x] expand macros when editing and press "Save Changes" I thought I saw someone else say recently that macro expansion while editing is vile. -- Skip Montanaro - skip@pobox.com http://www.mojam.com/ http://www.musi-cal.com/
On Mon, Nov 04, 2002 at 10:36:02AM -0600, Skip Montanaro wrote:
/dcII /dcII/add_contact /dcII/add_contact/index_html /dcII/standard_footer /dcII/standard_header
and .../index_html is a page template, how to I reference /dcII/standard_{header,footer}?
<span tal:replace="here/standard_header"> header</span> will do it, as Zope objects can "acquire" stuff further up the tree. so in this case it will keep looking in parent folders until it finds something called "standard_header". By the way - if standard_footer contains markup rather than just text, you'll want to use: <span tal:replace="structure here/standard_header"> header</span> This will make sure that the stuff from standard_header is not html-quoted. hth Felix.
Skip Montanaro writes:
If I have the following objects
/dcII /dcII/add_contact /dcII/add_contact/index_html /dcII/standard_footer /dcII/standard_header
and .../index_html is a page template, how to I reference /dcII/standard_{header,footer}? I tried both of the following:
<span tal:replace="/dcII/standard_html_header">header</span> <span tal:replace="here/../standard_html_header">header</span>
Try: "structure here/standard_html_header" or: "structure here/dcII/standard_html_header" Dieter
participants (6)
-
Chris McDonough -
Clemens Robbenhaar -
Dieter Maurer -
Felix Ulrich-Oltean -
Skip Montanaro -
Tino Wildenhain