Documentation

AddHeadString

CMain::AddHeadString(
 str, 
 bool Unique=false, 
 additional=false, 
 location = AssetLocation::AFTER_JS_KERNEL
)

The method adds a string into the <head>…</head> section of a site. Non-static method.

Equivalent to the method \Bitrix\Main\Page\Asset::addString in core D7.

Variables

Parameter Description Available from version
str string to be added into the … section
Unique if set to true and such string is already added to the <head> section, it will be duplicated. If set to false, the string will be added to the <head> section without duplication check.

Duplication check (with specified parameter $bUnique = true) is performed via calculation of md5-cache from the string in /bitrix/modules/main/classes/general/main.php.

additional Optional parameter. By default value is false.
location Where to print the string. Possible values:
BEFORE_CSS,
AFTER_CSS,
AFTER_JS_KERNEL,
AFTER_JS,
BODY_END.
14.0.18

Examples

Add a style.css style file from the current directory.

<?$APPLICATION->AddHeadString('<link href="'.$APPLICATION->GetCurDir().'"style.css";  type="text/css" rel="stylesheet" />',true)?>


© «Bitrix24», 2001-2024
Up