Last active
November 16, 2019 17:09
-
-
Save Elvinz/f9babf3ef2e47ad4ab526c82b5ac97a9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
для вот такого аjax поиска нам нужно не много. | |
файл search.php , в нужной вам папке (написано на d7 c костылем) | |
https://ftask.ru/category/bitrix/d7/ | |
<? | |
/** | |
* Created by PhpStorm. | |
* User: | |
* Date: 14.09.2018 | |
* Time: 12:51 | |
*/ | |
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php"); | |
CModule::IncludeModule("iblock"); | |
//http://ck21318.tmweb.ru/include/ajax/search.php?text=краб | |
\Bitrix\Main\Loader::includeModule('iblock'); | |
$text=$_REQUEST['text']; | |
$dbItems = \Bitrix\Iblock\ElementTable::getList(array( | |
'select' => array('ID', 'NAME', 'IBLOCK_ID' , 'PREVIEW_PICTURE', ), //,'DETAIL_PAGE_URL' | |
'filter' => array('IBLOCK_ID' => 12 ,'NAME'=>'%'.strip_tags($text).'%'), | |
'limit'=>10 | |
)); | |
$arrResult=array(); | |
while ($arItem = $dbItems->fetch()){ | |
//DETAIL_PAGE_URL d7 не выводит!!! | |
$el_res= CIBlockElement::GetByID( $arItem['ID'] ); | |
if ( $el_arr= $el_res->GetNext() ) { | |
$arItem['DETAIL_PAGE_URL']= $el_arr[ 'DETAIL_PAGE_URL' ]; | |
$arItem['PREVIEW_PICTURE']= CFile::GetPath( $el_arr[ 'PREVIEW_PICTURE' ] ) ; | |
} | |
// debug($arItem); | |
$arrResult[]=$arItem; | |
} | |
foreach ($arrResult as $item){ | |
?> | |
<a href="<?=$item['DETAIL_PAGE_URL']?>" class="tip"> | |
<div class="thumb"> | |
<img style="width:100%" src="<?=$item['PREVIEW_PICTURE']?>" alt=""> | |
</div> | |
<div class="info"> | |
<!-- <div class="cat">Мебель для ванной</div>--> | |
<div class="name"><?=$item['NAME']?></div> | |
</div> | |
<div class="link">Перейти к товару</div> | |
</a> | |
<?php | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment