Im trying to figure out if it's possible to add a different way to render subnodes in the existing content tree. What I want to achive is a dynamic rendering of content just like datefolders or firstletter folders (Tim Geyssen Packages).
Big difference is that I only want to display the nodes in different ways, not rearranging them physically.
First I tried this:
public MyEvent() { umbraco.cms.presentation.Trees.BaseTree.BeforeNodeRender += new umbraco.cms.presentation.Trees.BaseTree.BeforeNodeRenderEventHandler(BaseTree_BeforeNodeRender); }
void BaseTree_BeforeNodeRender(ref umbraco.cms.presentation.Trees.XmlTree sender, ref umbraco.cms.presentation.Trees.XmlTreeNode node, EventArgs e) { // find the children of node, add subnodes to tree and be happy? // but node contains no childcollection and sender contains only siblings? } }
... but neither sender nor node contains any ways to access the childnodes?
Can this be done? Another event? Or can I access the source xml tree before rendering starts?
I don't think it's a great idea to use this event to change the behaviour/appearance of the node. Event should be used for other purposes imho such as hiding, adding/removing menu items etc...
I'm sure tho you can still get a reference to the childnodes using
umbraco.presentation.nodeFactory.Node node = new umbraco.presentation.nodeFactory.Node(node.NodeID);
Maybe this can be usefull. Go to Tree API wiki and read the following part: 'Overriding the Content Tree'. Then you have more control over your tree rendering.
Of couse it's a great idea - besides I remember an example where Niels showed how to hide childnodes based on nodeTypeAlias but nevermind :-)
The example could be an article archive or a blog or many others. I'll try with the blog.
With the current blog4umbraco package all blogposts are organized in datefolders by adding nodes to the structure and moving the posts physically. The result is that all my blogposts are automagically organized in an year month day folders structure. And my url's reflect that.
I want the same - I still want to display the nodes in a date structure -but without moving the nodes around in the structure.
I've been reading the Tree API wiki and the umbraco.tv 'bout what is possible - but I dont see any way to add subnodes (when rendering).
Another approach could be which I mentioned in first post - is it possible to bind a "beforetreerenderstart" event and manipulate the xmltree. Is this possible?
Modifying content tree rendering
Im trying to figure out if it's possible to add a different way to render subnodes in the existing content tree. What I want to achive is a dynamic rendering of content just like datefolders or firstletter folders (Tim Geyssen Packages).
Big difference is that I only want to display the nodes in different ways, not rearranging them physically.
First I tried this:
... but neither sender nor node contains any ways to access the childnodes?
Can this be done? Another event? Or can I access the source xml tree before rendering starts?
Thx
Jesper Ordrup
I don't think it's a great idea to use this event to change the behaviour/appearance of the node. Event should be used for other purposes imho such as hiding, adding/removing menu items etc...
I'm sure tho you can still get a reference to the childnodes using
Could you give an example of what to accomplish?
Cheers,
/Dirk
Maybe this can be usefull. Go to Tree API wiki and read the following part: 'Overriding the Content Tree'. Then you have more control over your tree rendering.
Of couse it's a great idea - besides I remember an example where Niels showed how to hide childnodes based on nodeTypeAlias but nevermind :-)
The example could be an article archive or a blog or many others. I'll try with the blog.
With the current blog4umbraco package all blogposts are organized in datefolders by adding nodes to the structure and moving the posts physically. The result is that all my blogposts are automagically organized in an year month day folders structure. And my url's reflect that.
I want the same - I still want to display the nodes in a date structure -but without moving the nodes around in the structure.
I've been reading the Tree API wiki and the umbraco.tv 'bout what is possible - but I dont see any way to add subnodes (when rendering).
Another approach could be which I mentioned in first post - is it possible to bind a "beforetreerenderstart" event and manipulate the xmltree. Is this possible?
Best,
Jesper
is working on a reply...