Added current menu indicator to menu bar

This commit is contained in:
Gergely POLONKAI 2012-10-06 19:34:15 +02:00
parent 0d49fd358c
commit 0b75f27188
4 changed files with 94 additions and 14 deletions

View File

@ -71,18 +71,37 @@ body {
}
#menu {
background-color: #b5b5b5;
height: 39px;
}
#menu ul {
margin: 0;
margin: 8px;
padding: 0;
list-style-type: none;
text-align: right;
vertical-align: middle;
}
#menu ul li {
display: inline;
float: right;
margin-top: 10px;
margin-bottom: 10px;
margin-left: 1em;
height: 30px;
}
#menu ul li.active {
background-image: url('../images/arrow-up.png');
background-repeat: no-repeat;
background-position: center bottom;
}
#menu ul li a {
color: white;
font-weight: bold;
text-decoration: none;
font-size: 12px;
}
#content {
@ -170,6 +189,7 @@ dd p {
#tag-cloud a {
color: #b3b3b3;
text-decoration: none;
padding: 8px;
}
#tag-cloud .size0 {
@ -194,4 +214,8 @@ dd p {
#tag-cloud .size5 {
font-size: 150%;
}
.clear {
clear: both;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

View File

@ -32,22 +32,23 @@
<a href="{{ path('GergelyPolonkaiFrontBundle_blogFeed') }}"><img src="{{ asset('bundles/gergelypolonkaifront/images/rss_16.png') }}" alt="RSS Feed" /></a>
</div>
</div>
<div id="content">
<div id="content-padding"></div>
<div id="content-padding"></div>
{% if tagCloud|length > 0 %}
<div id="tag-cloud">
<div id="tag-cloud">
{% for cloudItem in tagCloud %}
<a href="{{ path('GergelyPolonkaiFrontBundle_blogTagList', { name: cloudItem.name }) }}" class="size{{ cloudItem.size }}">{{ cloudItem.name }}</a>{% if not loop.last %} | {% endif %}
<a href="{{ path('GergelyPolonkaiFrontBundle_blogTagList', { name: cloudItem.name }) }}" class="size{{ cloudItem.size }}">{{ cloudItem.name }}</a>{% if not loop.last %} | {% endif %}
{% endfor %}
</div>
</div>
{% endif %}
<div id="menu">
<ul>
<li><a href="{{ path('GergelyPolonkaiFrontBundle_about') }}">About me</a></li>
<li><a href="{{ path('GergelyPolonkaiFrontBundle_blogListing') }}">Blog</a></li>
<li><a href="{{ path('GergelyPolonkaiFrontBundle_resume', { _format: 'html' }) }}">Resume</a></li>
</ul>
</div>
<div id="menu">
<ul>
<li {% if currentMenu == 'resume' %} class="active"{% endif %}><a href="{{ path('GergelyPolonkaiFrontBundle_resume', { _format: 'html' }) }}">Resume</a></li>
<li {% if currentMenu == 'blog' %} class="active"{% endif %}><a href="{{ path('GergelyPolonkaiFrontBundle_blogListing') }}">Blog</a></li>
<li {% if currentMenu == 'about' %} class="active"{% endif %}><a href="{{ path('GergelyPolonkaiFrontBundle_about') }}">About me</a></li>
</ul>
<br class="clear" />
</div>
<div id="content">
{% block content %}{% endblock content %}
</div>
</div>

View File

@ -0,0 +1,55 @@
<?php
namespace GergelyPolonkai\FrontBundle\Twig;
use Symfony\Component\DependencyInjection\ContainerInterface;
use JMS\DiExtraBundle\Annotation as DI;
/**
* Description of CurrentMenu
*
* @author Gergely Polonkai
*
* @DI\Service
* @DI\Tag(name="twig.extension")
*/
class CurrentMenu extends \Twig_Extension
{
/**
* @var Symfony\Component\DependencyInjection\ContainerInterface $container
*/
private $container;
/**
* @DI\InjectParams({
* "container" = @DI\Inject("service_container")
* })
*/
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
public function getGlobals()
{
$controller = $this->container->get('request')->get('_controller');
$route = $this->container->get('request')->get('_route');
$currentMenu = 'none';
if (preg_match('/BlogController/', $controller)) {
$currentMenu = 'blog';
} elseif (preg_match('/_homepage$/', $route)) {
$currentMenu = 'blog';
} elseif (preg_match('/_resume$/', $route)) {
$currentMenu = 'resume';
} elseif (preg_match('/_about$/', $route)) {
$currentMenu = 'about';
}
return array(
'currentMenu' => $currentMenu,
);
}
public function getName()
{
return 'gergelypolonkaifront_currentmenu';
}
}