Is there an easy was to mass publish items across an entire site in Umbraco.? I am looking into having a parent site with many children sites, and being able to make changes to the parent and it affecting all the children would be ideal. Is there a module for anything like this, or would it have to be personally created to my needs? Thanks.
You can publish by right-clicking on Home page node and selecting 'Publish' menu item. Select '' and 'Include unpublished child pages' as per your requirement.
What do you mean by you want the changes to display on the sub-sites? When you create a new page under "Main Page," do you want a duplicate created under "Sub-Site 1,2 and 3" or do you want the sub-sites to be able to see that you created a new page under the "Main Page" and display data from that page?
Say for instance my company wants to make an announcement (ie a new Board Member elected) with some press release. I want to be able to post the content to one location, and all other locations where you would expect that to go it magically appears (same sort of functionality as user controls in .Net. Thanks.
I think you have two related posts running with the same question. The question from both threads seems to be are you attempting to reuse or feed content, or truly duplicate content.
As mentioned by the other Chris, if you organize your content (news items) into a different site or on the parent site, you can create an xslt macro to feed that content to your subsites, much like an rss feed. When a user clicks the link to a news story they will navigate to either your parent site or shared content site to display the news story detail. The content will be displayed in whichever site template the story is located.
If you want to duplicate content, meaning you publish a news story and it creates an identical node within each of the subsites, you will need to create a little custom code using event handlers.
Thanks for getting back to me. How I have it set up right now is that there is a Parent site, then 3 or 4 brands of business. All sites will have mostly different content, but things as mentioned would like to be pushed to the brand sites (ie news, announcements, company wide changes) Is the easiest way to do this is creating a shared content site, then grabbing information via an xslt? So the brand sites wont be grabbing from the home site but from a shared content area. Would this entail that the parent site would have to go out and grab content? Thanks for all the help so far.
Isaac
PS. I cannot delete that old post, but I would like to. Sorry for double posting :)
Where you store the content for your news, announcements has more to do with branding, navigation and the template applied. When the content is displayed (meaning news story or announcement body text), you need to apply a template. If you are displaying dynamic navigation, the navigation will display based upon where the content resides.
If you're not concerned about branding the news stories, where you place the content in the parent site or share content site is not as important. It's more about the template applied.
If you want to brand the content based on the site it was referred from, you can use the altTemplate querystring parameter to specifically set the template applied which overrides the set template for the node. You would create a "New Story Template" for each sub-site and when adding the macro specify this template as a string parameter. Then in the xslt, you would do something like this.
You can optionally pass the node it was referred from and based upon that determine which site it is coming from ( by looping up the tree in xslt) and show navigation based upon that. So there are a few options, some more advanced than others depending on your skill level.
The simplest solution is to have a separate "news site" for shared content and have your news and announcements link to that. It won't be branded but is the simplest solution. If you follow this option, yes you will need to put the same feed you use on your subsites on the parent site.
I suggest spending some time learning xslt by using the provided samples in umbraco or the packages available. There is some great code to learn from. Playing with xslt can help with understanding the content tree, which will help understanding content sharing and reuse. Here are some links to get you started.
Overall concepts of sharing content (codegarden presentation):
After doing some research on the whole "Sharing Content" topic myself, the most common answer is to implement umbraco.library.RenderTemplate in an XSLT Macro embedded in an empty template. This book gives you an overview of the concept. RenderTemplate works by re-requesting default.aspx (aka Server.Execute) with the provided nodeId and templateId. It then returns the rendered result as a string.
It's a workable approach, but has some drawbacks:
Server.Execute is a little expensive for my taste considering we're already in the middle of executing default.aspx for the current request.
I have a feeling that simply writing the result string to the current page will moot PostBack and event handlers if you're using your own UserControls (correct me if I'm wrong).
There is potential for infinite loops, since default.aspx can - by executing a Macro - call default.aspx which itself can execute a Macro that does the same thing and so on. That's a server killer right there.
You can't override individual properties, such as a page title or other meta tags.
The person editing content (aka, my customer, not me) has to work with pages in a different way. They can't, for example, choose from a range of templates. They must use the blank template that is required by this approach.
I dug deeper into the umbraco source code, and found a handy little property of the umbraco.presentation.templateControls.Item class that helped me solve all the above issues. Though, to be perfectly honest, number 1 is only half solved - doing any sort of content inheritance is going to be a bit expensive!
That magical property is NodeId, which allows you to set an alternative content source for the Item. At render time, the ItemRenderer will check if this property has a value, and if so, pulls the value from the cache instead of the current pageElements collection. Perfect!
So I created a new custom control (source to follow), registered it as a Macro and inserted into my base template. Now my original list looks like this:
Still a little expensive
UserControls work exactly as they normally would.
Negligable potential for loops.
Fully overrideable.
Customers can work normally and pick any template that fits.
Add a new Content Picker property to your chosen document type.
Register the Macro, browse properties and set PropertyAlias to use the propertyTypePicker. Turn off "Use in editor".
Insert the Macro into your chosen template. When prompted for the Property Alias, choose the new Content Picker property you created for your document type.
Done!
using System; using System.Collections.Generic; using System.Web.UI; using umbraco.presentation.nodeFactory; using umbraco.presentation.templateControls;
// Store the node id at the class level. Less expensive than passing it as a parameter to a recursive method. private Int32 _shareNodeId; // Collection to speed up override checks. // SortedList is a slower to build, faster to search collection. Best choice for "Contains" use. // SortedSet would be ideal, but is 4.0 only. private SortedList<String, Boolean> _overriddenProperties;
// The developer assigned property alias public String PropertyAlias { get; set; }
protected override void OnInit(EventArgs e) { // Using OnInit to get sharing sorted early // Could in theory be done any time before Render this.ProcessShare(); }
private void ProcessShare() { Node currentNode = Node.GetCurrent(); Property shareProperty = currentNode.GetProperty(this.PropertyAlias); // Sensibility check #1 // Make sure the property actually exists for the current node if (shareProperty != null) { // Sensibility check #2 // Make sure the value is actually a valid Int32 if (Int32.TryParse(shareProperty.Value, out this._shareNodeId)) { Node shareNode = new Node(this._shareNodeId); // Sensibility check #3 // Make sure the id resolves to a node that actually exists if (shareNode != null) { // Everything above checks out, so it's worth spending on the following // Populate the overridden properties list, we want to ignore these this.SetOverriddenProperties(currentNode); // Recursively scan the Page for Item controls // If found, and not in the overriden collection, set their NodeId property to _shareNodeId this.SetNodeId(this.Page); } } } }
private void SetOverriddenProperties(Node currentNode) { this._overriddenProperties = new SortedList<String, Boolean> { }; foreach (Property nodeProperty in currentNode.Properties) { if (!(nodeProperty.Alias.Equals(this.PropertyAlias) || String.IsNullOrEmpty(nodeProperty.Value))) { this._overriddenProperties.Add(nodeProperty.Alias, true); } } }
private void SetNodeId(Control parentControl) { foreach (Control childControl in parentControl.Controls) { if (childControl is Item) { Item childItem = (Item)childControl; if (!this._overriddenProperties.ContainsKey(childItem.Field)) childItem.NodeId = this._shareNodeId.ToString(); } else this.SetNodeId(childControl); } }
One-Click push to multiple sites
Is there an easy was to mass publish items across an entire site in Umbraco.? I am looking into having a parent site with many children sites, and being able to make changes to the parent and it affecting all the children would be ideal. Is there a module for anything like this, or would it have to be personally created to my needs? Thanks.
Isaac
You can publish by right-clicking on Home page node and selecting 'Publish' menu item. Select '' and 'Include unpublished child pages' as per your requirement.
Masood,
Can you go into more detail? Here is my Setup
Main Page (contains around 20 pages)
-- Sub-Site 1, 2, 3 (Mostly own content but things like news are from Parent)
When I make an update to a page in the Parent Site, I would like the changes to display on the Sub-Sites as well
I feel like I am missing something very obvious here. Thanks for the help
Isaac,
I don't think I am following.
What do you mean by you want the changes to display on the sub-sites? When you create a new page under "Main Page," do you want a duplicate created under "Sub-Site 1,2 and 3" or do you want the sub-sites to be able to see that you created a new page under the "Main Page" and display data from that page?
--
Donald
Donald,
Say for instance my company wants to make an announcement (ie a new Board Member elected) with some press release. I want to be able to post the content to one location, and all other locations where you would expect that to go it magically appears (same sort of functionality as user controls in .Net. Thanks.
Isaac,
I think you have two related posts running with the same question. The question from both threads seems to be are you attempting to reuse or feed content, or truly duplicate content.
As mentioned by the other Chris, if you organize your content (news items) into a different site or on the parent site, you can create an xslt macro to feed that content to your subsites, much like an rss feed. When a user clicks the link to a news story they will navigate to either your parent site or shared content site to display the news story detail. The content will be displayed in whichever site template the story is located.
If you want to duplicate content, meaning you publish a news story and it creates an identical node within each of the subsites, you will need to create a little custom code using event handlers.
http://umbraco.org/documentation/books/api-cheatsheet/attaching-document-eventhandlers
Hope that helps,
Chris
Chris,
Thanks for getting back to me. How I have it set up right now is that there is a Parent site, then 3 or 4 brands of business. All sites will have mostly different content, but things as mentioned would like to be pushed to the brand sites (ie news, announcements, company wide changes) Is the easiest way to do this is creating a shared content site, then grabbing information via an xslt? So the brand sites wont be grabbing from the home site but from a shared content area. Would this entail that the parent site would have to go out and grab content? Thanks for all the help so far.
Isaac
PS. I cannot delete that old post, but I would like to. Sorry for double posting :)
Isaac,
Where you store the content for your news, announcements has more to do with branding, navigation and the template applied. When the content is displayed (meaning news story or announcement body text), you need to apply a template. If you are displaying dynamic navigation, the navigation will display based upon where the content resides.
If you're not concerned about branding the news stories, where you place the content in the parent site or share content site is not as important. It's more about the template applied.
If you want to brand the content based on the site it was referred from, you can use the altTemplate querystring parameter to specifically set the template applied which overrides the set template for the node. You would create a "New Story Template" for each sub-site and when adding the macro specify this template as a string parameter. Then in the xslt, you would do something like this.
You can optionally pass the node it was referred from and based upon that determine which site it is coming from ( by looping up the tree in xslt) and show navigation based upon that. So there are a few options, some more advanced than others depending on your skill level.
The simplest solution is to have a separate "news site" for shared content and have your news and announcements link to that. It won't be branded but is the simplest solution. If you follow this option, yes you will need to put the same feed you use on your subsites on the parent site.
-Chris
Chris,
Thanks for all the help so far. Can you point me to a tutorial on setting up shared content? Thank you.
Isaac,
I suggest spending some time learning xslt by using the provided samples in umbraco or the packages available. There is some great code to learn from. Playing with xslt can help with understanding the content tree, which will help understanding content sharing and reuse. Here are some links to get you started.
Overall concepts of sharing content (codegarden presentation):
http://www.umbraco.us/media/1606/content%20sharing%20-%20codegarden%20us%202008%20-%2004.pdf
For some specifics on xslt:
http://umbraco.org/documentation/books/xslt-basics
CWS is a good package to get you started:
http://our.umbraco.org/projects/creative-website-starter-(cws).
Good luck :)
-Chris
After doing some research on the whole "Sharing Content" topic myself, the most common answer is to implement umbraco.library.RenderTemplate in an XSLT Macro embedded in an empty template. This book gives you an overview of the concept. RenderTemplate works by re-requesting default.aspx (aka Server.Execute) with the provided nodeId and templateId. It then returns the rendered result as a string.
It's a workable approach, but has some drawbacks:
I dug deeper into the umbraco source code, and found a handy little property of the umbraco.presentation.templateControls.Item class that helped me solve all the above issues. Though, to be perfectly honest, number 1 is only half solved - doing any sort of content inheritance is going to be a bit expensive!
That magical property is NodeId, which allows you to set an alternative content source for the Item. At render time, the ItemRenderer will check if this property has a value, and if so, pulls the value from the cache instead of the current pageElements collection. Perfect!
So I created a new custom control (source to follow), registered it as a Macro and inserted into my base template. Now my original list looks like this:
Source code from above. To use it:
is working on a reply...