
100
Serena® Collage® 5.1.3
Chapter 3 Design-Time Component Reference
You can use JavaScript to define logic that will create navigation buttons for sub-topics (in
this case Employees and Policies) when you click or hover on the parent topic with 1 or
more children:
Generating Node Name
To add the name of the node to the navigation control which is generated by the NavMap
component, use the
$node.name
macro. You can use this to display the node name, in
order to name navigation links.
Generating a Node URL
To generate the link to the node, use the
$node.url
macro. The
$node.url
macro
returns the path to the node. For example, to link to and display the name of a node:
<a href="$node.url">$node.name</a>
NavMap Example: Passing Node Values
into JavaScripts
One of the key benefits of the NavMap component is that it enables you to define a set of
values which you can then pass into even the most sophisticated JavaScript navigation
menus. This section looks at a simple example of a way that you can use the NavMap
component to generate JavaScript arrays which are populated with data about all of your
site nodes, and which additional JavaScripts can access.
The example NavMap component below generates arrays for each node in a site structure,
each of which stores the navigation data that the NavMap component can return:
<nexus:component classid="nexus/components/NavMap"
code="$nexusComponents" dwcomptype="navmap" sitestructure="/
website/website.site">
<script language="JavaScript">
node[i] = new Array("$node.name","$node.url",
$node.level,$node.children);
i++;
</script>
</nexus:component>
For each node in the site structure, Collage will generate the script above, but with the
actual values in place of the macros. For example, if there are just two nodes, Collage will
generate something like the following:
<script language=JavaScript">
node[i] = new Array("Home", "index.html", 1, 1);
i++;
</script>
Commenti su questo manuale