Copied to clipboard

Flag this post as spam?

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


  • René Andersen 238 posts 684 karma points
    Feb 05, 2015 @ 11:43
    René Andersen
    0

    Show related pages sorted by category

    Hi,

    I use his solution to show related pages on my portfolio and it works fine, but at the moment it shows all pages on this level including the current page. Is there a way only to show related pages without showing the current page?

    @{
    if (CurrentPage.Level > 2)
    {
    var section = CurrentPage.AncestorOrSelf(2);
    if (section != null)
    {
    var childItems = section.Children;
    foreach (var page in childItems)
    {
    <img src="@Umbraco.Media(page.thumbnail).Url">
    <h4>@page.title</h4>
    <a href="@page.Url"></a>
    }
    }
    }
    }


    I also need it only to show a specific category which is set with a checkbox list or radio button how, is that possible?

    Is there a better way instead of using "CurrentPage.AncestorOrSelf(2)" I am thinking using the specific documenttype instead.?

    This MockUp is how the design is:

    Thanks in advance!

    //René

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Feb 05, 2015 @ 11:55
    Dennis Aaen
    0

    Hi René,

    I was thinking could it be a idea for you to create a folder on the same level as home, by creating a document type named related content, and create another document type called related project.

    Then you can use the multinode treepicker https://our.umbraco.org/documentation/using-umbraco/backoffice-overview/property-editors/Built-in-Property-Editors-v7/Multinode-Treepicker on the project pages, and add which related project that should be visible on project page. It gives you a bit more work to do, but I think you end up with more flexibility, than just pick children items.

    With the multinode treepicker you have the option for limited it to specific document types, let the user select a max or min numbers of items, and so on.

    Hope this approach can help you.

    /Dennis

  • René Andersen 238 posts 684 karma points
    Feb 05, 2015 @ 12:36
    René Andersen
    0

    Hi Dennis,

    I have never used the multinode treepicker, but I will definitly give it a try.

    Does this approach mean that i don't have to use children at all, so that "Portfolio" don't have any children because thay are moved to the new documenttype on same level as "Home"? See my current structure:

    // René

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Feb 05, 2015 @ 12:59
    Dennis Aaen
    0

    Hi René,

    The first thing is to make a folder on the same level as the frontpage. In this folder you creates the related items, when this is done, then you have your the only child node tthat you need is the portofolio overview page and it´s portfolio items.

    On the actually page for each project, you add a property called e.g related products. of the multinode treepicker. So the section of the page, where you want to show the related products, you just insert a partial view macro that pulls data out from the multinode treepicker.  

    Hope this helps, and make sense.

    /Dennis

  • René Andersen 238 posts 684 karma points
    Feb 05, 2015 @ 14:16
    René Andersen
    0

    If I am not using the treepicker solution is there a way to skip the current page when showing related pages? I have tried to change the code a bit and managed to skip the first item when showing the related thumbnails but that does not work. I wish that you could do something like:

     

    @var nodes = Model.Children.Skip(CURRENT PAGE);

     

    This is my new code:

    @{
    if (@CurrentPage.DocumentTypeAlias == "Portfolioitem")
    {
    var section = CurrentPage.AncestorOrSelf(2);
    {
    var childItems = section.Portfolioitem.Skip(1);
    foreach (var page in childItems)
    {
    Do something
    }
    }
    }
    }

    // René

  • James 251 posts 1169 karma points
    Feb 06, 2015 @ 17:46
    James
    0

    Hi,

     

    This is probably not the cleanest way to do it but if the content inside the foreach is small its worth a try.

     

    Couldnt you just get the current page title and put it in a variable then do something like this in your foreach:

     

    if(currentPageTitle == page.title){then dont do anything}else{output stuff}

Please Sign in or register to post replies

Write your reply to:

Draft