Copied to clipboard

Flag this post as spam?

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


  • jonok 279 posts 549 karma points
    1 week ago
    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 279 posts 549 karma points
    1 week ago
    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 80 posts 796 karma points admin hq
    1 week ago
  • Chriztian Steinmeier 2737 posts 8401 karma points MVP 5x admin c-trib
    1 week ago
    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 279 posts 549 karma points
    1 week ago
    jonok
    0

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

Please Sign in or register to post replies

Write your reply to:

Draft