Bitrix Site Manager

CAdvBanner::SetDesiredKeywords

CAdvBanner::SetDesiredKeywords(
 mixed keywords,
 varchar(255) TYPE_SID=""
);

The method assigns a set of desired keywords to a given page. If one of the banner or contract keywords are found within a page, the probability of show of the banner is higher. In case no banner satisfying the keyword set can be found, a banner for the show is selected from those without any keywords.

Parameters

ParameterDescription
keywords Keywords. See Remarks for description of information types that can be passed in this parameter.
TYPE_SID Type identifier. Describes the advertisement type to which the keywords are to be assigned. Leave this parameter empty to assign keywords to all types.

Example

The following is an example of using the method in the real page.

<?
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
if (CModule::IncludeModule("advertising"))
{
     // desirable exact-match keywords 
     $arrKeywords = array();
     $arrKeywords[] = array("EXACT_MATCH" => "Y", "KEYWORD" => "GeForce");
     $arrKeywords[] = array("EXACT_MATCH" => "Y", "KEYWORD" => "video");
     CAdvBanner::SetDesiredKeywords($arrKeywords, "LEFT");

     // desirable fuzzy match keywords
     CAdvBanner::SetDesiredKeywords(array("Ford", "BMW", "Lada"), "RIGHT");
}

$APPLICATION->SetTitle("Title");
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_after.php");

// page body
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog.php");
?>

Global use in prolog_after.php:

<?
if (CModule::IncludeModule("advertising"))
{
    CAdvBanner::SetDesiredKeywords($APPLICATION->GetPageProperty("keywords"));
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
...

Remarks

Structures that can be passed in the keywords parameter include the following.

  1. Array with arrays with keys:
    • EXACT_MATCH - denotes the match type: exact match (Y) or occurrence (N).
    • KEYWORDS - the keyword.
    Sample

    Array
    (
        [0] => Array
        (
            [EXACT_MATCH] => Y
            [KEYWORD] => GeForce
        )
    
        [1] => Array
        (
            [EXACT_MATCH] => Y
            [KEYWORD] => Radeon
        )
    )
  2. Array of keywords.
    Sample

    Array
    (
        [0] => GeForce
        [1] => Radeon
        [2] => Sony
    )
    In this case, the fuzzy match algorithm is applied for searching for matching keywords.
  3. Comma-separated list of keywords.
    Sample

    "GeForce, Radeon, Sony"
    In this case, the fuzzy match algorithm is also applied for searching for matching keywords.