The module generates a sitemap. The site map includes all the active page of the site is not marked with the "Do not show on a sitemap", as well as attached to the pages of the site active category of modules that are not marked option "Do not show on a sitemap".
The module has two parts: a page of the site to which the plug-in "Site map" and the file for the search engines sitemap.xml.
On the page, the user output displays all pages of the site, as well as the category of connected modules, according to the site structure. You can also bring cell modules (news, products, articles and so forth.). The code that displays the elements in the file is commented out modules/map/map.model.php.
DIAFAN.CMS also generates a site map for the search engines: http://site.com/sitemap.xml.
File sitemap.xml is generated on the fly, the physical file is not created. It contains all the links created by the system, in addition to references to items marked with the "Do not show on a sitemap." To generate the reference module, you must have the file modules/module_name/module_name.sitemap.php. File format:
Example:
<?php
if ( ! defined('DIAFAN'))
{
$path = __FILE__; $i = 0;
while(! file_exists($path.'/includes/404.php'))
{
if($i == 10) exit; $i++;
$path = dirname($path);
}
include $path.'/includes/404.php';
}
class Модуль_sitemap extends Diafan
{
/**
* Returns the settings for generating the card module
*
* @param integer $site_id ID site page
* @return array
*/
public function config($site_id)
{
$result = array(
// data type – element, category
'type' => array('element', 'category'),
// conditions for sampling
'where' =>
array(
// for type "element"
'element' => "AND map_no_show='0'",
// for type "category"
'category' => "AND map_no_show='0'",
)
);
return $result;
}
}
The module links indexes created modules. The index is updated in three cases:
For a complete re-indexing a site re-install the module "Sitemap" in the "Modules and DB".
According to the standard file sitemap.xml can be split into multiple files. The number of links in the same file set the properties
private $max_url = 5000;
in the file modules/map/map.sitemap.php.
Подключаемая часть – файл modules/map/map.inc.php. В нем описан класс
Map_inc. В модуле к объекту класса можно обратиться через переменную $this->diafan->_map
. Экземпляр класса создается при первом вызове
переменной.
void index_all () – Индексирует весь сайт.
Example:
// indexes all links on the site for the file sitemap.xml
$this->diafan->_map->index_all();
void index_module (string $module_name) – Индексирует модуль.
Example:
// index the module "Online shop"for the sitemap.xml
$this->diafan->_map->index_module('shop');
void index_site_module (array $row, [boolean $out = true]) – Индексирует страницы модуля, прикрепленного к странице сайта.
Example:
$row = array(
"id" => 13,
"module_name" => "shop",
"timeedit" => 1398851484,
"changefreq" => "always",
"priority" => 0,
);
// index page with attached module for the file sitemap.xml
$this->diafan->_map->index_site_module($row);
void index_elements (array $rows) – Индексирует группу элементов.
Example:
$rows = array(
array(
"id" => 1,
"element_type" => "element",
"module_name" => "shop",
"site_id" => 13,
"timeedit" => 1398851484,
"changefreq" => "always",
"priority" => 0,
),
array(
"id" => 2,
"element_type" => "element",
"module_name" => "shop",
"site_id" => 13,
"timeedit" => 1398851485,
"changefreq" => "always",
"priority" => 0,
),
);
// index some products for the file sitemap.xml
$this->diafan->_map->index_elements($rows);
void index_element (array $row) – Индексирует один элемент.
Example:
$row = array(
"id" => 1,
"element_type" => "element",
"module_name" => "shop",
"site_id" => 13,
"timeedit" => 1398851484,
"changefreq" => "always",
"priority" => 0,
);
// index product for the file sitemap.xml
$this->diafan->_map->index_element($row);
void delete (integer|array $element_ids, string $module_name, [string $element_type = 'element']) – Удаляет один или несколько элементов из индекса.
Example:
// delete product brand from the file sitemap.xml
$this->diafan->_map->delete(2, "shop", "brand");
void delete_module (string $module_name) – Удаляет весь индекс модуля.
Example:
// delete all links of module "News" from the file sitemap.xml
$this->diafan->_map->delete_module("news");
void delete_sites (array $site_ids) – Удаляет индекс модулей, прикрепленных к страницам сайта.
Example:
// delete all links of all modules attached to site pages ID=3,4,6 from the file sitemap.xml
$this->diafan->_map->delete_sites(array(3, 4, 6));
{map_index} – Индекс для файла sitemap.xml
modules/map/admin/map.admin.inc.php – Connecting the module to the administrative part of other modules;
modules/map/js/map.tiny.js – Подгружает карту сайта в визуальном редакторе, JS-сценарий;
modules/map/map.php – Controller;
modules/map/map.inc.php – Подключение модуля;
modules/map/map.install.php – Module installation;
modules/map/map.model.php – Model;
modules/map/map.sitemap.php – Карта сайта в XML формате;
modules/map/map.tiny.php – Плагин карты сайта для визуального редактора;
modules/map/views/map.view.list.php – Шаблон списка страниц в карте сайте.