Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jesper Ordrup 1019 posts 1528 karma points MVP
    Mar 19, 2010 @ 11:58
    Jesper Ordrup
    0

    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:

    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?

    Thx

    Jesper Ordrup

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Mar 19, 2010 @ 15:13
    Dirk De Grave
    0

    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);

    Could you give an example of what to accomplish?

     

    Cheers,

    /Dirk

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Mar 19, 2010 @ 15:24
    Jeroen Breuer
    0

    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.

  • Jesper Ordrup 1019 posts 1528 karma points MVP
    Mar 19, 2010 @ 19:31
    Jesper Ordrup
    0

    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

     

Please Sign in or register to post replies

Write your reply to:

Draft