Then "get" it in your partial and do what you want with it (UmbracoHelper!) proof of concept below!
@{
var currentPageId = ViewData["umbracoPageId"];
var umbracoHelper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
var currentPage = umbracoHelper.TypedContent(currentPageId);
}
<h1>this is a test parial - pageID: @currentPageId</h1>
<h2>@currentPage.Name</h2>
How to get the currentpage from a nested partial
I have a partial, where i load another partial, which is a nav. (Some stacked content thingie).
But pullin @Model.Content gets me the stacked content item, not the current page.. @CurrentPage does the same...
How do i get the actual page i'm on?
Hi Claushingebjerg,
you could make your own ViewModel where you pass the Page as a property to the Partial where you need it.
Hope this helps
/Michaël
In theory, yes, but a snippet or somehting would be nice as i have no idea how...
Claushingebjerg,
No problem:
Then where you load the nav partial you pass in this class object:
*Untested code, so don't shoot me when I have a typo.
Hope this helps
/Michaël
And i don't do backend code, so no visual studio.
Please dont tell med this requires VS and compiling and stuff. I was hoping this would be relatively simple.
Ah ok didn't see this post that you don't want to use VS.
Yeah, i've built umbraco sites since 2008 without it :), so no need to start now... i hope.
But lately i've been running into more and more relatively simple stuff, that seems to require a VS solution :(...
Hi,
Purests will not like this but it will work!
Use the TempData!
In your view set the value then it will be available in all partials:
Then "get" it in your partial and do what you want with it (UmbracoHelper!) proof of concept below!
HTH (disclaimer I used VS to write it ;) )
Thanks - got an error , but rewrote it to:
Which works fine. THANKS
Of course you can just do that - how stupid of me! Glad it put in you in the direction of a solution though!
is working on a reply...