Copied to clipboard

Flag this post as spam?

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

  • Leon 101 posts 486 karma points
    May 05, 2015 @ 14:23

    How do I get the current page from a new Grid Layout?


    I've made my own grid layout page - a copy of Bootstrap3.cshtml. I'm trying to get the current page (or a specific page). How can I do that? Looks like it needs "Umbraco.Web.Mvc.UmbracoTemplatePage", but this isn't a template. Any ideas?


  • Leon 101 posts 486 karma points
    May 05, 2015 @ 14:29

    I found out how - from stack overflow.

    umbraco.NodeFactory.Node node = uQuery.GetNodesByName("Page Name").FirstOrDefault();


  • Dan Sørensen 102 posts 327 karma points
    Oct 13, 2016 @ 14:15
    Dan Sørensen

    Sorry Leon but I dont think your answer is correct because you are getting all pages with the same name ? so if you got more nodes in backend called the same as your homepage it will get more results back, for the most part I would guess it always will be the first in the list because you had created the homepage first, but I dont like the way you get the node because there is a possible risk it will get the worng node..

    I like Marcelo version insted ! :D

  • Marcelo S. 12 posts 57 karma points
    May 29, 2015 @ 20:20
    Marcelo S.

    Hi Leon,

    I was looking for a way to get the current page inside my grid framework. I tried your solution, but for what I was trying to accomplish that solution did not help me.


    I found another way, including this line inside my framework grid:

    IPublishedContent currentPage = UmbracoContext.PublishedContentRequest.PublishedContent;


    As I don't know Umbraco very well, Please, someone could confirm if this approach is acceptable? Will I have problems in future for my website?


Please Sign in or register to post replies

Write your reply to: