Documentation

Create

mixed
  CSiteMap::Create(
	string site_id,
	array max_execution_time,
	array NS,
array arOptions = array()
);

Creating map site in the Google Sitemap format.

Creation always occurs in the step-by-step mode. Non-static method.

Method parameters

Parameter DescriptionAvailable from version
site_id Site ID for which the map will be created.
max_execution_time Element of this array with index 0 specifies maximum time of one step in seconds. The element with index 1 - specifies maximum number the search index records (it is recommended to specify not more than 5000).
NS Step start. The result, returned by the previous call of this method is passed.
arOptionsOptional parameter. If it contains the FORUM_TOPICS_ONLY key with "Y" value, then not all messages will go to Sitemap with installed forum module, but only the messages that start a new topic at the forum. During this, the date of modification will be equal to the date when the last message is added to this topic.

Returned value

  • false - if an error occurs.
  • true - when a map is created successfully.
  • array - one more method call is required.

Examples of use

Building site map from the scenario, called in the cron.

<?
//connecting search module
if(CModule::IncludeModule('search'))
{
//This array will pass "progress" data. The same array will serve as indicator of execution completion.
$NS=Array();
//Set maximum duration of one iteration that equals to "infinity".
$sm_max_execution_time = 0;
//It is the maximum number of links, processed per one step.
//Specifying too larger value will lead to the loss of productivity.
$sm_record_limit = 5000;
do {
$cSiteMap = new CSiteMap;
//Iterate the creation,
$NS = $cSiteMap->Create("ru", array($sm_max_execution_time, $sm_record_limit), $NS);
//until the site map is created.
} while(is_array($NS));
}
?>


© «Bitrix24», 2001-2024