Skip to content

Instantly share code, notes, and snippets.

@Kaapiii
Last active December 19, 2015 08:49
Show Gist options
  • Save Kaapiii/5928131 to your computer and use it in GitHub Desktop.
Save Kaapiii/5928131 to your computer and use it in GitHub Desktop.
Beta langNavBar Beta
<?php
/**
* getFrontendLangNavigation()
* @param \Cx\Core\Routing\Url $pageUrl
* @param boolean $langNameContraction
* @return string
*/
function getFrontendLangNavigation($page, $pageUrl, $langNameContraction = false)
{
$activeLanguages = \FWLanguage::getActiveFrontendLanguages();
$node = $page->getNode();
if(self::$objTemplate->blockExists('ul')){
self::$objTemplate->parse('ul');
}
$langNavigation = array();
foreach ($activeLanguages as $langId => $langData) {
$targetPage = $node->getPage($langId);
if ($targetPage && $targetPage->isActive()) {
$url = clone $pageUrl;
$url->setLangDir($langData['lang']);
$url->setPath(substr($targetPage->getPath(), 1));
$name = contrexx_raw2xhtml($langNameContraction ? strtoupper($langData['lang']) : $langData['name']);
$class = $langId == FRONTEND_LANG_ID ? $langData['lang'].' active' : $langData['lang'];
$langNavigation[] = '<a class="'.$class.'" href="'.$url.'" title="'.$name.'">'.$name.'</a>';
$objTemplate->setVariable(array(
'HOTELCARD_WATCHLIST' => \HotelWatchlist::getWatchlist()
));
if(self::$objTemplate->blockExists('li')){
self::$objTemplate->parse('li');
}
}
}
return implode('', $langNavigation);
}
<!-- BEGIN ul -->
<ul>
<!-- BEGIN li -->
<span>[[HOTELCARD_WATCHLIST]]</span>
<!-- END li -->
</ul>
<!-- END ul -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment