I'm a Umbraco newbie and I'm looking for a way to share notifications between two pages.
I have this structure:
Content > Home (Will display notifications) > > Support (Will display notifications) > > About > > ... etc > Notifications > > Notification1 > > Notification2
I was hoping I could just add something like a ContentQuery property to the Home and Support DocumentTypes, where I could get published children of Notifications. I see there is a Content Picker (Multiple), but I dont want to manually set which ones to display.
I dont want to put the notifications inside the Home content tree either, it is not the same people handling the content and those who need to put out alerts.
If it isnt a native way of doing it, can someone tell me how I can access this data directly in a template/view?
I'm using Umbraco 7.2.5 and am quite familiar with Razor and MVC.
Got this within an email but it's not on the forum...
Thanks James!
It's working now. I do have a follow up question, though:
I changed @inherits Umbraco.Web.Mvc.UmbracoTemplatePage to
@inherits Umbraco.Web.Mvc.UmbracoViewPage and lost @CurrentPage.
Is there a cleaner way to get to the Document Type properties than
this.Content.Properties.FirstOrDefault(x => x.PropertyTypeAlias ==
"myPropertyAlias");?
Stephan
Funny you should ask that. I've been working on something recently with a few other guys that allows you to pass strong typed models to your views. There's an article about it here.
How can I share content between pages?
I'm a Umbraco newbie and I'm looking for a way to share notifications between two pages.
I have this structure:
Content
> Home (Will display notifications)
> > Support (Will display notifications)
> > About
> > ... etc
> Notifications
> > Notification1
> > Notification2
I was hoping I could just add something like a ContentQuery property to the Home and Support DocumentTypes, where I could get published children of Notifications. I see there is a Content Picker (Multiple), but I dont want to manually set which ones to display.
I dont want to put the notifications inside the Home content tree either, it is not the same people handling the content and those who need to put out alerts.
If it isnt a native way of doing it, can someone tell me how I can access this data directly in a template/view?
I'm using Umbraco 7.2.5 and am quite familiar with Razor and MVC.
Hi Stephen,
This sounds like something I would use Route Hijacking to do.
Within your
ActionResult
you can use theUmbracoHelper
property to query the document tree and grab whatever bits you want for your view model.Let me know if you need more information.
Cheers
James
Thanks James!
It's working now :)
Stephan
Excellent! Glad I could help :)
Hi Stephan,
Got this within an email but it's not on the forum...
Funny you should ask that. I've been working on something recently with a few other guys that allows you to pass strong typed models to your views. There's an article about it here.
Cheers
James
is working on a reply...