Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Content type "SysContentFolder" is not allowed to be created under parent of content type "SysRoot

Vote:
 
 var contentRepository = ServiceLocator.Current.GetInstance();
                var folder = contentRepository.GetBySegment(SiteDefinition.Current.RootPage, name, LanguageSelector.AutoDetect()) as ContentFolder;
                if (folder == null)
                {
                    folder = contentRepository.GetDefault(SiteDefinition.Current.RootPage);
                    folder.Name = name;
                    contentRepository.Save(folder, SaveAction.Publish, AccessLevel.NoAccess);
                }

                return folder as ContentFolder;

above code throws exception. I am not able to figure out what is causing the exception?

Any help would be appreciated.

Cheers

#179794
Jun 22, 2017 6:48
Vote:
 

The exception message actually tells you a fair bit here.

You are trying to create a system content folder under the System root page. This isn't allowed, as you are trying to create a media folder within the pages section of the content tree.  I'm not sure exactly what you are trying to do, but I'll assume you are trying to create a new content folder to store blocks or images in. In which case you should create them either within the Global Assets folder (meaning items are available to all sites in a multi-site scenario) or the Site specific assets folder (for blocks and images limited to a single site)

In your code you need to replace SiteDefinition.Current.RootPage with either:

  • SiteDefinition.Current.GlobalAssetsRoot
  • SiteDefinition.Current.SiteAssetsRoot
#179801
Jun 22, 2017 11:22
Vote:
 

Hi Mark,

I have noticed that SysRoot does not allow any custom content folder class under itself. I was able to add ContentFolder and all of my custom folder under content folder.

Cheers

#179993
Jun 28, 2017 5:52
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.