Copied to clipboard

Flag this post as spam?

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


  • Meni 277 posts 534 karma points
    Jul 19, 2013 @ 15:33
    Meni
    0

    How to build a new node from existing one?

    Hello, I have a node which contain childrens. I want to build a new node which contain just a certain childrens that I"ll choose - how can I do it with a loop? I saw the add statement - how do I use it? Couldn't success with the Where statement (tried but it doesn't work - my condition is if a checkbox match a category name and just cant get the result I like so maybe it will work "Manually" ...)Thanks. Menachem .

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jul 22, 2013 @ 10:29
    Jeavon Leopold
    0

    Hi Meni,

    Can you please confirm, are you looking to create new nodes in the tree by copying others as the new nodes children?

    If you have any code you could post that would be helpful in understanding what you are trying to do.

    Thanks,

    Jeavon

     

  • Meni 277 posts 534 karma points
    Jul 22, 2013 @ 15:09
    Meni
    0

    Hi Jeavon,

    No no, Not tryoing to build a new tree - Just try to sort existing node... - I already posted the code here in the forum but didn't get answer...

    Here is the problem: In my magazine each node contain a section in the magazine (like gadgets, photography, etc). Now, the problem is with two nodes which contains more than one section - Photography and gadgets in one node. The reason is btw - in order to display them together in the homepage. The problem is in the archive pages where I want to display them in seperate. Somehow it just doesn't work with the "where" statement. I distinguish between the topics with a checkbox - doesn't work. So I thought maybe to just build a new node with the requested childrens and then display them.

    This is what I tried till now (W/O success...)

    pagesToList = magazine_node.DescendantsOrSelf().Where("Model.GetProperty(\"opliCategory\").Value.ToString() == \"Gadgets\"");

     

    Just thought maybe to de it with Foreach loop that's it. And then inside the loop to pick the selected topic with if statement

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jul 22, 2013 @ 15:38
    Jeavon Leopold
    0

    Obviously I'm not quite sure what else you are doing and I'm assuming you are using DynamicNode rather than Mvc, but this works and might help?

        var magazine_node = Model.AncestorOrSelf(1);
        var pagesToList = magazine_node.DescendantsOrSelf().Where("opliCategory == @0", "Gadgets");
        foreach (var page in pagesToList)
        {
            <p>@page.Name</p>
        }

     

  • Meni 277 posts 534 karma points
    Jul 23, 2013 @ 02:53
    Meni
    0

    WoW! work LIKE A MAGIC!!!! Thank you so much !!! :)

     

    So, just want to understand what was wrong with my condition .. ?

    Where("Model.GetProperty(\"opliCategory\").Value.ToString() == \"Gadgets\"");

    and what's  the meaning of this:

    Where("opliCategory == @0","Gadgets");

    Just to learn ...

    Thanks :)

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jul 25, 2013 @ 14:29
    Jeavon Leopold
    0

    Awesome, basically you are mixing typed syntax with dynamic. Mainly when using DynamicNode you will be using dynamic syntax.

    To use the condition in the way you orginally had you would need to do something like this using the Typed DynamicNode:

     @{
        var magazine_node = new DynamicNode(Model.AncestorOrSelf(1).Id);
        var pagesToList = magazine_node.DescendantsOrSelf().Where(x => x.GetPropertyValue("Gadgets") == "Gadgets");
        foreach (dynamic page in pagesToList)
        {
            <p>@page.Name</p>
        }
    }

    FYI, the documentation for using a .Where filter in DynamicNode is here.

Please Sign in or register to post replies

Write your reply to:

Draft