Skip to content

Commit

Permalink
Added css class to active menu items
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagocamposviana committed Dec 17, 2013
1 parent b823b5a commit 44722e2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Classes/Components/SideMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function render(){


return $this->controller->render(
'TuteiBaseBundle:parts:side_menu.html.twig', array('list' => $list), $response
'TuteiBaseBundle:parts:side_menu.html.twig', array('list' => $list, 'locations'=>$locations), $response
);


Expand Down
4 changes: 3 additions & 1 deletion Classes/Components/TopMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ public function render(){
new LocationPriority(Query::SORT_ASC)
);
$list = $searchService->findContent($query);

$locations = explode('/', $this->parameters['pathString']);


return $this->controller->render(
'TuteiBaseBundle:parts:top_menu.html.twig', array(
'list' => $list
'list' => $list, 'locations'=>$locations
), $response
);
}
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/pagelayout.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<div class="navbar-collapse collapse">

<ul class="nav navbar-nav">
{{ render( controller( "tutei:showComponent", { 'name': 'TopMenu' } ) ) }}
{{ render( controller( "tutei:showComponent", { 'name': 'TopMenu','parameters' : {'pathString': location.pathString } } ) ) }}
</ul>
<form class="navbar-form navbar-right" role="form" method="get" action="{{ path( 'ez_legacy', {'module_uri': '/content/search'} ) }}">
<div class="form-group">
Expand Down
6 changes: 5 additions & 1 deletion Resources/views/parts/side_menu.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
<div class="navbar navbar-collapse side-menu" role="navigation">
<ul class="nav nav-tabs nav-stacked">
{% for item in list.searchHits %}
<li>{{ render(
{% set active = false %}
{% if item.valueObject.versionInfo.contentInfo.mainLocationId in locations %}
{% set active = true %}
{% endif %}
<li{% if active %} class="active"{% endif %}>{{ render(
controller(
'ez_content:viewLocation',
{
Expand Down
9 changes: 7 additions & 2 deletions Resources/views/parts/top_menu.html.twig
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
{% for item in list.searchHits %}
<li>{{ render(

{% set active = false %}
{% if item.valueObject.versionInfo.contentInfo.mainLocationId in locations %}
{% set active = true %}
{% endif %}
<li{% if active %} class="active"{% endif %}>{{ render(
controller(
'ez_content:viewLocation',
{
'locationId': item.valueObject.versionInfo.contentInfo.mainLocationId,
'viewType': 'menu_item',
'params': {}
'params': {'active':active}
}
)
) }}</li>
Expand Down

0 comments on commit 44722e2

Please sign in to comment.