Copied to clipboard

Flag this post as spam?

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


  • khansaa111 25 posts 55 karma points
    Jun 04, 2015 @ 12:24
    khansaa111
    0

    use .OrderBy("CreateDate desc").Take(int)

    hi everyone

    I want to use .OrderBy("CreateDate desc").Take(int) after the call of my data ,

    for example :

    <h5 class="toto"><a href="#">@child.alias.OrderBy("CreateDate desc").Take(1)</a></h5>

    but it s not work , how can i do dthat

    i need your help

    thank you so mush

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 04, 2015 @ 12:32
    Dennis Aaen
    0

    Hi khansaa111,

    You will need to add the .OrderBy("CreateDate desc").Take(int) where you are loop through the elements, so it could look something like this,

    @foraech(var child in CurrrentPage.Children.Where("Visible").OrderBy("CreateDate desc").Take(5)){ 
    
    }
    

    Hope this helps,

    /Dennis

  • khansaa111 25 posts 55 karma points
    Jun 04, 2015 @ 13:10
    khansaa111
    0

    hi Deninis  ,

    thank you for your answer

    well, I know that i have to use the syntax .OrderBy("CreateDate desc").Take(int) im loop : it's mean into the foreach ,

    but i have a problem !

    explication :) :

    I have 3 level My Content , I work in the homepage , &  I want to show the children of the children of my homepage , but on condition !

    show just the latest children whose type is " Transport "

    "Transport" : " is a choice among the choices of a dropdown .

    well , this is my code page

    @inherits UmbracoTemplatePage
    @{
      var Portal_home = CurrentPage.AncestorsOrSelf(1).First();
      var mylevel1 = Portal_home.Children.Where("UmbracoNaviHide == true");
    }



    <section class="col-actualite">
    <div style="border:1px solid red;" class="pavet_video">

      @foreach (var mylevel2 in mylevel1)
                   {
                   foreach (dynamic mylevel3 in mylevel2.Children.Where("Visible"))
                            {
                            
                            if (mylevel3.letype == "Transport")    
                                    {                      

                                          <!-- Dennis :  I need to add the .OrderBy("CreateDate desc").Take(int)  there , after if not before -->              
                                
                                <h5 class="h5-title-actu"><a href="#">@mylevel3.letype</a></h5>
                                <h5 class="h5-title-video"><a href="#">@mylevel3.titreAlaUne</a></h5>
                
                                     }
                              }        
                      }                
                                    

    </div>   

    </section

     

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 04, 2015 @ 14:06
    Dennis Aaen
    0

    Hi khansaa111,

    I was thinking if you could do it like this instead and then get the right data.

    Hope this helps,

      @foreach (var mylevel2 in mylevel1)
                   {
                   foreach (dynamic mylevel3 in mylevel2.Children.Where("Visible && DocumentTypeAlias == @0", "Transport").OrderBy("CreateDate desc").Take(5))
                            {
    
    
    
                                <h5 class="h5-title-actu"><a href="#">@mylevel3.letype</a></h5>
                                <h5 class="h5-title-video"><a href="#">@mylevel3.titreAlaUne</a></h5>
    
    
                              }        
                      }                
    

    Hope this helps,

    Dennis

  • khansaa111 25 posts 55 karma points
    Jun 04, 2015 @ 15:27
    khansaa111
    0

    Hi Dennis

    I agree with you but :)

    i dont want to filter by  DocumentTypeAlias , but by using mylevel3.letype , this img well show you all

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 04, 2015 @ 20:46
    Dennis Aaen
    0

    Hi khansaa111,

    Okay the screenshot is very nice. Then I think you could do it like this.

    @foreach (var mylevel2 in mylevel1)
                   {
                   foreach (dynamic mylevel3 in mylevel2.Children.Where("Visible && letype == \"Transport\"".OrderBy("CreateDate desc").Take(5)){
    
                                <h5 class="h5-title-actu"><a href="#">@mylevel3.letype</a></h5>
                                <h5 class="h5-title-video"><a href="#">@mylevel3.titreAlaUne</a></h5>
                       }        
    }       
    

    Hope this helps,

    /Dennis

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies