sidebar.tmpl 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. [% USE site = XML::Simple(
  2. 'sitemap.xml'
  3. ForceArray = ['page']
  4. KeyAttr = ['' ]
  5. )
  6. %]
  7. [% INCLUDE explore node=site;
  8. BLOCK explore;
  9. # nodes is already set by breadcrumbs.tmpl
  10. PROCESS crumblist urllist=[] cnode=nodes.0;
  11. itemcount = 0;
  12. FOREACH page IN node.page;
  13. IF page.url;
  14. IF page.url.match("^http://") OR page.url.match("^https://");
  15. page.path = page.url;
  16. ELSE;
  17. page.path = (page.url == '.') ? toplink : "$toplink$page.url";
  18. END;
  19. ELSE;
  20. # add page id to current path to get page path
  21. page.path = "$toplink$path/$page.id";
  22. # add suffix for a section (/index.html) or page (.html)
  23. suffix = page.page ? '/index.en.html' : '.en.html';
  24. page.url = "${page.path}${suffix}";
  25. END;
  26. # add complete URL to sitemap lookup table
  27. site.url2page.${page.url} = page;
  28. t_url = "$toplink${template.name}"|replace('/index.html|/index.en.html','/')|replace('.html|.en.html','');
  29. in_list = 0;
  30. FOREACH url IN urllist;
  31. IF page.path == "$toplink$url";
  32. in_list = 1;
  33. END;
  34. END;
  35. IF !page.hide || in_list;
  36. IF itemcount == 0;
  37. node == site ? "<ul id=\"nav\">" : "\n<ul>";
  38. "\n";
  39. END;
  40. itemcount = itemcount + 1;
  41. # print some debugging info
  42. # "page: $page.id\n path: $page.path\n url: $page.url\n" | stderr;
  43. "\t<li><a href=\"$page.path\">$page.title</a>";
  44. # process and child nodes
  45. INCLUDE explore node=page path=page.path
  46. IF page.page AND (t_url.match("^$page.path") OR in_list);
  47. "</li>\n";
  48. END;
  49. END;
  50. IF itemcount > 0;
  51. "</ul>\n";
  52. END;
  53. END;
  54. BLOCK crumblist;
  55. IF cnode && cnode.getName() == "page";
  56. urllist.push(cnode.getAttribute("url"));
  57. PROCESS crumblist cnode=cnode.getParentNode();
  58. END;
  59. END;
  60. %]