Index: magnolia-taglib-utility/src/main/resources/META-INF/cms-util-taglib.tld
===================================================================
--- magnolia-taglib-utility/src/main/resources/META-INF/cms-util-taglib.tld (revision 17838)
+++ magnolia-taglib-utility/src/main/resources/META-INF/cms-util-taglib.tld Wed Sep 03 10:52:36 MDT 2008
@@ -298,7 +298,17 @@
true
-
+
+ The anchorIDStrategy is used to apply an ID to the anchor. The default strategy is "none" which means
+ that no ID is applied to the anchor. The only other implemented strategy is "pageName" which will give
+ the anchor an ID that is equal to the page name that it points to.
+
+ anchorIDStrategy
+ false
+ true
+
+
+
When specified, all links will have the anchortext wrapped in the supplied element (such as "span")
wrapperElement
@@ -306,6 +316,15 @@
true
+
+ Set this to "relative" if you want to treat the start level and end level as being relative to the active
+ page. The default value is "normal".
+
+ levelResolvingMethod
+ false
+ true
+
+
Name for the "nofollow" nodeData. If a page contains a boolean property with this name and it is
set to true, rel="nofollow" will be added to the generated link (for links the should be ignored by search
engines).
Index: magnolia-taglib-utility/src/main/java/info/magnolia/cms/taglibs/util/SimpleNavigationTag.java
===================================================================
--- magnolia-taglib-utility/src/main/java/info/magnolia/cms/taglibs/util/SimpleNavigationTag.java (revision 17838)
+++ magnolia-taglib-utility/src/main/java/info/magnolia/cms/taglibs/util/SimpleNavigationTag.java Wed Sep 03 10:54:35 MDT 2008
@@ -157,6 +157,26 @@
public static final String EXPAND_NONE = "none";
/**
+ * Relative mode adjusts the start and end level based on the parent page
+ */
+ public static final String LEVEL_MODE_RELATIVE = "relative";
+
+ /**
+ * Normal level mode is the default move
+ */
+ public static final String LEVEL_MODE_NORMAL = "normal";
+
+ /**
+ * Give the anchor for a created link an ID with the the pageName that it points to
+ */
+ public static final String ANCHOR_ID_STRATEGY_PAGE_NAME = "pageName";
+
+ /**
+ * Give the anchor no ID
+ */
+ public static final String ANCHOR_ID_STRATEGY_NONE = "none";
+
+ /**
* Stable serialVersionUID.
*/
private static final long serialVersionUID = 224L;
@@ -167,6 +187,11 @@
private static Logger log = LoggerFactory.getLogger(SimpleNavigationTag.class);
/**
+ * Active page level.
+ */
+ private int activePageLevel = 0;
+
+ /**
* Start level.
*/
private int startLevel;
@@ -197,6 +222,12 @@
public String wrapperElement;
/**
+ * A strategy to determine how (and if) to apply ID to apply to the anchor text
+ * - default is to apply no ID to the anchor.
+ */
+ public String anchorIDStrategy = ANCHOR_ID_STRATEGY_NONE;
+
+ /**
* Expand all the nodes (sitemap mode)
*/
private String expandAll = EXPAND_NONE;
@@ -207,6 +238,11 @@
private String classProperty;
/**
+ * Property determining how to handle the levels...
+ */
+ private String levelResolvingMethod = LEVEL_MODE_NORMAL;
+
+ /**
* Name for the "nofollow" hodeData (for link that must be ignored by search engines).
*/
private String nofollow;
@@ -312,6 +348,26 @@
}
/**
+ * The Start and EndLevel can be treated as relative levels by passing in "relative"
+ * so an endLevel of 2 and a levelResolvingMethod of "relative" will show pages 2 levels deeper than the
+ * current page regardless of what level that page starts at.
+ *
+ * @param levelResolvingMethod
+ */
+ public void setLevelResolvingMethod(String levelResolvingMethod) {
+ this.levelResolvingMethod = levelResolvingMethod;
+ }
+
+ /**
+ * Setter for anchorTextID
tag attribute
+ * @param anchorIDStrategy is this is set to "pageName" the page will be given a CSS ID with the page name
+ * @jsp.attribute required="false" rtexprvalue="true"
+ */
+ public void setAnchorIDStrategy(String anchorIDStrategy) {
+ this.anchorIDStrategy = anchorIDStrategy;
+ }
+
+ /**
* @see javax.servlet.jsp.tagext.Tag#doEndTag()
*/
public int doEndTag() throws JspException {
@@ -334,6 +390,14 @@
}
try {
+ activePageLevel = activePage.getLevel();
+
+ // if we are to treat the start and end level as relative
+ // to the active page, we adjust them here...
+ if (this.levelResolvingMethod.equals(LEVEL_MODE_RELATIVE)) {
+ this.startLevel += activePageLevel;
+ this.endLevel += activePageLevel;
+ }
if (this.startLevel <= activePage.getLevel()) {
Content startContent = activePage.getAncestor(this.startLevel);
drawChildren(startContent, activePage, out);
@@ -365,6 +429,9 @@
this.expandAll = EXPAND_NONE;
this.wrapperElement = "";
this.contentFilter = "";
+ this.anchorIDStrategy = ANCHOR_ID_STRATEGY_NONE;
+ this.activePageLevel = 0;
+ this.levelResolvingMethod = LEVEL_MODE_NORMAL;
this.filter = null;
this.nofollow = null;
super.release();
@@ -497,6 +564,10 @@
out.print("\""); //$NON-NLS-1$
}
+ if ( StringUtils.equals(this.anchorIDStrategy, ANCHOR_ID_STRATEGY_PAGE_NAME) ) {
+ out.print(" id='" + child.getName() + "' ");
+ }
+
if (nofollow != null && child.getNodeData(this.nofollow).getBoolean())
{
out.print(" rel=\"nofollow\""); //$NON-NLS-1$