Adding locale selection

This commit is contained in:
Marc Ducobu 2014-11-12 15:28:43 +01:00
parent 52c48f5b5d
commit 1ebb4662c1
3 changed files with 24 additions and 10 deletions

View File

@ -10,4 +10,9 @@ class DefaultController extends Controller
{
return $this->render('ChillMainBundle::layout.html.twig');
}
}
public function indexWithoutLocaleAction()
{
return $this->redirect($this->generateUrl('chill_main_homepage'));
}
}

View File

@ -4,6 +4,14 @@ root:
_controller: FrameworkBundle:Redirect:urlRedirect
path: /homepage
permanent: true
chill_main_homepage_without_locale:
pattern: /homepage
defaults: { _controller: ChillMainBundle:Default:indexWithoutLocale }
chill_main_homepage:
pattern: /{_locale}/homepage
defaults: { _controller: ChillMainBundle:Default:index }
options:
menus:
section:
@ -11,12 +19,8 @@ root:
label: Homepage
icon: home
cl_chill_main_homepage:
pattern: /homepage
defaults: { _controller: ChillMainBundle:Default:index }
chill_main_admin_central:
pattern: /admin
pattern: /{_locale}/admin
defaults: { _controller: ChillMainBundle:Admin:index }
options:
menus:
@ -39,4 +43,4 @@ logout:
user:
order: 10
label: Logout
icon: power-off
icon: power-off

View File

@ -49,16 +49,21 @@
'layout': 'ChillMainBundle::Menu/user.html.twig',
}) }}
<li class="nav-link more"><a href="javascript:void(0)">FR</a>
<ul class="submenu">
<li><a href="javascript:void(0)">FR</a></li>
<li><a href="javascript:void(0)">NL</a></li>
<li><a href="javascript:void(0)">EN</a></li>
{% for locale in ['fr', 'nl', 'en'] %}
<li {% if locale == app.request.locale %}class="active"{% endif %}>
<a href="{{ path(app.request.get('_route'), app.request.get('_route_params')|merge({'_locale' : locale})) }}">{{ locale | upper }}</a>
</li>
{% endfor %}
</ul>
</li>
</ul>
</div>
</header>
{{ app.request.locale }}
{% block layout_content %}
<div class="container content">