Exemplo n.º 1
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
?>
<div class="search-page">
<form action="" method="get">
<?php 
if ($arParams["USE_SUGGEST"] === "Y") {
    if (strlen($arResult["REQUEST"]["~QUERY"]) && is_object($arResult["NAV_RESULT"])) {
        $arResult["FILTER_MD5"] = $arResult["NAV_RESULT"]->GetFilterMD5();
        $obSearchSuggest = new CSearchSuggest($arResult["FILTER_MD5"], $arResult["REQUEST"]["~QUERY"]);
        $obSearchSuggest->SetResultCount($arResult["NAV_RESULT"]->NavRecordCount);
    }
    ?>
	<?php 
    $APPLICATION->IncludeComponent("bitrix:search.suggest.input", "", array("NAME" => "q", "VALUE" => $arResult["REQUEST"]["~QUERY"], "INPUT_SIZE" => 40, "DROPDOWN_SIZE" => 10, "FILTER_MD5" => $arResult["FILTER_MD5"]), $component, array("HIDE_ICONS" => "Y"));
} else {
    ?>
	<input type="text" name="q" value="<?php 
    echo $arResult["REQUEST"]["QUERY"];
    ?>
" size="40" />
<?php 
}
?>
	&nbsp;<input type="submit" value="<?php 
echo GetMessage("SEARCH_GO");
?>
" />
Exemplo n.º 2
0
<?php

define("STOP_STATISTICS", true);
define("PUBLIC_AJAX_MODE", true);
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
$arResult = array();
if (CModule::IncludeModule("search")) {
    if (!empty($_REQUEST["search"]) && is_string($_REQUEST["search"])) {
        $search = $APPLICATION->UnJSEscape($_REQUEST["search"]);
        $arParams = array();
        $params = explode(",", $_REQUEST["params"]);
        foreach ($params as $param) {
            list($key, $val) = explode(":", $param);
            $arParams[$key] = $val;
        }
        $obSearchSuggest = new CSearchSuggest($arParams["md5"], $search);
        $db_res = $obSearchSuggest->GetList($arParams["pe"], $arParams["site"]);
        if ($db_res) {
            while ($res = $db_res->Fetch()) {
                $arResult[] = array("NAME" => $res["PHRASE"], "CNT" => intval($res["CNT"]));
            }
        }
    }
}
echo CUtil::PhpToJSObject($arResult);
require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/epilog_after.php";
die;