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 489 karma points
    May 05, 2015 @ 14:23
    Leon
    0

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

    Hello.

    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

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

    I found out how - from stack overflow.

    http://stackoverflow.com/questions/15925076/umbraco-get-node-by-name-and-datatype

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

    Leon

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

    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.
    3

    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?

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft