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 07, 2013 @ 17:34
    Meni
    0

    Try to sort Node - get error - HELP!!! Thx :)

    So the thing is like this: In my magazine I have two nodes which contains more than one topic. So when I display the Archive pages I distinguish between them by check their checkbox and then I display just nodes from the selected topic. The problem is that I'm get kind of "Holes" because if for example the pagination variable declare to show 20 posts on each page, now if the first 13 items are from topic 1, then there are another 24 items of topic 2 so the second page will be empty. 

    So, I got advise to simply build a new node which contain just the selected topic and show it like I show the other nodes which contain just one topic and there isn't any problem with them.

    So, this the way I create the Node using the "Where" sentence - however, I get just errors...

    if (Category_item == "Gadgets") //Select the requested topic to build to new node
        {
               // pagesToList will be the new node 
            // magazine_node - is the node that contains few topics and I want to sort it -        // mean - to build a new node (pagesToList) which contain just the selected items -      //in this case topics about gadgets        
           pagesToList = magazine_node.DescendantsOrSelf.Where(Model.GetProperty("opliCategory").Value.ToString() == "Gadgets");
        }
    // opliCategory is the checkbox value and Gadgets is the selected topic

    What I'm doing wrong? 

    I know that the error / problem is somewhere after the "pagesToList = magazine_node.DescendantsOrSelf" - Here.

    Because if I just left it like this - pagesToList = magazine_node.DescendantsOrSelf - there is no error But there isn't sort effect also ...

    HELLLLLLLLLLLLLLLLP!!

    Thanks :)


  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jul 08, 2013 @ 12:12
    Jeroen Breuer
    0

    If you are using the "old" razor this blog might help: http://umbraco.com/follow-us/blog-archive/2011/3/1/umbraco-razor-feature-walkthrough-%E2%80%93-part-4

    The where statement should always be a string with the old razor.

    Jeroen

  • Meni 277 posts 534 karma points
    Jul 11, 2013 @ 00:03
    Meni
    0

    So, if I understand your answer maybe I'm use the old Razor? (I'm using v6.0.5) 

    And if yes - so the way to solve it is to use the \" \" ? (this what I understand from the link)

    So, I tried this

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

    Still not work ...

     

    Any other idea pls ... ? 

    Thanks. 

  • Meni 277 posts 534 karma points
    Jul 18, 2013 @ 16:42
    Meni
    0

    Anybody ... ?

    Other way to do it?

     

    Maybe with foreach loop and add ?

     

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft