Created
February 7, 2018 13:48
-
-
Save nielsnuebel/7850f0c51441886e706e3a969b1c4b0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function getAjax() | |
{ | |
$app = JFactory::getApplication(); | |
// Get an instance of the generic articles model | |
$model = JModelLegacy::getInstance('Areas', 'KickDirectoryModel', array('ignore_request' => true)); | |
$model->setState('filter.state', 1); | |
$items = $model->getItems(); | |
// Load associations | |
$assoc = JLanguageAssociations::isEnabled(); | |
$lang = JFactory::getLanguage(); | |
$languages = JLanguageHelper::getLanguages(); | |
foreach ($items as $item) | |
{ | |
$item->link = JRoute::_('index.php?Itemid=' . $item->startid); | |
if (!$assoc) | |
{ | |
continue; | |
} | |
$associations = MenusHelper::getAssociations($item->startid); | |
foreach ($languages as $language) | |
{ | |
if($language->lang_code === $lang->getTag()) | |
{ | |
$itemid = $associations[$lang->getTag()]; | |
$item->link = JRoute::_('index.php?lang=' . $language->sef . '&Itemid=' . $itemid); | |
break; | |
} | |
} | |
} | |
echo new JResponseJson($items, null, false); | |
$app->close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment