bootstrap_package
bootstrap_package copied to clipboard
Home link active only on home page in main navigation
Support
Description
Dear community,
in previous version this TS has worked to mark the pagelink with id 2 as active, when on the root page with id 1. The page with id 1 has the actual content of the home page.
[page["uid"] == 1]
page.10.dataProcessing.10.alwaysActivePIDlist = 2
[END]
Now even if removing this condition the home item with id 2 remains marked as active.
Please help to achieve the result where id 2 is marked active when on page 1. Thank you.
Screenshots
Hi all, i can confirm this behavior. By debugging the fluid template there are 2 pages marked as "active=1" in the menu the same time if you klick on a page of the menu. For example if you click the features page than this page is shown as active and still the root page is marked as active = 1 - so the root page still stay as marked active=1 no matter which other page is selected. I checked the template here i cant find a problem - any hints? Thx Many greetings
Hi all, i was digging deeper into the problem of having always the root page as marked "active". I also checked the introduction package on a fresh installed TYPO3 site. TYPO3 version 11.5.13 bootstrap package: 12.0.5 Here the same issue appear. I am not able to find out, if it is a issue of TYPO3 or bootstrap package. Probably there is something wrong with the menu processor in TYPO3 or likely in the bootstrap package.
I was lookong for a typoscript solution to deactivate the active state of the root page. so i searched for the opposite of : "page.10.dataProcessing.10.alwaysActivePIDlist = 0" I had no luck, is there a typoscript solution, any hints?
Anyway, i tryed to fix it in the templates itselfs. After a few try and error attemps i found a working solution for me. It is probably very ugly and complicated. But for now i go with this untill there is another solution. Maybe some of the masterminds can make the solution easyer? (!) ok here what i did: in the folder Resources\Private\Partials\Page\Navigation\ i changed the main.html as follow:
i addes a iteration on the menu: <f:if condition="{menu}">
upps most of my code was gone. here again:
class="nav-item{f:if(condition: '{iterator.isFirst} == 1 && {item.current} == 1', then: ' active', else: '')}{f:if(condition: '{iterator.isFirst} != 1 && {item.active} == 1', then: ' active', else: '')}{f:if(condition: item.children, then:' dropdown dropdown-hover
Update: well, my solution looks like it is not very smart. If all of the main-navigation pages are moved after a page-spacer it works no longer, cause the iterator.isFirst condition isn`t working no more correct. The iteraror number then is "3" and the same problems with the double marked as "acive" page is back again. Again two pages are active the same time. Of course now it is possible to create a new var with a counter or some other weird constructions.
No one else got that problem? THX and have a nice day
ok - more info about this topic:
https://forge.typo3.org/issues/97037
it seems this behaviour startet with update TYPO3 from 11.5.4 to 11.5.5;
I hope there will be a fix out soon.
I've fixed it quick & dirty with this:
<f:variable name="active"><f:if condition="{item.active}"> active</f:if></f:variable>
<f:if condition="{item.link} == '/'"><f:variable name="active"><f:if condition="{item.current}"> active</f:if></f:variable></f:if>
<li class="nav-item{active}{f:if(condition: item.children, then:' dropdown dropdown-hover')}">
Hi SventB and thank you for the solution - worked great untill i updated the bootstrap_package to version 14.0.1 and wanted to use the original templates of that version. There are changes in the template files.
The fix in the template: Resources/Private/Partials/Page/Navigation/MainNavigation.html is no more working cause the structure has changed.
Did you adapt your fix to the new templates? And if so, you want to share?
I was hoping, that with the new version (TYPO3 12 or a new Bootstrap-Package) the problem with two active marked menu items would be fixed - unfortunatly the issue is still present.
i wonder that not more ppl report this issue. The issue is also on https://www.bootstrap-package.com and is in my mind not the best first impression and should be fixed generally - either in the TYPO3 core or preventive as workaround or solution in the bootstrap package.
Who agrees with me? Or i am wrong?
THX
also many thanks to Benjamin Kott for that great extension!!
Ok, i think i could adapt your fix to the templates of bootstrap-package vers. 14.0.1 make a variable usable like before with the same code in: Resources/Private/Partials/Page/Navigation/MainNavigation.html
use:
<f:variable name="active"><f:if condition="{item.active}"> active</f:if></f:variable> <f:if condition="{item.link} == '/'"><f:variable name="active"><f:if condition="{item.current}"> active </f:if></f:variable></f:if>
than in line 21 change: class="nav-link nav-link-main{f:if(condition: item.active, then:' active')}" to: class="nav-link nav-link-main{f:if(condition: item.active, then:'{active}')}" so far it looks like it is working perfect