Question

We are building two websites, both of which will have a news section.

Some of the news items will be unique to each website and some will be published on both sites.

Is it possible to set Umbraco up so that both sites are controlled by the same Umbraco CMS and be able to mark certain news items as being pulished on one of the sites or both sites?

Was it helpful?

Solution

It sure is! You have many options for this. I recommend simply adding a checkbox on your news document type, call it "Publish on both sites". Then when you display news on either site, simply pull your normal news combined with the news from the other site.

You'll need to traverse up the tree, then to the other site, then get the news. Here is code to display the news, considering you have a "News - NewsItem" structure.

var siteRoot = Model.Content.AncestorOrSelf("Site");

var normalNews = Model.Content.Descendants("NewsItem");

var otherSite = site.Children[1];

var otherSiteNews = otherSite .Descendants("NewsItem").Where(x => x.AsDynamic().publishOnBothSites);

var combinedNews = normalNews.AddRange(otherSiteNews);

Then proceed with working with the combined news!

(Syntax might be typoed, I'm at home)

Hope this helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top