templates/layout.tmpl
changeset 12 2abc5ace0b15
parent 11 fa216534ae45
child 20 d40c339d3778
--- a/templates/layout.tmpl	Sat Feb 07 01:33:30 2009 +0200
+++ b/templates/layout.tmpl	Sat Feb 07 02:12:32 2009 +0200
@@ -1,5 +1,18 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
+<%def name="render_menu(open_page, page, items, ancestry)">
+<ul>
+% for pi in items :
+    <li>
+        <a href="${site_page_url}/${pi.url}"${' class="selected-page"' if pi == open_page else ''}>${pi.title} ${'&raquo;' if pi.children and pi.parent else ''}</a>
+    % if pi in ancestry and pi.children and pi.parent :
+        ${render_menu(page, pi, pi.children, ancestry)}
+    % endif
+    </li>
+% endfor
+</ul>
+</%def>
+
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
     <head>
         <title>qmsk.net :: ${page.title}</title>
@@ -9,15 +22,10 @@
             <div id="header">
                 <a href="${site_page_url}/">QMSK.NET</a>
             </div>
- 
-            <ul id="nav">
-            % if menu.page.parent and menu.page.parent.parent :
-                <li><a href="${site_page_url}/${menu.page.parent.url}">&laquo;</a></li>
-            % endif
-            % for pi in menu.items :
-                <li><a href="${site_page_url}/${pi.url}"${' class="selected-page"' if pi.url == page.url else ''}>${pi.title} ${'&raquo;' if pi.children and pi.parent else ''}</a></li>
-            % endfor
-            </ul>
+            
+            <div id="nav">
+                ${render_menu(menu.page, menu.page, menu.items, menu.ancestry)}
+            </div>
 
             <div id="content">
                 ${page.content}