Views: 4292
Last Modified: 10.10.2012

To assign the page metadata values use the SetPageProperty() function:

<?
$APPLICATION->SetPageProperty("keywords", "Mobile phones, accessories, Alcatel, Siemens, Motorolla");
$APPLICATION->SetPageProperty("description", "Mobile Store");
?>

The metadata values calls are implemented by the ShowMeta() function:

< head >
…
< ?$APPLICATION->ShowMeta("keywords")?>
< ?$APPLICATION->ShowMeta("description")?>
…
</head>

These function calls generate the following HTML code:

<meta name="keywords" content="Mobile phones, accessories, Alcatel, Siemens, Motorolla">
<meta name="description" content="Mobile Store">

If the metadata values are not assigned for the current page, then as the page metadata values will be used values assigned for the parent directory. If the parent directory metadata values are not assigned then the page metadata will be undefined.

Page properties can be set from the script dynamically. For example: properties of pages that are used to display the catalog contents or the news (i.e. information blocks), can be set with respect to values of an information block elements. Thus, you can create properties keywords and description for each element of an information block and apply them to a page dynamically.

 $APPLICATION->SetPageProperty("description",$arIBlockElement["PROPERTIES"][$META_DESCRIPTION]["VALUE"]);

In this example the page property description value is taken from the information block property meta_description.



Courses developed by Bitrix24