Reputation: 445
I'm using TYPO3 v. 8.7 and ext. vhs
Is it possible to make a condition that checks for current page? Have tried the code below but it does not work. I think it should then be possible to check for Current page
<v:page.menu expandAll="1" entryLevel="1" >
<f:for each="{menu}" as="menuPage" iteration="iteration">
<f:if condition="{menuPage.isCurrentPage}">
<f:then>is current page</f:then>
<f:else>is not current page</f:else>
</f:if>
</f:for>
</v:page.menu>
Upvotes: 0
Views: 1424
Reputation: 2148
I don't know which version of EXT:VHS you are using, maybe an old one (as you wrote the deprecated v:page.menu
instead of v:menu
).
You can discover all the options available for each item on the menu and their current value just using
<f:debug>{_all}</f:debug>
Like this:
<v:page.menu expandAll="1" entryLevel="1" >
<f:for each="{menu}" as="menuPage" iteration="iteration">
<f:debug>{_all}</f:debug>
<f:if condition="{menuPage.uid} == {data.uid}">
<f:then>is current page </f:then>
<f:else>is not current page</f:else>
</f:if>
</f:for>
</v:page.menu>
On version 6.0.0 (the one I am currently using) there are the boolean current
and active
so your code should be just:
<v:menu expandAll="1" entryLevel="1" >
<f:for each="{menu}" as="menuPage" iteration="iteration">
<f:if condition = "{menuPage.current}">
<f:then>is current page </f:then>
<f:else>is not current page</f:else>
</f:if>
</f:for>
</v:menu>
Plus, if you just need a different class for your "active" or "current" items, you can also use the v:menu
arguments ´classActive´ and classCurrent
for example:
<v:menu expandAll="1" entryLevel="1" classCurrent="is-current" classActive="is-active">
<f:for each="{menu}" as="menuPage" iteration="iteration">
<li class="{menuPage.class}">
<f:link.page pageUid="{menuPage.uid}" title="{menuPage.linktext}">{menuPage.linktext}</f:link.page>
</li>
</f:for>
</v:menu>
Upvotes: 1
Reputation: 445
I have temporarily resolved it as follows. But I don't think that's the nicest solution.
<v:page.menu expandAll="1" entryLevel="1" >
<f:for each="{menu}" as="menuPage" iteration="iteration">
<f:if condition="{menuPage.uid} == {data.uid}">
<f:then>is current page </f:then>
<f:else>is not current page</f:else>
</f:if>
</f:for>
</v:page.menu>
Upvotes: 0