If you are using a Razor page with access to the Umbraco API (such as UmbracoTemplatePage or PartialViewMacroPage), you could grab your events something like this:
var events = Umbraco.TypedContentAtXPath("//Event")
.Where(n => n.IsVisible())
.ToList();
This should give you a collection containing all Events across all sites. You need to change //Event to whatever your Doc Type is.
Then you can render them using a Partial view or just use the data right away:
I initially created the Events folder at the root but for some reason, the document didn't render. When I moved it under SITE1, it started working fine . using the right template.
I want to move it back to the root .. but how do I get this to work
where url1 and url2 will both use the same event data but a different template . ?
I undersants the query part of it to retrieve the content, my problem is how can I use custom routing to determine a model and a template and render that .. !
Share content between sites
Here's the scenario
I have a SITE1 with a list of events (DocType = 'Event')
Events show OK using the configured template for SITE1 on url (http://site1/event1, http://site2/event2 .. )
I want to be able to show same events on SITE2 using a different template (http://site2/event1 ..)
How is this possible? I tried route hijacking without success.
Hi!
If you are using a Razor page with access to the Umbraco API (such as
UmbracoTemplatePage
orPartialViewMacroPage
), you could grab your events something like this:This should give you a collection containing all Events across all sites. You need to change
//Event
to whatever your Doc Type is.Then you can render them using a Partial view or just use the data right away:
Hope this helps!
Hi,
Why not move the Events node to the root, and have it outside of both sites? Then you can do something like:
Bonus - this gives you re-usable code for both site 1 and site 2...
Thanks,
Maff
EDIT - that should be:
Thanks!
I initially created the Events folder at the root but for some reason, the document didn't render. When I moved it under SITE1, it started working fine . using the right template.
I want to move it back to the root .. but how do I get this to work
url1 : http://site1/events/event1
url2 : http://site2/events/event1
where url1 and url2 will both use the same event data but a different template . ?
I undersants the query part of it to retrieve the content, my problem is how can I use custom routing to determine a model and a template and render that .. !
Thanks again!
I would like to know that too.
Did you ever figure out how to do this?
Cheers
is working on a reply...