[FLOW3-general] checking for active uri

Michael Gerdemann michael.gerdemann at avency.de
Wed Dec 12 07:17:59 CET 2012


Hi Robin,

have a look at this ticket:
http://forge.typo3.org/issues/41439#note-2

Regards,
Michael



On Tue, 11 Dec 2012 17:44:51 +0100, Robin Lehrmann
<robin at snow-hamster.de> wrote:

>Hello together.
>
>I want to create a simple menu template:
>Controller:
>public function initializeView(\TYPO3\Flow\Mvc\View\ViewInterface $view) {
>         /* @var $view \TYPO3\Fluid\View\TemplateView */
>$view->setPartialRootPath('../Packages/Application/SNOW.Start/Resources/Private/Partials');
>         $this->uriBuilder->setCreateAbsoluteUri(TRUE);
>         $view->assign('active-menu-item', $this->uriBuilder->uriFor());
>}
>
>Template (eq Partial):
><div class="menu">
>     <div class="menu-item">
>     <a id="projects"<f:if condition="{active-menu-item} == 
>{f:uri.action(absolute: true, package: 'SNOW.Projects', controller: 
>'Standard', action: 'index')}">class="active"</f:if> 
>href="{f:uri.action(absolute: true, package: 'SNOW.Projects', 
>controller: 'Standard', action: 'index')}">
>         <img alt="projects" src="{f:uri.resource(path: 
>'Images/projects.png', package: 'SNOW.Start')}" />
>     </a>
>     </div>
>     <div class="menu-item">
>     <a id="blog"<f:if condition="{active-menu-item} == 
>{f:uri.action(absolute: true, package: 'SNOW.Blog', controller: 
>'Standard', action: 'index')}">class="active"</f:if> 
>href="{f:uri.action(absolute: true, package: 'SNOW.Blog', controller: 
>'Standard', action: 'index')}">
>         <img alt="blog" src="{f:uri.resource(path: 'Images/blog.png', 
>package: 'SNOW.Start')}" />
>     </a>
>     </div>
>     <div class="menu-item">
>     <a id="person"<f:if condition="{active-menu-item} == 
>{f:uri.action(absolute: true, package: 'SNOW.Person', controller: 
>'Standard', action: 'index')}">class="active"</f:if> 
>href="{f:uri.action(absolute: true, package: 'SNOW.Person', controller: 
>'Standard', action: 'index')}">
>         <img alt="person" src="{f:uri.resource(path: 
>'Images/person.png', package: 'SNOW.Start')}" />
>     </a>
>     </div>
>     <div class="menu-item">
>     <a id="justice"<f:if condition="{active-menu-item} == 
>{f:uri.action(absolute: true, package: 'SNOW.Justice', controller: 
>'Standard', action: 'index')}">class="active"</f:if> 
>href="{f:uri.action(absolute: true, package: 'SNOW.Justice', controller: 
>'Standard', action: 'index')}">
>         <img alt="justice" src="{f:uri.resource(path: 
>'Images/justice.png', package: 'SNOW.Start')}" />
>     </a>
>     </div>
></div>
>
>it works, but it's really involved.
>My Idea is maybe to add an function to check if the menu entry is active.
><f:link.action activeClass="active">Link</f:link.action>
><output>
><a href="http://example.de/route.html" class="active"></a>
></output>
>
>I would set the default classname to active.
>Cheers, Robin


More information about the FLOW3-general mailing list