Answer the question
In order to leave comments, you need to log in
How to replace the menu from the selected city?
Good day
Site on Bitrix, there is a main site and its copies in subdirectories corresponding to different cities, when choosing a city, a cookie is written, in the .left.menu_ext.php file, a part of the menu is assembled with the following code:
<?
if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
global $APPLICATION;
if(CModule::IncludeModule("iblock"))
{
if ($_COOKIE['userCity']=='irkutsk') {
$IBLOCK_ID = 25;
} elseif ($_COOKIE['userCity']=='rostov') {
$IBLOCK_ID = 49;
} elseif ($_COOKIE['userCity']=='khabarovsk') {
$IBLOCK_ID = 48;
} elseif ($_COOKIE['userCity']=='rostov') {
$IBLOCK_ID = 31;
} else {
$IBLOCK_ID = 5;
}
// указываем из какого инфоблока берем элементы
$arOrder = Array("SORT"=>"ASC"); // сортируем по свойству SORT по возрастанию
$arSelect = Array("ID", "NAME", "IBLOCK_ID", "DETAIL_PAGE_URL");
$arFilter = Array("IBLOCK_ID"=>$IBLOCK_ID, "ACTIVE"=>"Y");
$res = CIBlockElement::GetList($arOrder, $arFilter, false, false, $arSelect);
while($ob = $res->GetNextElement())
{
$arFields = $ob->GetFields(); // берем поля
// начинаем наполнять массив aMenuLinksExt нужными данными
$aMenuLinksExt[] = Array(
$arFields['NAME'],
$arFields['DETAIL_PAGE_URL'],
Array(),
Array(),
""
);
} // while($ob = $res->GetNextElement())
} // if(CModule::IncludeModule("iblock"))
$aMenuLinks = array_merge($aMenuLinksExt, $aMenuLinks);
// $aMenuLinks = array_merge($aMenuLinks);
?>
if ($_COOKIE['userCity']=='irkutsk') {
$IBLOCK_ID = 25;
} elseif ($_COOKIE['userCity']=='rostov') {
$IBLOCK_ID = 49;
} elseif ($_COOKIE['userCity']=='khabarovsk') {
$IBLOCK_ID = 48;
} elseif ($_COOKIE['userCity']=='rostov') {
$IBLOCK_ID = 31;
} else {
$IBLOCK_ID = 5;
}
Answer the question
In order to leave comments, you need to log in
There is no binding to the site (SITE_ID), it seems to me that this is the reason
Is $_COOKIE['userCity'] exactly what you expect? Is the menu component's cache disabled?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question