A plugin for Cotonti. Generates an XML sitemap exclusively for user profiles. Helps search engines find and index public user pages.
History and Why It Is Needed
This plugin is part of a project to split the standard SiteMap plugin (included with Cotonti) into several independent plugins.
The original SiteMap generated one large sitemap for the entire site: pages, forums, users, products. Any changes or errors in one section required fixing the entire plugin, which often broke the whole map.
To avoid this problem, it was decided to break the single plugin into specialised ones, each responsible only for its own content type:
sitemap_users – XML sitemap for user profiles (this plugin)
sitemap_pages – XML sitemap for pages (with multilingual support)
sitemap_forums – XML sitemap for forums
sitemap_market – XML sitemap for products (Market module)
Each plugin is fully autonomous, configured separately, and does not affect the operation of others. This approach simplifies maintenance and allows flexible management of the site’s sitemaps.
sitemap_users was created based on the original SiteMap code but was completely reworked specifically for the users module and adapted for PHP 8.x.
Features
Generates an XML sitemap containing links to the profiles of all publicly viewable users (respecting access rights).
Automatically splits the sitemap into multiple files (sitemap index) if the total number of links exceeds the specified limit (perpage).
Upon installation, automatically adds links to the sitemap in robots.txt.
Upon installation, automatically adds rewrite rules to .htaccess for pretty URLs (if the URLEditor plugin is active).
Caches generated sitemaps into files for fast delivery.
Flexible settings: update frequency, priority for user profiles.
Full compatibility with PHP 8.x.
Requirements
Cotonti Siena (the latest version is recommended)
The users module — must be installed and active
The urleditor plugin — if you plan to use pretty URLs (sitemap-users.xml)
Write permissions for the datas/cache/ folder (for caching sitemaps)
Access to the user list: to generate the sitemap the plugin checks the cot_auth('users', 'a', 'R') permission. Ensure that guests or search bots have this right (by default in Cotonti guests cannot view the user list). It is recommended to enable this right in the admin panel: Rights → users → a (user list) → Guests: read.
PHP 8.0 or higher
Plugin Structure
sitemap_users/
├── sitemap_users.setup.php # Plugin header, metadata and settings
├── sitemap_users.ajax.php # Main request handler (AJAX)
├── inc/
│ └── sitemap_users.functions.php # Functions: XML compression, date handling, saving sitemaps
├── lang/
│ ├── sitemap_users.ru.lang.php # Russian labels for settings
│ └── sitemap_users.en.lang.php # English labels for settings
├── tpl/
│ ├── sitemap_users.tpl # Template for a standard urlset
│ └── sitemap_users.index.tpl # Template for a sitemap index file (sitemapindex)
└── setup/
└── sitemap_users.install.php # Automatically adds links to robots.txt
# and rules to .htaccess during installation
You do not need to write these rules manually — the installation does everything automatically. If you have disabled automatic modification of .htaccess, simply copy the lines above into your .htaccess after the RewriteEngine On line.
Usage
Viewing the Sitemap
Main sitemap: open in your browser https://yoursite/sitemap-users.xml or https://yoursite/index.php?r=sitemap_users
Sitemap index (if the sitemap is split into parts):https://yoursite/sitemap-users-index.xml or https://yoursite/index.php?r=sitemap_users&a=index
Adding to robots.txt
During installation, the plugin automatically adds the following lines to the root robots.txt (depending on the SEF settings):
If you need to modify or remove these links, edit robots.txt manually.
Validating the Sitemap
You can use the XML Sitemap Validator or similar services to verify that the sitemap is generated correctly.
Caching and Clearing the Cache
Generated sitemaps are stored in the datas/cache/sitemap_users/ folder and are only regenerated after the cache_ttl time has expired (1 hour by default). This significantly reduces server load during frequent requests from search engines.
If you need to force an update before the cache expires, simply delete the files in the cache folder (datas/cache/sitemap_users/). They will be recreated on the next request.
Detailed Description of Each File
Below is a very detailed description of every file included in the plugin. The description goes from general purpose to specific details so that a beginner can understand.
1. sitemap_users.setup.php
Purpose: the "passport" of the plugin. It stores information that Cotonti uses to register the plugin in the system and to build the settings page in the admin panel.
What it contains:
The [BEGIN_COT_EXT] / [END_COT_EXT] section – plugin metadata: its code, name, category, description, version, author, required modules, access rights.
The [BEGIN_COT_EXT_CONFIG] / [END_COT_EXT_CONFIG] section – a list of settings available to the administrator. Format: parameter_name=order:type:default_value:hint. Examples: cache_ttl, freq, users.
Important: manually editing this file is not recommended — all settings can be changed through the admin panel and they are saved in the database.
2. sitemap_users.ajax.php
Purpose: the heart of the plugin. It is called via an AJAX hook when someone opens the sitemap link. It generates and serves the ready XML sitemap.
How it works (step by step):
Output protection: clears buffers, sets the Content-Type: application/xml; charset=utf-8 header.
Getting parameters:$d (part number) and $a (action: 'index' for the sitemap index).
Generating the sitemap index file (for ?a=index): checks the cache, recalculates parts, builds <sitemapindex>.
Generating the main sitemap: if the cache is stale, rebuilds the data: checks access to the user list, selects users, builds URLs, passes them to the template, saves parts to the cache.
Serving the ready file: determines the required cache file, reads, cleans and outputs it with the correct XML declaration.
3. inc/sitemap_users.functions.php
Purpose: a library of helper functions.
sitemap_users_compress — removes unnecessary whitespace characters from XML.
sitemap_users_date — formats a Unix timestamp into W3C (ISO 8601).
sitemap_users_freq — returns the value for <changefreq> (if not default).
sitemap_users_prio — similarly for <priority>.
sitemap_users_parse — adds one entry to the template, saves the current part when the limit is reached.
sitemap_users_save — saves the XML into a cache file.
4. Language Files (lang/sitemap_users.ru.lang.php and en.lang.php)
Purpose: translation of strings shown in the admin panel when editing plugin settings. They contain the $L array and arrays for dropdown lists.
5. Templates (tpl/)
sitemap_users.tpl (standard sitemap)
Contains the <!-- BEGIN: MAIN --> block with the root element <urlset> and the <!-- BEGIN: SITEMAP_ROW --> block for a single URL. Conditional blocks {SITEMAP_ROW_DATE}, {SITEMAP_ROW_FREQ}, {SITEMAP_ROW_PRIO} allow optional tags to be omitted.
sitemap_users.index.tpl (sitemap index)
Similar, but the root element is <sitemapindex>, and inside the SITEMAP_ROW block there is <sitemap> with <loc> and optionally <lastmod>.
Important: never add the line <?xml version="1.0" encoding="UTF-8"?> to these templates — it is inserted programmatically.
6. setup/sitemap_users.install.php
Purpose: runs when the plugin is installed. It configures robots.txt (adds links to the sitemap) and .htaccess (adds rewrite rules for pretty URLs), if they are writable and the rules do not already exist.
In the Cotonti admin panel, enable the right for guests to read the user list (Rights → users → a → Guests: read).
Check that the Sitemap: lines have appeared in robots.txt.
Open https://yoursite/sitemap-users.xml — you will see XML with a list of user profiles.
To validate the sitemap with an online validator, add 'Sitemaps Generator' to the bot whitelist of the visitor_stats plugin if it is installed.
Troubleshooting
The sitemap does not open (404 or 500 error). Check that the users module is active and that the datas/cache/sitemap_users/ folder is writable.
The sitemap is empty, although there are users. Check the access rights: guests must be allowed to read the user list (Rights → users → a → Guests: read).
Pretty URLs (sitemap-users.xml) are not working. Make sure the urleditor plugin is active, its preset is not none, and the rules have been added to .htaccess.
The validator shows an «Incorrect http header content-type: text/html» error. Add 'Sitemaps Generator' to the bot whitelist of visitor_stats (file WhitelistBots.php).
The sitemap index is empty or contains incorrect links. Clear the cache and check the perpage and use_pretty_urls settings.
License
Distributed under the BSD license. Free use and modification as long as the copyright notice is preserved.
Оказываю весь спектр услуг по CMF Cotonti. Разработка открытых и закрытых корпоративных интернет порталов, небольших социальных сетей, торговые площадки, маркетплейсы, биржи фриланса, каталоги товаров оптовых поставщиков, интернет-магазин под заказ, чтобы делать совместные покупки и групповые совместные продажи от имени нескольких продавцов.
CMS, Script and Engine for an online storefront, infoproduct shop and digital goods store. Different prices in different currencies. Online cryptocurrency payments for goods and services.