I've been using @inherits Umbraco.Web.Mvc.UmbracoTemplatePage to build my canonical like so <link rel="canonical" href="https://@[email protected]" runat="server" id="canonical" />, but either v8 doesn't have UmbracoTemplatePage anymore or it's moved. If it's moved can someone point me to where it is now. If it's gone, could you suggest how I get the current page's url?
I'm a day into my first v8 project. Gotta say I'm perplexed at the lack of documentation available. It's cool if you're going to change stuff. Just have a page somewhere that says, this used to work, now it's like this. That's all I need. I've been struggling to find v8 documentation. If you've got a bead on where I can find some good documentation on moving from v7 to v8 I'd really appreciate a link.
Note: My document type is called Testers, hence the Testers model name in there.
UmbracoViewPage is nothing new, we've had that in Umbraco for years. I think it was also possible to have a typed version like here (UmbracoViewPage<ContentModels.Testers>).
You're able to remove the type as well if you want: @inherits Umbraco.Web.Mvc.UmbracoViewPage.
In both cases, you can then use @Model.Url to get the URL of the "CurrentPage" (Model). Not much else has changed, let's hope you find your way a little bit better from this starting point.
Just wondering with the document type model name that never resolves so we don't get any autocomplete on Model. is there a way to wire that up?
Cheers,
Tom
The current page is just the model - picked up in the master razor layout.
FYI I use the following for the home page, and I also allow a local page header and footer to override the global settings.
How to get CurrentPage in v8
I've been using
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
to build my canonical like so<link rel="canonical" href="https://@[email protected]" runat="server" id="canonical" />
, but either v8 doesn't have UmbracoTemplatePage anymore or it's moved. If it's moved can someone point me to where it is now. If it's gone, could you suggest how I get the current page's url?I'm a day into my first v8 project. Gotta say I'm perplexed at the lack of documentation available. It's cool if you're going to change stuff. Just have a page somewhere that says, this used to work, now it's like this. That's all I need. I've been struggling to find v8 documentation. If you've got a bead on where I can find some good documentation on moving from v7 to v8 I'd really appreciate a link.
Hey there Ben, make sure to have a look at the documentation statuspage: https://our.umbraco.com/documentation/v8documentation
If you look at the template we give you when you create it, you'll see:
Note: My document type is called
Testers
, hence theTesters
model name in there.UmbracoViewPage
is nothing new, we've had that in Umbraco for years. I think it was also possible to have a typed version like here (UmbracoViewPage<ContentModels.Testers>
).You're able to remove the type as well if you want:
@inherits Umbraco.Web.Mvc.UmbracoViewPage
.In both cases, you can then use
@Model.Url
to get the URL of the "CurrentPage" (Model). Not much else has changed, let's hope you find your way a little bit better from this starting point.Shannon also spoke about the v8 changes recently and his slides are here, they could come in helpful: https://shazwazza.com/media/1032/uduf-2019.pdf
Many thanks @SebastiaanJanssen!
Hi Sebastiaan :)
Maybe i missed something, but how can i get my root node (Frontpage) out as a model? :)
In v7 i could do
var rootNode = Model.Content.Site().OfType<Frontpage>();
But that is not an option anymore :)
Hi Anders,
Instead of Model.Content.Site() try Model.Root()
Hi Frans :)
Yeah i have done it with Model.Root() but the problem with Model.Root is that i does not give me the possibility to do this,
I have to do this,
The
.OfType<FrontPage>
is gone many places, and i can't find a replacement for it :(What I always do is:
You could also use
Model.Root() as Fronpage
but I have to update Rosalyn to be able to use Modelsbuilder for that oneNice thanks!
It works with
Thanks alot! :)
This is the best one as you can then test for nulls.
Just wondering with the document type model name that never resolves so we don't get any autocomplete on Model. is there a way to wire that up? Cheers, Tom
Do you use modelsbuilder? And if so in what mode?
Thanks Frans, Currently PureLive
Autocomplete doesn't work in purelive mode since models only exist runtime.
I would strongly advice looking in to app data mode or, if you always use visual studio, use the modelsbuilder api.
Yes, its a total nightmare finding alternatives that used to work in v7. Surprised the Umbraco team never gave this much thought.
I like to do this:
Cheers
Paul
A important remark with this method is that the documenttype alias of your root/home node must be "home" in this case, otherwise this won't work.
If you don't know the documenttype alias you can always do:
The "Home" in
Model.AncestorOrSelf<Home>()
is the type name, rather than an alias - otherwise it would have quotation marks, surely?The current page is just the model - picked up in the master razor layout. FYI I use the following for the home page, and I also allow a local page header and footer to override the global settings.
is working on a reply...