How To implement Folders for Documents

Hey there,
I tried to create a NodeType DocumentFolder like this:

'Example.Homepage:PageFolder':
  ui:
    label: 'Ordner'
    icon: 'icon-folder'
  superTypes:
    'TYPO3.Neos:Document': TRUE 

and:

prototype(Example.Homepage:PageFolder) < prototype(TYPO3.TypoScript:Template) {
    templatePath = 'resource://Example.Homepage/Private/Templates/TypoScriptObjects/Shortcut.html'
} 

But I alway get an Error because Neos tries to render a Content Collection “main”. I am confused because there no instance of Page in my definition.

An exception was thrown while Neos tried to render your page
No content collection of type TYPO3.Neos:ContentCollection could be found in the current node (/sites/homepage/node-5836d68f0f89b) or at the path "main". You might want to adjust your node type configuration and create the missing child node through the "flow node:repair --node-type Systemum.Homepage:PageFolder" command.
page<TYPO3.Neos:Page>/
 body<TYPO3.TypoScript:Template>/
  content/
   main<TYPO3.Neos:PrimaryContent>/
    default<TYPO3.TypoScript:Matcher>/
     renderer/
      __meta/
       context/
        node<>/

Hey Kuno,

what you’ll need to do is tell Neos that for that page type, it’s supposed to use a different rendering path in TS/Fusion. It’s not really necessary to create a custom TS prototype for this use case.

The “root” typoscript path is a case object, in which you need to add your custom rendering path. That basically tells Neos that “if the page type is X, use a different TS rendering path”. Otherwise it will use page, which is the default (should be visible in your package’s Root.ts2. This is also why the error is displayed, because the page TS object is trying to load a collection from body.content.main, which your node type doesn’t have (check the structure tree at the bottom left in the backend to verify this). You can see the root case object and the rendering logic behind it in Packages/Application/TYPO3.Neos/Resources/Private/TypoScript/DefaultTypoScript.ts2.

To fix your issue, add the following to your Root.ts2:

root.pagefolder {
	condition = ${q(node).is('[instanceof Example.Homepage:PageFolder]')}
	renderPath = '/pagefolder'
}

and

pagefolder = TYPO3.Neos:Shortcut

Also, you can have your node type inherit from TYPO3.Neos:Shortcut instead of document if you don’t need rendering for the folder.

3 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.