Hi,
contentService.Save(post) should be => contentService.Save(content)`.
You are modifying the variable 'content' but you are saving the variable 'post' at the end.
On the very same topic, after I change the document type via the code all seems OK on the backend office UI - i.e. I see the document type has been updated and icon reflects the corresponding to changed document type.
I have changed one node document type manually via the backend office UI, then run the code for the remaining 500.
When I try to iterate all the nodes from its main node with CurrentPage.Descendants("blogArticle")
there is only one item returned - the one I manually changed. No clue why the others are not returning as the document type seems to be changed. Published all.
If I change to code to CurrentPage.Descendants() then I get all of them.
Is there a step that I am missing? Would you have any ideas?
I would try checking the /app_data/Umbraco.config and seeing if the XML cache for your modified nodes has been updated correctly - that is, the modified nodes have the correct tags (the name of the new doctype) around them.
If not - you need to rebuild the Umbraco XML cache (which is, or at least was, a very common Umbraco troubleshooting step).
This can time out and/or slow down your site - so be careful on production sites.
How to change DocumentType programmatically
I believe this is the right place to ask this;
--
I have a documentType A which I have copied to B (exact same properties),
where I would like to change about 500+ nodes of DocumentType A to B, programmatically, as using the GUI is not practical.
Not sure if Im using the right approach, trying the following saves the nodes (i.e. code executes) but does not change their document type;
Anyone can shed some light?
Hi, contentService.Save(
post
) should be => contentService.Save(content
)`. You are modifying the variable 'content' but you are saving the variable 'post' at the end.Doh.. didnt notice that past midnight..
Many thanks for the heads-up. You have been very helpfull in numerous occasions, much appreciated!
cheers
Hi Jivan
On the very same topic, after I change the document type via the code all seems OK on the backend office UI - i.e. I see the document type has been updated and icon reflects the corresponding to changed document type.
I have changed one node document type manually via the backend office UI, then run the code for the remaining 500.
When I try to iterate all the nodes from its main node with CurrentPage.Descendants("blogArticle")
there is only one item returned - the one I manually changed. No clue why the others are not returning as the document type seems to be changed. Published all.
If I change to code to CurrentPage.Descendants() then I get all of them.
Is there a step that I am missing? Would you have any ideas?
have you solved this issue? republishing doesnt seem to work
Have you try Content->right click -> Republish entire site?
this doesnt work :(
I would try checking the /app_data/Umbraco.config and seeing if the XML cache for your modified nodes has been updated correctly - that is, the modified nodes have the correct tags (the name of the new doctype) around them. If not - you need to rebuild the Umbraco XML cache (which is, or at least was, a very common Umbraco troubleshooting step). This can time out and/or slow down your site - so be careful on production sites.
/umbraco/dialogs/republish.aspx?xml=true
is working on a reply...