Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
The solution turned out to be not so simple. It is possible
to add include areas to the search index , but this requires intervention in the indexing process.
for this, the following code is added to /local/php_interface/init.php:
<?
AddEventHandler("search", "BeforeIndex", Array("MyClass", "BeforeIndexHandler"));
class MyClass
{
private $file_abs_path = "";
function BeforeIndexHandler($arFields)
{
$io = CBXVirtualIo::GetInstance();
if($arFields["MODULE_ID"] == "main")
{
list($site_id, $file_rel_path) = explode("|", $arFields["ITEM_ID"]);
$file_doc_root = CSite::GetSiteDocRoot($site_id);
$file_abs_path = preg_replace("#[\\\\\\/]+#", "/", $file_doc_root."/".$file_rel_path);
$f = $io->GetFile($file_abs_path);
$sFile = $f->GetContents();
if(isset($sFile) && $sFile != "")
{
$replacer = new MyClass;
$replacer->file_abs_path = $file_abs_path;
$sFile = preg_replace_callback("/<\\?\\\$APPLICATION->IncludeComponent\\(\\s*\"bitrix:main.include\",(.*?)\\?>/mis", array($replacer, "replace"), $sFile);
$arFields["BODY"] = CSearch::KillTags($sFile);
}
}
return $arFields;
}
function replace($matchParams)
{
$io = CBXVirtualIo::GetInstance();
if (preg_match("/\"AREA_FILE_SUFFIX\"\\s*=>\\s*\"(.*?)\",/", $matchParams[1], $match))
{
$slash_pos = strrpos($this->file_abs_path, "/");
$sFilePath = substr($this->file_abs_path, 0, $slash_pos+1);
$sFileName = substr($this->file_abs_path, $slash_pos+1);
$sFileName = substr($sFileName, 0, strlen($sFileName)-4)."_".$match[1].".php";
$f = $io->GetFile($sFilePath.$sFileName);
return $f->GetContents();
}
return "";
}
}
I'm afraid not. The included area can be connected anywhere: in any static sections, in infoblock components (and even for some if conditions), even in the infoblock elements themselves (with some skill). Therefore, Bitrix will not be able to display relevant pages in the search results for this text.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question