Copied to clipboard

Flag this post as spam?

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


  • jonok 297 posts 658 karma points
    May 13, 2022 @ 22:42
    jonok
    0

    Block List - how to access other pages within a view

    Is there an easy way to access the other pages of the website from within a Block List view?

    eg. in my regular partial views, I can access the home page node with the following:

    var homeNode = Model.AncestorOrSelf(1);
    

    Is it possible to do something similar within a block list item view?

  • jonok 297 posts 658 karma points
    May 13, 2022 @ 23:12
    jonok
    0

    As an answer to my own question, I just found I can do this to load a node by ID. Not perfect, but it will do for my situation:

    var homeNode = Umbraco.Content(1063);
    
  • Lindow 154 posts 1301 karma points
    May 14, 2022 @ 09:39
  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    May 15, 2022 @ 14:41
    Chriztian Steinmeier
    100

    Hi jonok,

    If I need access to "the outside world", I usually do something like this in a Block partial, so I don't have to rely on any hardcoded ids:

    var currentPage = Umbraco.AssignedContentItem;
    var siteRoot = currentPage.Root();
    

    Hope that helps, /Chriztian

  • jonok 297 posts 658 karma points
    May 16, 2022 @ 04:22
    jonok
    0

    Yes Chriztian - that's what I'm looking for, just couldn't find it when I was sifting through the docs. Thanks!

  • 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