|
Henrik Rydberg Dec 18, 2011 23:36 |
Creating navigationWhen you start creating your new site, one of the first things you think about is how to create the navigation. b:structure is a perfect tool for that. Here's few examples how to use it together with other tags to create a navigation. I would like to create a navigation which HTML would look like this: <ul> I'll start by using b:structure that lists pages the way they appear in Bildy content navigator. This B:tag needs two attributes: parent and name. Parent is the path to the place from which you want to list the pages. You can freely choose the name as long as it's unique and not any reserved word. I want to list all the pages from the top level, so I'll use / as the root: <ul> This will output the unordered list I wanted. Next, I'd like to highlight the page that is currently open. For that I'll use b:if and b:page.metadata.path <ul> Now class named "selected" will be included to the list element that is currently open. To list all the sub pages of the opened page, we could use b:navi.recursion. This calls the same query again, but I'll give it a new parent value. To get the UL tags in the beginning and the end of the sub list, I'll place them in b:before and b:after tags. <div id="navigation"> Now when I navigate to page /products/milk I get HTML: <div id="navigation"> I hope this gave you ideas for creating your own navigation. If you don't want to list certain pages in your navigation, set its publishing status to "hidden from the navigation". You can also limit pages by testing that they have certain template or datamodel. If you want your navigation to start from a certain level, you can use b:env.request tag with depth attribute as a b:getstructure parent value. |