Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I've been using @inherits Umbraco.Web.Mvc.UmbracoTemplatePage to build my canonical like so <link rel="canonical" href="httpsP@HttpContext.Current.Request.Url.Host@CurrentPage.Url" 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?
<link rel="canonical" href="httpsP@HttpContext.Current.Request.Url.Host@CurrentPage.Url" runat="server" id="canonical" />
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:
@using ContentModels = Umbraco.Web.PublishedModels;
Layout = null;
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.
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 :)
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,
var widgetImageGallery = rootNode.widgetImageGallery;
I have to do this,
var widgetImageGallery = rootNode.Value<IEnumerable<IPublishedContent>>("widgetImageGallery");
The .OfType<FrontPage> is gone many places, and i can't find a replacement for it :(
What I always do is:
Frontpage frontpage = new Frontpage(Model.Root());
You could also use Model.Root() as Fronpage but I have to update Rosalyn to be able to use Modelsbuilder for that one
Model.Root() as Fronpage
It works with
var rootNode = Model.Root() as Frontpage;
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?
Do you use modelsbuilder? And if so in what mode?
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:
var homePage = Model.AncestorOrSelf<Home>();
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:
var homePage = Model.AncestorOrSelf(1);
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.
EcHomePage homePage = (EcHomePage)Umbraco.ContentAtRoot().FirstOrDefault(x => x.ContentType.Alias.Equals("ecHomePage"));
IPublishedContent currPage = Model;
EcGlobalSettings configPage = homePage.Descendant<EcGlobalSettings>();
// Allow page footer to override global footer.
EcFooterSection footerSection = currPage.Children<EcPageSettings>().FirstOrDefault()?.Descendant<EcFooterSection>() ?? configPage.Descendant<EcFooterSection>();
// Allow page header to override global header.
EcHeaderSection headerSection = currPage.Children<EcPageSettings>().FirstOrDefault()?.Descendant<EcHeaderSection>() ?? configPage.Descendant<EcHeaderSection>();
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted