Answer the question
In order to leave comments, you need to log in
Why does the code work under admin and not under guest?
The code
<a href="/inc/ajax/city.php" class="lightbox-inline-ajax"><?=$_SESSION['city']?><?=$cont[0]["NAME"]?></a>
<?include($_SERVER['DOCUMENT_ROOT']."/bitrix/modules/main/include/prolog_before.php");
$template = '/bitrix/templates/main';
include($_SERVER['DOCUMENT_ROOT'].$template."/inc/functions.php");
IncludeTemplateLangFile($template.'/header.php');
CModule::IncludeModule("iblock");
CModule::IncludeModule("catalog");
CModule::IncludeModule("sale");?>
<div id="city" class="lightbox mfp-hide">
<p class="h3">Выбрать город</p>
<input type="text" class="search-city input-text selcity" placeholder="Ваш город">
<div class="scroll-city load_cities">
<ul>
<small>Выберите город из списка, или начните вводить название.</small><br>
<li><a class="" href="?city=Астрахань">Астрахань</a><br>
<li><a class="" href="?city=Волгоград">Волгоград</a><br>
<li><a class="" href="?city=Краснодар">Краснодар</a><br>
<li><a class="" href="?city=Сочи">Сочи</a><br>
<li><a class="" href="?city=Новороссийск">Новороссийск</a><br>
<li><a class="" href="?city=Ростов-на-Дону">Ростов-на-Дону</a><br>
<li><a class="" href="?city=Севастополь">Севастополь</a><br>
<li><a class="" href="?city=Ставрополь">Ставрополь</a><br>
<li><a class="" href="?city=Новороссийск">Новороссийск</a><br>
</ul>
<div class="clr"></div>
</div>
</div><!--.lightbox-end-->
<script>
$('.selcity').on('keyup', function(){
$('.load_cities').load('/inc/ajax/cities.php', {'name':$(this).val()});
});
</script>
<?include($_SERVER['DOCUMENT_ROOT']."/bitrix/modules/main/include/prolog_before.php");
CModule::IncludeModule("iblock");
CModule::IncludeModule("catalog");
CModule::IncludeModule("sale");?>
<div class="scroll-city">
<ul>
<?$filter = array("LID" => LANGUAGE_ID);
$filter = array("LID" => LANGUAGE_ID);
if($_POST['name']!='') $filter["%CITY_NAME"] = $_POST['name'];
$db_vars = CSaleLocation::GetList(array("CITY_NAME"=>"ASC"),$filter);
$n = 0;
while($city = $db_vars->GetNext()):
$n++;
//if(!preg_match("#^".strtolower($_POST['q'])."#i",strtolower($city['CITY_NAME']))) continue;
if(trim($city['CITY_NAME']=='')) continue;?>
<li><a href='?city=<?=$city['CITY_NAME']?>' noindex nofollow class="unitt"><?=$city['CITY_NAME']?></a><!--li-end-->
<?if($n>30){?>
<br><small>Введите больше букв, чтобы получить нужный город</small>
<?break;
}?>
<?endwhile;?>
</ul>
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question