3

I guess my problem is easily solved, but I'm thinking for days about it, googling didn't help me out. Maybe I just don't understand the concept :-).

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

Thanks for any hints to get it working. I'm useing Typo3 7.1

Page config Fullpage.html:

<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 config 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... putting it together in the page layout file Page.html:

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

2 Answers2

2

Finally got it. It's the old problem... how do you ask the right question if you don't get to the real matter. Another post (about accessing flexform) gave me the final hint. Yay!

<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>
DerPeer
  • 51
  • 7
0

By 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 the variables in the foreach-loop with <f:debug>{varname}</f:debug> and check if the field "fontawesomeicon" 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 to use TypoScript (HMENU, TMENU) for menus instead of Fluid-Templates

Merec
  • 2,751
  • 1
  • 14
  • 21
  • 1
    Thank you so far. But that is the real point, where I seem to have a lack of knowledge and understandig. What do I need to add that the variable gets "foreach-ed" like this item. Is there maybe a hierarchy that could be used like {item.uid.fontawesomeicon}. Or a way to add the pageUid where to take the information from? And yes, the field is present, gets rendered. ... And why better use Typoscript? I just switched over from that, thougt it might be easier the Fluid way (far better to read at least). Are there any disadvantages on using fluid? – DerPeer Jul 22 '15 at 19:59