Views: 10490
Last Modified: 30.05.2014

In order to display the metadata values in the page code the function of ShowMeta() located in the prologue of the site design template must be used:

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

Let us assume that the following values are set for keywords and description properties of a page:

The function of SetPageProperty() will apply the values of these properties to a page:

<?
$APPLICATION->SetPageProperty("keywords", "sofas, chairs, office furniture, kitchen furniture, nursery furniture");
$APPLICATION->SetPageProperty("description", "We use only the high quality equipment to manufacture our furniture to achieve the superior quality.");
?>
Note: Section properties can be set up using the function of SetDirProperty() (e.g., in the code of the file .section.php):
< ?
…
$APPLICATION->SetDirProperty("keywords", "design, web, site");

$APPLICATION->SetDirProperty("description", "Site Manager System"); … ?>

In this case, the following HTML code will be introduced into the page code as a result of the function ShowMeta().

<meta name="keywords" content="design, web, site">
<meta name="description" content="Site Manager System">

If no property value is set for the page itself, the value of the property of a higher section (recursively to the site root) will be selected. If the property value is not determined, the value of the relevant meta tag will remain undetermined. Page properties may be set dynamically from the code of the components located on the page. For example, for pages showing catalog or news information, the page properties may be set in accordance with determined properties of infoblock elements:

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

In this case, the value of the property of an information block element with meta_description code will be used as a value for the description page property. Thus, the properties of keywords and description may be created for catalog elements and dynamically substituted to the page code.



Courses developed by Bitrix24