Skip to content

Instantly share code, notes, and snippets.

@iamrobert
Last active April 19, 2018 18:57
Show Gist options
  • Select an option

  • Save iamrobert/12c3bfd07317b604f947fec987b6ff0d to your computer and use it in GitHub Desktop.

Select an option

Save iamrobert/12c3bfd07317b604f947fec987b6ff0d to your computer and use it in GitHub Desktop.
Landing Page - Joomla if home page - redirect to language landing page version
<?php
//add at top of template index.php
//GET DEFAULT HOMEPAGE
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() == $menu->getDefault()) {
//LANGUAGE
// Initialize the language code variable
$lc = "";
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
// Check to see that the global language server variable isset()
// If it is set, we cut the first two characters from that string
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
$lc = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
// Now we simply evaluate that variable to detect specific languages
if($lc == "zh"){
JFactory::getApplication()->redirect(JURI::base().'landing/default-zh.php');
exit();
}
else { // don't forget the default case if $lc is empty
JFactory::getApplication()->redirect(JURI::base().'landing/default-en.php');
exit();
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment