...
There is a "navigation.jar" file which must live in the /WEB-INF/lib directory of the webapp. It defines a JSP tag library which can be used to get navigation/breadcrumb/sitetree information. This library causes the webapp to crawl its structure constantly in the background (on a low priority thread). The webapp periodically updates a global "SiteTree" object representing all the navigation information about the site.
Note | ||
---|---|---|
| ||
In the virtualization server environment with many webapps, this can be slow. That means that for people using the Preview button, you may have to wait some time before any changes to the global SiteTree are picked up. This does not mean that people have to wait to see something; just that they see an older version of the information. If they refresh after enough time has gone by, they will see the newest information. On a production system, which is running (probably) just the one webapp, this will be fast. I have tested this system on a Tomcat instance running on a local machine, crawling a site with 3,000 files in it. It took approximately one half of a second between updates. Again, no user has to wait an extra half of a second for their browser to show a page; the page will be rendered at the normal time, but with information which may be up to a half of a second old. |
...
The web application automatically generates navigation information for your web project. If you do not tell it to do something differently, it will generate default titles for the sections and pages in your site. By default, every folder (except META-INF and WEB-INF) in the site will be a Section whose title is the same as the name of the folder. Also, every file (*note to self:
Info | ||
---|---|---|
| ||
I probably should make this just .html, .htm, .xhtml, .jsp, or .jspx files |
) in the site will be a Page whose title is the same as the name of the file (without the extension). In some cases this will be what you want. In other cases, you will want to alter the default behavior by controlling the navigation information yourself.
You may control the navigation information on a per-folder level in your Alfresco Web Project via the web form named "Navigation Information". This web form manages a file in the current folder called "navigation.xml". If you have just created a new folder and you want to control its navigation information, you must choose Create > Create Web Content. Then you should create content via the "Navigation Information" web form as shown below:
Warning | |
---|---|
|
...
|
...
The information in the "Name:" field is ultimately ignored; the output file will always be named "navigation.xml". Unfortunately the "Name" field is mandatory, so you are forced to type something in there. Sigh. |
...
If you have already created the navigation.xml file for a folder and you want to alter it, you can do so by clicking the edit (pencil) icon on the navigation.xml file. (Note: if
Warning | ||
---|---|---|
| ||
If you do the create web content steps above instead, you will end up clobbering the existing navigation.xml file. It is more likely you'd rather edit the file than write over it, but it's up to you. |
...
The form for editing/creating the navigation.xml file is shown below:
There are three types of fields to be filled out.
...
- To ignore a file so that it is not included as a Page: enter its file name e.g., "index-old.html", into the Url field.
- To ignore a folder so that it is not included as a child Section: enter the folder name (ideally ending with a slash) e.g., "junk/", into the Url field.
---
That's all there is to it for content authors.
...
Name | Type | Description |
---|---|---|
homeSection | Section | an object representing the Home Page (or Home Section) for the web site. You can recurse the tree starting from this section using the <nav:treeWalk> and <nav:subtreeWalk tags>. |
lastUpdated | java.util.Date | the datestamp when this site tree object was created. The site tree returned by <nav:setSiteTreeVar> should always be fairly new. If you are using a cached or stored SiteTree object (not recommended) this could be older. This property is provided primarily to help webapp developers develop and debug their application. |
timeToCreate | long | the time in milliseconds that it took to create this site tree object. It is a measure of how long it takes for the webapp to crawl the site. If the servlet container is running many such threads (virtualization server, hint hint) this could be a long-ish time. This property is provided primarily to help webapp developers develop and debug their application. |
Page Page (and Section)
This is an object representing a page or a section within the site tree. The basic object is a Page, which has a title and a URL. A Section is a special type of Page, which contains subpages. If a Page is not a Section, it does not contain subpages. (Note that all All Section objects are Pages, but not all Page objects are Sections.) To ease JSP programming, you can just treat all Sections as Pages, and use the "isASection" and "subpages" properties to access section-specific behavior.
...
This <nav:setSiteTreeVar> action sets a scoped variable to the object representing the current site tree. The site tree bean is useful for a JSP which generates a Site Index or Site Map page. Once you have set a variable to the site tree bean, you can walk through it with the <nav:treeWalk> and <nav:subTreeWalk> tags.
...
The <nav:treeWalk> and <nav:subtreeWalk> actions allow you to recursively walk through the site tree (or any tree structure). The idea is that the body of the <nav:treeWalk> tag is performed for every branch of the tree. The body of the <nav:treeWalk> tag must contain the <nav:subtreeWalk> tag, which indicates where to include the sub-branches in the tree walk. It's much easier to look at an example than to explain what I mean.
Warning | ||
---|---|---|
|
...
This is a simple tag, so you may not include jsp scripting elements (<% ... %>, <%= ... %>, etc.) inside the body of the <nav:treeWalk> tag. You |
...
may use only JSP tags inside the body. |
Syntax
Wiki Markup |
---|
<nav:treeWalk \[root="_theRootObject_"\] \[var="_currentNodeObjectVar_"\] \[depth="_currentDepthVar_"\] > ... <nav:subtreeWalk subroot="_subNodeObject_" /> ... </nav:treeWalk> |
...
No Format |
---|
<nav:setSiteTreeVar var="theSiteTree" /> <h3><ul><li> <nav:treeWalk root="${theSiteTree.homeSection}" var="page"> <a href="${page.url}" ><c:out value="${page.title}" /></a>:<br/> <ul><c:forEach items="${page.subpages}" var="subpage"> <li><nav:subtreeWalk subroot="${subpage}" /></li> </c:forEach></ul> </nav:treeWalk> </li></ul></h3> |
...
The following example gets and displays a breadcrumb for the currently requested page, since the "url" attribute is not set. (Tip:
Tip | ||
---|---|---|
| ||
This can be saved into its own JSP which is included in all JSPs on the web site to give a consistent breadcrumb look and feel and to avoid code duplication. |
...
No Format |
---|
<nav:setBreadcrumbVar var="breadcrumb" /> <c:forEach var="page" items="${breadcrumb}" varStatus="status"> <c:if test="${not status.first}">></c:if><a href="${page.url}" ><c:out value="${page.title}" /></a> </c:forEach> |
...
The following example displays a bulleted list of all links underneath the currently requested page, since the "url" attribute is not set. (Tip:
Tip | ||
---|---|---|
| ||
This can be saved into its own JSP which is included in all JSPs on the web site to give a consistent subnavigation look and feel and to avoid code duplication. |
...
No Format |
---|
<nav:setPageVar var="page"/> <c:forEach var="subpage" items="${page.subpages}" > • <a href="${subpage.url}" ><c:out value="${subpage.title}" /></a><br/> </c:forEach> |