Using of AllowedChildren attribute

Topics: Developer Forum
Oct 23, 2008 at 9:08 PM
Hi,

First I want to thank you for the great CMS you have build, it's fantastic...

I have one question though... I can't find a way how to accomplish this requirement:
I have created a NewsContainer item where I will create and store all news articles. The requirement that I have is to be able to create ONLY pages from NewsItem type
under the NewsContainer type pages. I tried to set that in the definition of the NewsContainer item type by adding this attribute to the NewsContainer class:

[

AllowedChildren(typeof(NewsItem))]

but with no success, I am still getting all other defined item types when i click New to create a new page under the NewsContainer page.
Is there something that I am missing?

Thanks in advance.

 

 

Coordinator
Oct 23, 2008 at 9:36 PM
Edited Oct 23, 2008 at 9:36 PM
I know this is confusing. For some reason I decided to do this opposite to the most natural way early on. Use this instead:

[RestrictParents(typeof(NewsContainer))]
public class NewsItem
Oct 25, 2008 at 7:21 AM
Edited Oct 25, 2008 at 7:25 AM
Hi again

I've tried that before and it doesn't work...In case you did not understood me well here is better explanation with sample...I have NewsItem defined like this:

[Definition("News Item", "NewsItem", "  --> News article page that defines one article", "News article page that defines one article", 300)]
[TabPanel(Tabs.Information, Tabs.InformationTabText, Tabs.InformationTabSortOrder)]
[RestrictParents(typeof(NewsContainer))]
public class NewsItem : AbstractContentPage, ISyndicatable

The NewsContainer item is defined like this:

[Definition("News Container", "NewsContainer", "  --> Containes a list of news. News items can be added to this page.", "Containes a list of news. News items can be added to this page", 290)]
[AllowedChildren(typeof(NewsItem))]
public class NewsContainer : AbstractContentPage

And when I go in edit mode, right click on NewsContainer page and click New, I want to have only this option in the right panel:

Select type of item below "News"
News Item --> News article page that defines only one article

In this moment, with this definition, I am getting all other defined item types from which the editor can choose... I know that one solution is to restrict parents to all other item types, so they wont implement NewsContainer type which will lead to not showing them in the list in the right panel when I am trying to create child page under NewsContainer. This solution is very bad in my opinion cause I will need to be careful not to forget to put restrictions on every item type and that list of item types can become very long in the future and hard for maintenance.

I hope my explanation was OK.
Thanks
Coordinator
Nov 1, 2008 at 5:14 PM
I think the AbstractContentPage has a marker interface referenced by the other types you see. Try using ContentItem as base class.