Copied to clipboard

Flag this post as spam?

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


  • Niklas Hjelm 104 posts 125 karma points
    Jun 20, 2016 @ 10:09
    Niklas Hjelm
    0

    Hide current page from list

    Hi, I'm trying to create sort of a blog feature where you can continue reading articles after the main article. This works fine but is there a smart way to remove the current page from the articlelist below the main page? Right now I'm getting all the articles from a specific node without filtering out the current page.

    Any help appreciated

    / Niklas

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Jun 20, 2016 @ 10:19
    Alex Skrypnyk
    0

    Hi Niklas,

    I think it's not hard to solve. Can you provide some code, how you are trying to do it ?

    / Alex

  • Niklas Hjelm 104 posts 125 karma points
    Jun 20, 2016 @ 11:44
    Niklas Hjelm
    0

    Hi Alex, it's a simple macro under the main body of the current page.

    @foreach (var page in node.Children.Where("Visible").OrderBy("CreateDate desc").Take(100))
    

    {

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Jun 20, 2016 @ 13:27
    Alex Skrypnyk
    0

    Niklas, I don't recommend you to use dynamic objects for traversing. It has some disadvantages, can we rewrite it to use strongly typed?

    Alex

  • Niklas Hjelm 104 posts 125 karma points
    Jun 20, 2016 @ 14:51
    Niklas Hjelm
    0

    Hi Alex, as long as I can use it in a macro it should be fine :)

    / Niklas

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Jun 20, 2016 @ 16:18
    Alex Skrypnyk
    0

    The dummy way is to check in the foreach is this currentPage or not )

    @foreach (var page in Model.Content.Children.Where("Visible").OrderBy("CreateDate desc").Take(100))
    {
        if (page.Id != CurrentPage.Id)
        {
    
        }
    }
    
  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Jun 30, 2016 @ 22:12
    Alex Skrypnyk
    0

    Hi Niklas Hjelm,

    Did you solve the problem ?

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft