[Neos] setting bootstrap wrap classes globally for all content elements

Bastian Waidelich bastian at typo3.org
Thu Dec 5 18:18:59 CET 2013


Dominic Garms wrote:

> I digg a bit deeper and try to create a Bootstrap package which adds
> content wrapper to all content types [...]
>
> Now I am not sure how to proceed. I found prototype(TYPO3.Neos:Content)
> and there are already some attributes:
>
> prototype(TYPO3.Neos:Content) < prototype(TYPO3.TypoScript:Template) {
>      node = ${node}
>
>      attributes = TYPO3.Neos:Attributes
>      attributes.class = ''


Look a few lines further and you see a (somewhat crazy) example of a 
processor:

attributes.class. at process.nodeType = ${String.trim(value + ' ' + 
String.toLowerCase(String.pregReplace(q(node).property('_nodeType.name'), '/[[:^alnum:]]/', 
'-')))}

This snippet generates classes like "typo3-neos-nodetypes-headline" for 
your content elements


If you don't need that behavior you can disable it with:

prototype(TYPO3.Neos:Content) {
	attributes.class. at process.nodeType >
}

and/or you can add your own processors. Or simply set the class 
attribute explicitly:

prototype(TYPO3.Neos:Text) {
	attributes.class = 'custom-class-for-text'
}


BTW: we'll simplify the nodeType processor to something like
attributes.class. at process.nodeType = 
${String.slugify(q(node).property('_nodeType.name'))}

-- 
Bastian Waidelich


More information about the Neos mailing list