Author: andre
Date: 2009-11-26 19:27:33 +0100 (Thu, 26 Nov 2009)
New Revision: 39989

Modified:
   openimages/trunk/mmsite/src/main/config/functions/mmsite.xml
   openimages/trunk/mmsite/src/main/java/org/mmbase/mmsite/UrlUtils.java
Log:
added just one more function to get the top most node in a path

Modified: openimages/trunk/mmsite/src/main/config/functions/mmsite.xml
===================================================================
--- openimages/trunk/mmsite/src/main/config/functions/mmsite.xml        
2009-11-26 17:19:09 UTC (rev 39988)
+++ openimages/trunk/mmsite/src/main/config/functions/mmsite.xml        
2009-11-26 18:27:33 UTC (rev 39989)
@@ -4,6 +4,17 @@
 <version>2</version>
 <description>Taglib functions for MMSite, like sitestructure etc.</description>
 
+  <function name="root">
+       <description>
+         Get the 'root' node of a crumbpath.
+       </description>
+       <type>class</type>
+       <class>org.mmbase.mmsite.UrlUtils</class>
+       <method>root</method>
+       <param name="node" type="Node" description="A node f.e. of type page" />
+    <return type="org.mmbase.bridge.Node" /> 
+  </function>
+  
   <function name="crumbs">
        <description>
       Returns a NodeList containing nodes of the same (!) type travelling the 
path to the 'root' 

Modified: openimages/trunk/mmsite/src/main/java/org/mmbase/mmsite/UrlUtils.java
===================================================================
--- openimages/trunk/mmsite/src/main/java/org/mmbase/mmsite/UrlUtils.java       
2009-11-26 17:19:09 UTC (rev 39988)
+++ openimages/trunk/mmsite/src/main/java/org/mmbase/mmsite/UrlUtils.java       
2009-11-26 18:27:33 UTC (rev 39989)
@@ -43,11 +43,22 @@
     }
 
     /**
+     * Get the '(most) root' node, being the (grand)parent of all the nodes in 
the crumbpath.
+     *
+     * @param  node    A node of some type with a field 'path'
+     * @return the node highest to the top, often the homepage
+     */
+    public static Node root(Node node) {
+        NodeList l = listNodes2Root(node);
+        return l.get(l.size() - 1);
+    }
+    
+    /**
      * Retrieve a pages node with a certain path.
      *
      * @param   cloud   MMBase cloud
      * @param   path    Value of field path, f.e. '/news/new'
-     * @return  null if not found
+     * @return  a 'pages' node or null if not found
      */
     protected static Node getPagebyPath(Cloud cloud, String path) {
         Node node = null;

_______________________________________________
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to