SetRequiredKeywords
CAdvBanner::SetRequiredKeywords( mixed keywords, varchar(255) TYPE_SID="" );
The method assigns a set of required keywords to a given page. If all 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. Non-static method.
Parameters
Parameter | Description |
---|---|
keywords | Keywords. See Notes 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")) { // required exact match keywords $arrKeywords = array(); $arrKeywords[] = array("EXACT_MATCH" => "Y", "KEYWORD" => "GeForce"); $arrKeywords[] = array("EXACT_MATCH" => "Y", "KEYWORD" => "video"); CAdvBanner::SetRequiredKeywords($arrKeywords, "LEFT"); // required fuzzy match keywords CAdvBanner::SetRequiredKeywords(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::SetRequiredKeywords($APPLICATION->GetProperty("keywords")); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> ...
If a page contains keywords, the following two scenarios are possible.
- No banners matching the keyword list are found. In this case, banners with an empty list of keywords are displayed according to their priority.
- More than one matching banners are found. In this case, a banner is selected that has the highest priority with respect to the priority of its contract.
Please remember that a full list of banner keywords is comprised by both banner keywords and keywords of a contract to which the banner is attached.
Notes
Structures that can be passed in the keywords
parameter include
the following.
- 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 ) )
- Array of keywords.
Sample
Array ( [0] => GeForce [1] => Radion [2] => Sony )
In this case, the fuzzy match algorithm is applied for searching for matching keywords; search includes all of the required keywords. - Comma-separated list of keywords.
Sample
"GeForce, Radion, Sony"
In this case, the fuzzy match algorithm is also applied for searching for matching keywords.
© «Bitrix24», 2001-2024