Modular Layout in ZOPESilva - PowerPoint PPT Presentation

1 / 4
About This Presentation
Title:

Modular Layout in ZOPESilva

Description:

(c) 2003, Thomas Duebendorfer, ETH Zurich, Switzerland - GNU GPL. 1. Modular Layout in ZOPE/Silva. Problem: ... silva. metal:fill-slot= 'meta' content.html ... – PowerPoint PPT presentation

Number of Views:51
Avg rating:3.0/5.0
Slides: 5
Provided by: thomasdue
Category:

less

Transcript and Presenter's Notes

Title: Modular Layout in ZOPESilva


1
Modular Layout in ZOPE/Silva
  • Problem How can one redefine only a part (e.g.
    regions A,B,C in the picture) of the web page
    layout in a subfolder without duplicating any
    reused (e.g. regions H, N, F in the picture)
    layout parts?
  • Solution The ZOPE macro-slot filling mechanism
    is not powerful enough as it does not allow to
    that only a few slots (defined in content.html)
    are overridden in a subfolder. Hence, we split
    the layout_macro.html into several
    filesmain.html contains the layout of regions
    A, B, C and layout_macro.html contains the layout
    of regions H, N, F.
  • Now, main.html (which actually defines the
    contents of a table cell in layout_macro.html)
    can be overriden (thanks to ZOPEs acquisition)
    in subfolders and the rest of the layout can be
    reused. The inclusion of main.html into
    layout_macro.html happens through macro
    expansion. On the following pages, a possible
    implementation is shown and main.html is even
    split into further files (region B and C get
    their own layout files) for full flexibility.In
    order to use some default fallback files for
    non-existing layout-files, we use a small python
    script to generate the path to each layout file.

H
B
A
F
2
Reusable and modular Content/Layout Templates
Fill-slot meta Fill-slot nav Fill-slot
footer
define-macro ethlife
content_macro_ ethlife.html
define-macro fav_links
content_macro_ fav_links.html
content.html
main.html
defines macro-slots for Header Navigation
and Footer
define-macro main
layout_macro.html
content_macro_ main.html
3
Reusable and modular Content/Layout Templates
lthtml metaluse-macro /layout gt ltsilva
metalfill-slot meta gt
lthtml metaldefine-macro layout gt ltmetal
block define-slotmeta gt ltTABLE
metaluse-macro here/main.html/ macros/maingt
lt/TABLEgt
ltTABLE metaldefine-macro main gt ltspan
talomit-tag taldefinemacropath
pythonpath( here.getContentPath( ethlife))gt
ltspan metaluse-macro macropathgt
lt/spangt lt/spangt ltspangt fav_links
lt/spangt lt/TABLEgt
ltspan metal define-macro ethlife gtlt/spangt
content_macro_ ethlife.html
ltspan metal define-macro fav_links gtlt/span
gt
content.html
defines macro-slots for Header Navigation
and Footer
content_macro_ fav_links.html
layout_macro.html
main.html
4
Python script for path generation
  • getContentPath(macroname)
  • Returns a list of paths that lead to content
    macros
  • (c) 4.12.2002, Thomas Duebendorfer, GNU GPL
  • The returned list of ""-separated paths make
    ZOPE do the following
  • 1. Use override Mechanism (no traversal)
  • Use macro ltmacronamegt in override_ltcontent_m
    acrogt if it exists at the request path location
    (no traversal).
  • If file exists but has not the searched
    macro in it, then call macro "bad_override" in
    file ltcontent_macros_filegt.
  • 2. Find macro ltmacronamegt by traversing the
    hierachy
  • Look at the first file named
    ltcontent_macrogt starting at request path location
    and call macro ltmacronamegt in it.
  • On error Look for a file
    ltcontent_macros_filegt and call macro ltmacronamegt
    in it.
  • On error Call macro "no_contents" in file
    ltcontent_macros_filegt.
  • Note The default filename for a macro with
    name ltmacronamegt is ltcontent_macro_prefixgt
    ltmacronamegt '.html'
  • override_prefix 'override_'
  • content_macro_prefix 'content_macro_'
  • content_macros_file 'content_macros.html'
  • nocontentsmacro content_macros_file
    '/macros/no_contents'
Write a Comment
User Comments (0)
About PowerShow.com