How to implement a content element which is added statically to a page?


I have three link buttons in the header of the homepage. I want to make the text and link data of these buttons editable by the author, but I don’t want to use a ContentCollection node where the author first needs to add these three link buttons. These buttons should have been already added via the template.

How can I achieve this?

I have checked the HowTo here:
but this works with a footer ContentCollection, which I actually don’t really need.

My idea is just to define this static content structure like:

    /main -> the main content column
            /buttonLink1 -> the LinkButton Content element

and then to “statically” render only the buttonLinkX elements with:

{header.buttonLinks.buttonLink1 -> f:format.raw()}

So the author then have the possibility to edit just exactly these bits of data directly without first adding each link buttons to the ContentCollection.

Thanks for your help!

Unfortunately I haven’t found yet a solution for such a static include of custom content elements (not added via the admin interface). I have tried to define a child node in the NodeTypes.yaml with the “LinkButton” as type (instead of ContentCollection), but then I somehow could not edit the data of the node in the admin interface.

Therefore I just have added now a “buttonLinks” ContentCollection node and added these LinkButon content elements, which works so far.

Hi Oliver, adding each link will be unavoidable I think. I would probably define my nodetype like this:

      type: 'TYPO3.Neos:ContentCollection'
      type: 'My.Package:ButtonLinksCollection'

Inside the ButtonLinksCollection (which could also be a normal ContentCollection) add a constraint to only allow link elements to be added.

Thanks @hphoeksma for your input! I have done it this way and it works :smile:

I just thought to somehow simplify the Content Editing for the author so that the author just specifically can edit these pieces of data without first having to add these “Button link” elements, because they are statically defined by the design and won’t change.

You might just add a Neos.NodeTypes:Menu element there than… ? Or an element similar like that with a (custom I guess) link editor where instead of 1 link you can add multiple links…

That would probably give the best experience for the user.

Actually I have found now the “feature” what I have looked for in this discussion here: RFC: Node Templates.

With this feature, as I understand it, we are then able to pre-define some content for the created node - cool!

My usage of the title text “…added statically to a page” was a bit confusing to get the idea what I actually meant.

1 Like