How to add css/javascript to parent document in fusion?

Hi, I have a short question regarding fusion: Is it possible (and how) to modify the first parent document element? I like to add some css/javascript to the document when my nodetype gets included.

Hey Jens,
no, you can’t modify a parent fusion object from the child - Fusion is designed so that child objects don’t have any knowledge about the environment they are used in. What you can do, however, is check in the document’s fusion object if a certain nodetype is a child of the current one. It works like this:

prototype(Your.Document:NodeType) {
    includedCss = ... (some template or fusion object that renders your styles, or just a variable you evaluate in fluid)
    includedCss.@if.someNodeTypeExistsAsChild = ${q(node).find('[instanceof Your.Content:NodeType]').count() > 0}
1 Like