1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- [%
- # Load the sitemap once per build and cache it for reuse on each page.
- IF !global.cached.xpath;
- USE xpath = XML.XPath("lib/sitemap.xml");
- global.cached.xpath = xpath;
- END;
- BLOCK breadcrumbs;
- my_path = "${template.name}"|replace('/index.html|/index.en.html','/')|replace('.html|.en.html','');
- nodes = [global.cached.xpath.findnodes("//page[@url='$my_path']")];
- UNLESS nodes;
- my_id = "${template.name}"|replace('/index.html|/index.en.html|.html|.en.html','')|replace('^.+/','');
- nodes = [global.cached.xpath.findnodes("//page[@id='$my_id']")];
- END;
- PROCESS crumb crumbs=[] node=nodes.0;
- u = "";
- FOREACH crumb IN crumbs.reverse;
- IF loop.first;
- "<a href=\"$toplink\">Home</a> ";
- END;
- " » ";
- IF loop.last;
- "<span>$crumb.title</span>";
- ELSE;
- IF crumb.url;
- u = "$crumb.url";
- ELSE;
- u = "$u/$crumb.id";
- END;
- "<a href=\"$toplink$u\">$crumb.title</a>";
- END;
- END;
- END;
- BLOCK crumb;
- IF node && node.getName() == "page";
- crumbs.push({ title => node.getAttribute("title"),
- id => node.getAttribute("id"),
- url => node.getAttribute("url") });
- PROCESS crumb node=node.getParentNode();
- END;
- END;
- %]
|