Redirecting users to language..
Permalink
I now put this in index.php..
Only I think it is the wrong place.. how to check if a users not access the index? but wants to access a specific page from somewhere then they should not be redirected.
like if somebody wants to see /en/contact/ they should not be redirected... only if they want to access domain/index.php
<?php session_start(); function getLanguage() { $lang = $_SERVER['HTTP_ACCEPT_LANGUAGE']; $lang = substr($lang, 0, 2); return $lang; } if(!isset($_SESSION['site_language'])){ $_SESSION['site_language'] = getLanguage(); switch ($_SESSION['site_language']) { case 'en': header("Location: /en/"); break; case 'th':
Viewing 15 lines of 23 lines. View entire code block.
Only I think it is the wrong place.. how to check if a users not access the index? but wants to access a specific page from somewhere then they should not be redirected.
like if somebody wants to see /en/contact/ they should not be redirected... only if they want to access domain/index.php
if you look in the index.php it points to the dispatcher.php
Yes but modifying the dispatcher does not seems like a good idea.. Most frameworks have the ability to extend or override the front controller... or have some sort of bootstrap.
I agree. I've been trying to figure out how to extend the base/front controller for a while. This article (http://www.concrete5.org/index.php?cID=30241) mentions an 'on_start' hook that will apparently be available in future versions. Check it out for how to implement it now.
In the template:
Still wondering if there is anyway to extend the front controller as this should not really be in the theme :P