Can I hide (not disallow) a node to be created under another node?
I have allowed two document types to be created under Home node (content and static).
When I right click Home node and select Create, it displays both options to create.
I want to HIDE "static" option because I am creating these nodes programatically and do not want user to create it.
It appears that the "Allow child node types" is only a UI validation, that determines what a user is allowed to create under another node. It does´nt however add any validation to when you are creating content progamaticlly with the ContentService. So in your case, you could just remove the "Static" doctypes from your "Home" doctypes allowed child nodes, which will make it dissapear from the UI dialog for creating content, but you will still be able to create nodes under home with the doctype Static, using the ContentService.
Example:
As you see, I have a Home doctype and it does NOT allow a doctype called Static.
And I have a doctype called Static, which I´ve just given a name, everything else is default.
Now when I right click my Home content node and selects Create, I get this dialog in the UI. Notice there is no doctype called Static.
Now, when i run this following code, (i just placed this in a startup event just to try it out, you´d prpbobly want to place it somewhere else), everything works and I dont get any exceptions. (1055 is the ID of my Home page, in the above example called "Overflow")
var content = ApplicationContext.Current.Services.ContentService.CreateContent("Code generated page", 1055, "static");
ApplicationContext.Current.Services.ContentService.Save(content);
Now after running this code, a new child has appeard under Overflow, with the Static doctype. But a user can still not create any more Static childen, they can only be created programaticlly.
I hope this can help you in any way. Best of luck to you!
Hide "Allowed" DocumentType
Can I hide (not disallow) a node to be created under another node? I have allowed two document types to be created under Home node (content and static).
When I right click Home node and select Create, it displays both options to create.
I want to HIDE "static" option because I am creating these nodes programatically and do not want user to create it.
Is that possible?
Hi Ifrahim.
It appears that the "Allow child node types" is only a UI validation, that determines what a user is allowed to create under another node. It does´nt however add any validation to when you are creating content progamaticlly with the ContentService. So in your case, you could just remove the "Static" doctypes from your "Home" doctypes allowed child nodes, which will make it dissapear from the UI dialog for creating content, but you will still be able to create nodes under home with the doctype Static, using the ContentService.
Example:
As you see, I have a Home doctype and it does NOT allow a doctype called Static.
And I have a doctype called Static, which I´ve just given a name, everything else is default.
Now when I right click my Home content node and selects Create, I get this dialog in the UI. Notice there is no doctype called Static.
Now, when i run this following code, (i just placed this in a startup event just to try it out, you´d prpbobly want to place it somewhere else), everything works and I dont get any exceptions. (1055 is the ID of my Home page, in the above example called "Overflow")
Now after running this code, a new child has appeard under Overflow, with the Static doctype. But a user can still not create any more Static childen, they can only be created programaticlly.
I hope this can help you in any way. Best of luck to you!
is working on a reply...