2
votes

how can i build a TYPO3 special-Menu in fluid with tt_content Header Elements, not the "pages" ?

https://docs.typo3.org/typo3cms/extensions/fluid_styled_content/7.6/ContentElements/Menu/Index.html

The Type-3 is a good Example, but i can only selected in the BE the Pages, not the tt_content - Elements.

<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" xmlns:ce="http://typo3.org/ns/TYPO3/CMS/FluidStyledContent/ViewHelpers" data-namespace-typo3-fluid="true">
<ce:menu.list pageUids="{pageUids}" as="pages">
<f:if condition="{pages}">
    <ul class="ce-menu ce-menu-3">
        <f:for each="{pages}" as="page">
            <ce:menu.section pageUid="{page.uid}" as="contentElements" type="header">
                <f:if condition="{contentElements}">
                    <f:for each="{contentElements}" as="contentElement">
                        <li>
                            <f:link.page pageUid="{page.uid}" section="c{contentElement.uid}">
                                {contentElement.header}
                            </f:link.page>
                        </li>
                    </f:for>
                </f:if>
            </ce:menu.section>
        </f:for>
    </ul>
</f:if>
</ce:menu.list>
</html>
2
Do you want to use this in menu? - gautamsinh mori

2 Answers

1
votes

I suppose you get back content elements which have "Show in Section Menus" enabled, and have the header filled and not hidden. The menu.section viewhelper does not have the possibility to filter on content element type. The type="header" argument of the view helper is not a filter for the content element type, but checks if there is a visible header_layout and the header field is not empty. I agree, the argument name type is misleading.

If you want to filter on content type (CType), add an extra "if" statement, filtering on {contentElement.CType} == header during the iteration of the content elements

<f:for each="{contentElements}" as="contentElement">
    <f:if condition="{contentElement.CType} == 'header'">
        <li>
            <f:link.page pageUid="{page.uid}" section="c{contentElement.uid}">
                {contentElement.header}
            </f:link.page>
        </li>
    </f:if>
</f:for>

Better would be to write your own view helper for this, if you have the knowledge to do it.

0
votes

First of all you should rename your question so it is clear that you want to create a content menu that works with grid_elements

I had the same problem and could not find another way but to create a small extension for that purpose since you have to modify the search query for the content. You can find it here: https://typo3.org/extensions/repository/view/gridelements_content_menu

There is currently no manual, just install the extension and include the static TS in your template. The resulting Menu might not be sorted right if your content elements are nested deeper than one level with grid_elements