Is it possible to write the data of a node to the umbraco.config xml without publishing the node?
I've got a situation where I got news items which are displayed on a big overview page. This overview page is the parent node, but the child nodes (news items) don't have their own template and are only displayed in the parent node. Therefore I don't want to child nodes to be published because the url's would be useless. Currently I solved this by using the umbracoRedirect and all the news nodes are redirected to the parent. This works but I would prefer it if the url just wouldn't exit.
So I would like the node to be available in xml, but I don't want it to have an url. Is this possible or should I just keep using the umbracoRedirect?
You're right about that but I just find it useless that there is an url in the first place if it's not used. Should be able to have the url disabled or something.
Unless you wanted something really ugly which captures the save event the generates XML and parses the document itself, but then you don't have the ability to have unpublished content.
Why don't you just create a template which redirects to the parent node and set it as the default.
@slace I was also thinking about using a template which redirects to the parent. This saves me the trouble of having to set the umbracoRedirect on each news node. Is it better to make a 301 redirect in the template? Too bad there isn't some way to remove the url from a node.
I think it is the wrong appraoch to store info in the Umbraco database that you don't want to publish.
I would create a custom datatype to use on the overviewpage to manage the news items. This cutsom datatype then stores the newsitems in a custom datatable in the database.
On the frontend then, you can use a .net macro to pull the newsitems from the database.
@RolandWolters That would work, but for something simple as news items it would be much better to use XSLT and you need the data to be stored in the umbraco.config xml for this. A .NET macro would also do the trick but XSLT is faster :). For more info about XSLT vs UserControl please visit http://our.umbraco.org/forum/developers/xslt/7571-Xslt-paging-vs-UserControl-gridview.
@Niels I can understand that's it's this way by design. I just hoped it could be changed. Guess I'll just have to go with the template which redirects to the parent.
Jeroen, I do think, though, that this is a classic case of YAGNI. Nobody is ever going to know these URL's, so why develop functionality in case somebody ever hits the URL?
@Sebastiaan I'm no SEO expert, but isn't there a change the pages might be found in Google? If that's the case I would like them to redirect to correct page. Otherwise it sounds like YAGNI indeed :).
No, there is no chance, if you take care to exclude the newsarticle docType from your sitemap.xml and any HTML sitemaps or menu's on you site, then Google will not find the URL. Google only tries to index URLs based on something linking to it. Otherwise, how would the crawler know where to look? It's not going to guess, it's too busy for that! ;-)
@Sebastiaan Thank you for clearing that up for me :). Just like you said the newsarticle docType won't be in the sitemap.xml or any HTML sitemaps so it's unnessary to create any redirecting for these pages. I just won't give them a template. If by some miracle some still finds the pages they just get a blank page :).
Another thing you can try is to create in every news document a property named "umbracoUrlName" which is internally used by umbraco in order to form the url for each node. then set the value of this property for every document to the name of the parent node. you can set the value programmatically by registering the "before save" or "before publish" event. this way, all child documents (news) will have the same url as the parent document, without the need of the redirect functionality.
For more information on how to create this special property have a look at:
Write node to umbraco.config xml without publish
Hello,
Is it possible to write the data of a node to the umbraco.config xml without publishing the node?
I've got a situation where I got news items which are displayed on a big overview page. This overview page is the parent node, but the child nodes (news items) don't have their own template and are only displayed in the parent node. Therefore I don't want to child nodes to be published because the url's would be useless. Currently I solved this by using the umbracoRedirect and all the news nodes are redirected to the parent. This works but I would prefer it if the url just wouldn't exit.
So I would like the node to be available in xml, but I don't want it to have an url. Is this possible or should I just keep using the umbracoRedirect?
Jeroen
But, nobody sees the URL's, so what's the problem?
You're right about that but I just find it useless that there is an url in the first place if it's not used. Should be able to have the url disabled or something.
No, the Umbraco XML is the published cache.
Unless you wanted something really ugly which captures the save event the generates XML and parses the document itself, but then you don't have the ability to have unpublished content.
Why don't you just create a template which redirects to the parent node and set it as the default.
@slace I was also thinking about using a template which redirects to the parent. This saves me the trouble of having to set the umbracoRedirect on each news node. Is it better to make a 301 redirect in the template? Too bad there isn't some way to remove the url from a node.
I've added a codeplex future request: Remove the url from a node. http://umbraco.codeplex.com/WorkItem/View.aspx?WorkItemId=27213 Please vote.
I think it is the wrong appraoch to store info in the Umbraco database that you don't want to publish.
I would create a custom datatype to use on the overviewpage to manage the news items. This cutsom datatype then stores the newsitems in a custom datatable in the database.
On the frontend then, you can use a .net macro to pull the newsitems from the database.
@RolandWolters That would work, but for something simple as news items it would be much better to use XSLT and you need the data to be stored in the umbraco.config xml for this. A .NET macro would also do the trick but XSLT is faster :). For more info about XSLT vs UserControl please visit http://our.umbraco.org/forum/developers/xslt/7571-Xslt-paging-vs-UserControl-gridview.
@Niels I can understand that's it's this way by design. I just hoped it could be changed. Guess I'll just have to go with the template which redirects to the parent.
Jeroen, I do think, though, that this is a classic case of YAGNI. Nobody is ever going to know these URL's, so why develop functionality in case somebody ever hits the URL?
@Sebastiaan I'm no SEO expert, but isn't there a change the pages might be found in Google? If that's the case I would like them to redirect to correct page. Otherwise it sounds like YAGNI indeed :).
No, there is no chance, if you take care to exclude the newsarticle docType from your sitemap.xml and any HTML sitemaps or menu's on you site, then Google will not find the URL. Google only tries to index URLs based on something linking to it. Otherwise, how would the crawler know where to look? It's not going to guess, it's too busy for that! ;-)
@Sebastiaan Thank you for clearing that up for me :). Just like you said the newsarticle docType won't be in the sitemap.xml or any HTML sitemaps so it's unnessary to create any redirecting for these pages. I just won't give them a template. If by some miracle some still finds the pages they just get a blank page :).
Another thing you can try is to create in every news document a property named "umbracoUrlName" which is internally used by umbraco in order to form the url for each node. then set the value of this property for every document to the name of the parent node. you can set the value programmatically by registering the "before save" or "before publish" event. this way, all child documents (news) will have the same url as the parent document, without the need of the redirect functionality.
For more information on how to create this special property have a look at:
http://our.umbraco.org/wiki/reference/umbraco-best-practices/umbracourlname
http://our.umbraco.org/forum/templating/templates-and-document-types/2825-Alter-node-url-from-name-to-id
For more information on how to register umbraco events, have a look at:
http://our.umbraco.org/wiki/reference/api-cheatsheet/using-applicationbase-to-register-events
http://www.richardsoeteman.net/PermaLink,guid,f470b6cf-40da-4aa9-a0d9-7b984fe9bf59.aspx
If you try this, be sure to use Document not Node:
http://our.umbraco.org/wiki/reference/api-cheatsheet/difference-between-a-node-and-a-document
is working on a reply...