[Zope3-Users] Building an admin interface
Stephan Richter
srichter at cosmos.phy.tufts.edu
Mon Jul 16 16:44:04 EDT 2007
On Monday 16 July 2007 15:58, Benji York wrote:
> This reminds me of something I've been curious about but haven't had
> time to research lately. What are the differences between pagelets and
> viewlets and their various strengths/weaknesses. An acceptable answer
> is "read the docs and decide for yourself". <wink>
Viewlets-pure UI design is a great approach, if you have portal, where there
is really never a main content area, since you can reuse viewlets accross
many pages. So in this UI pattern, you would create a "Contents" viewlet
manager, and register viewlets for this manager. Depending on which page you
are looking at, viewlets are picked up and displayed. Unfortunately, for
simple pages, this requires two directives: One to define the page and one to
define its "Contents" viewlet. This cost is very acceptable to a portal site
where those simple pages are rare, but are impractical for more traditional
Web applications.
Also, any piece of dynamic code is a viewlet manager with viewlets or a simple
content provider: left menu, right menu, header, CSS files, JS files, title,
etc.
Pagelet-based UI design is pretty much the same pattern, except that it allows
you to define a main content area. Here you define a layout template that is
used to define the O-wrap (pretty much like standard_macros/page). A page is
then registered as a pagelet, which defines a second template that defines
the content area of the page. As for macros, the advantage here is that you
only need one generic UI layout directive plus one other directive per page.
But something that is much nicer in pagelets is that you do not have to
include the macro from within the pagelet, but that the layout is driving
everything. Also, it is much simpler to register an alternative layout
template for a particular view or context.
All this can be combined with a simpler implementation of macros, provided by
z3c.macro, which only provides a flat namespace for all macros. Defining a
macro is a matter of doing something like this:
<z3c:macro
template="mytemplate.pt"
name="macroname" />
(Optionally, you can specify the context, view and layer for which the macro
is available.)
It can be used like this:
<div metal:use-macro="macro:macroname" />
Regards,
Stephan
--
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
More information about the Zope3-users
mailing list