Fluid Typo3 - How to get variables defined through a stream from different pages

I think my problem is easily solved, but I have been thinking about it for a few days and google did not help me. Maybe I just don't understand the concept :-).

In my vendor extension, I define a simple master page with one configuration parameter. Depending on what the "fontawesomeicon" says for the page, the corresponding Fonteawesome-Icon should be placed before the menu entry text. But when I implement it this way, each page menu page gets an icon from the actual page. I don't know how to tell the system that the corresponding {fontawesomeicon} should be taken from this page this entry belongs to.

Thanks for any hints to get it working. I am using Typo3 7.1

Fullpage.html page configuration:

<f:section name="Configuration">
    <flux:form id="fullpage" />
    <flux:grid>
        <flux:grid.row>
            <flux:grid.column colPos="0" name="main" />
        </flux:grid.row>
    </flux:grid>
    <flux:field.input name="fontawesomeicon" />
</f:section>

      

Partial configuration of Elements.html:

<f:section name="MainMenu">
    <ul class="sf-menu">
        <v:page.menu pageUid="{settings.startpageUid}" entryLevel="2" levels="2" expandAll="TRUE" as="menu">
            <f:for each="{menu}" as="item">
                <li class="{item.class}">
                    <a href="{item.link}"><i class="fa fa-lg {fontawesomeicon}"></i>&nbsp;{item.linktext}</a>
                    <f:if condition="{item.hasSubPages}">
                        <ul>
                            <f:render section="SubMenu" arguments="{_all}" />
                        </ul>
                    </f:if>
                </li>
            </f:for>
        </v:page.menu>
    </ul>
</f:section>

<f:section name="SubMenu">
    <v:page.menu pageUid="{item.uid}" entryLevel="2" levels="1" as="submenu">
        <f:for each="{submenu}" as="subitem">
            <li class="{subitem.class}">
                <a href="{subitem.link}"><i class="fa {fontawesomeicon}"></i>&nbsp;{subitem.linktext}</a>
            </li>
        </f:for>
    </v:page.menu>
</f:section>

      

Just to complete it ... by linking it in the Page.html page layout file:

<f:layout name="Page" />
<f:render section="MainMenu" partial="Elements" arguments="{_all}" />
<f:render section="Main" />

      

+3


source to share


2 answers


Finally got it. This is an old problem ... how do you ask the right question if you don't get to the real question. Another post (on flexform access) gave me one final hint. Hooray!



<f:section name="MainMenu">
    <ul class="sf-menu">
        <v:page.menu pageUid="{settings.startpageUid}" entryLevel="2" levels="2" expandAll="TRUE" as="menu">
            <f:for each="{menu}" as="item">
                <li class="{item.class}">
 <!--new:-->        <flux:form.data table="pages" field="tx_fed_page_flexform" uid="{item.uid}" as="menuIcon">
                        <a href="{item.link}"><i class="fa fa-lg {menuIcon.fontawesomeicon}"></i>&nbsp;{item.linktext}</a>
 <!--new:-->        </flux:form.data>
                    <f:if condition="{item.hasSubPages}">
                        <ul>
                            <f:render section="SubMenu" arguments="{_all}" />
                        </ul>
                    </f:if>
                </li>
            </f:for>
        </v:page.menu>
    </ul>
</f:section>

<f:section name="SubMenu">
    <v:page.menu pageUid="{item.uid}" entryLevel="2" levels="1" as="submenu">
        <f:for each="{submenu}" as="subitem">
            <li class="{subitem.class}">
 <!--new:-->    <flux:form.data table="pages" field="tx_fed_page_flexform" uid="{subitem.uid}" as="subMenuIcon">
                    <a href="{subitem.link}"><i class="fa {subMenuIcon.fontawesomeicon}"></i>&nbsp;{subitem.linktext}</a>
 <!--new:-->    </flux:form.data>
            </li>
        </f:for>
    </v:page.menu>
</f:section>

      

+2


source


Using the variable "fontawesomeicon" directly, the value is always the same as set in the controller that renders the template, you need to specify a new context.

Debug variables in the foreach loop with <f:debug>{varname}</f:debug>

and check if the "fontawesomeicon" field is present.



<f:section name="SubMenu">
    <v:page.menu pageUid="{item.uid}" entryLevel="2" levels="1" as="submenu">
        <f:for each="{submenu}" as="subitem">
            <li class="{subitem.class}">
                <f:debug>{subitem}</f:debug>
                <a href="{subitem.link}"><i class="fa {fontawesomeicon}"></i>&nbsp;{subitem.linktext}</a>
            </li>
        </f:for>
    </v:page.menu>
</f:section>

      

I also recommend using TypoScript ( HMENU, TMENU

) for menus instead of Fluid-Templates

0


source







All Articles