Created
November 11, 2016 10:29
-
-
Save madcatgith/a4e12b8f2098b278adafc1257b4c618b 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 getLangByTemplate($tplID = 1) { | |
$tpl = new Template(); | |
$langArray = self::getLanguages(); | |
$menuID = Url::get('menuID'); | |
$contentID = Url::get('contentID'); | |
$productID = Url::get('productID'); | |
$tagID = Url::get('tagID'); | |
if (count($langArray) == 0) { | |
return ''; | |
} | |
if ($tagID > 0) { | |
foreach ($langArray as $key => $lang) { | |
$langArray[$key]['href'] = Url::setUrl(array('lang' => $key, 'menu' => $menuID, 'tag' => Url::get('tagCnc') . '-' . $tagID)); | |
} | |
} else if ($contentID > 0) { | |
foreach ($langArray as $key => $lang) { | |
$langArray[$key]['href'] = Url::setUrl(array('lang' => $key, 'menu' => $menuID, 'content' => Url::get('contentCNC'))); | |
} | |
} else if ($productID > 0) { | |
$ps = array(); | |
$res = Registry::get('db')->query('select lang_id,cnc from ?_product where id=' . $productID,true); | |
foreach ($res->fetchAll() as $r) { | |
$ps[$r['lang_id']] = $r['cnc']; | |
} | |
foreach ($langArray as $key => $lang) { | |
$langArray[$key]['href'] = Url::setUrl(array('lang' => $key, 'menu' => $menuID, 'product' => $ps[$key])); | |
} | |
} else if ($menuID > 0) { | |
foreach ($langArray as $key => $lang) { | |
$langArray[$key]['href'] = Url::setUrl(array('lang' => $key, 'menu' => $menuID)); | |
} | |
} else { | |
foreach ($langArray as $key => $lang) { | |
$langArray[$key]['href'] = Url::setUrl(array('lang' => $key)); | |
} | |
} | |
$tpl->assign('langArray', $langArray); | |
return $tpl->fetch(BASEPATH . 'lib/wmpLang/template_' . $tplID . '.tpl'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment