[PEAK] Example using sitemap.xml and bulletins

Phillip J. Eby pje at telecommunity.com
Sat Mar 26 15:28:13 EST 2005


At 06:58 PM 3/26/05 -0100, Tiago Cogumbreiro wrote:
>On Sat, 26 Mar 2005 14:30:57 -0500, Phillip J. Eby
><pje at telecommunity.com> wrote:
> > As part of this, I'd also get rid of the 'bulletins.databaseURL' property
> > and change the 'bulletins' start file to read something like:
> >
> >      [Named Services]
> >      bulletins.db = naming.LinkRef("sqlite:///tmp/bulletins.db")
>What about the DDL?

It would remain the same.


> > >Can I embedd views inside of each other?
> >
> > I don't understand the question.
> >
> >
>I was trying to ask if I could could reuse views/templates inside each
>other.

Within a template, the 'this:replace' and 'content:replace' operations will 
insert the specified view of the "current object".  Or more precisely, they 
will use URL traversal from the current object to the supplied path.


>I was thinking in terms of the widget analogy.

Yes, view templates can be HTML snippets to create widgets.  In fact, by 
default a template can only be used as a web page if it contains a 
definition for "page" or "page-layout"; otherwise it is only usable as a 
"fragment"; i.e. it is only embeddable within other templates, and not 
usable as a standalone page.

A "layout" is a template that acts as a macro for laying out a page or 
fragment.  Within a layout template, you use paths like "/params/foo" to 
refer to blocks that were defined in the calling template.  This is 
basically the same as ZPT macros, except that instead of fill-slot you use 
"this:is" or "content:is" attributes to name blocks, and instead of 
define-slot you use "this:replace='/param/slotName'" or 
"content:replace='/param/slotName'" in the layout to insert the supplied data.

But this is something that probably should be left to a tutorial document, 
as for simple things you don't need any layouts at all, but peak.web can 
actually use the same template as both a fragment and a page, and lay the 
information out in different ways depending on how it is being used.  This 
is particularly useful for creating components that can then work within 
the look-and-feel of any site.  To some extent, this will require a common 
vocabulary of parameters or slot names, however.

Anyway, the simplest way to have a template work as a page is to add 
"with:page-layout='/default'" as an attribute on the outermost XHTML 
element of your template.  You do not need to do anything special to make a 
template work when referenced by another template, unless you want it to 
only use part of the page.

For example, suppose you've created a template that displays a bulletin 
object, and you'd like to embed it in another page that displays multiple 
bulletins, but you'd also like it to work as a standalone page.  You can do 
this by marking the document with "this:is='page'", and by marking the 
inner part that just displays the bulletin as "this:is='fragment'".  Then, 
when you go directly to that view template via a web browser, the whole 
template is rendered.  But, if you reference it from inside another 
template, then only the part marked as a fragment will be displayed.




More information about the PEAK mailing list