Sitemap Users — XML Sitemap for User Profiles

A plugin for Cotonti. Generates an XML sitemap exclusively for user profiles. Helps search engines find and index public user pages.


Sitemap Users — XML Sitemap for User Profiles

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

Installation

  1. Download the ZIP archive of the plugin from the GitHub repository.
  2. Extract the archive into the plugins/ folder of your site. You should get the structure described above.
  3. Go to the Cotonti admin panel → Extensions.
  4. Find the «Users Sitemap» plugin in the list and click «Install».

Important: during installation the plugin automatically:

  • Adds links to the user sitemap in robots.txt.
  • Adds rewrite rules to .htaccess for pretty URLs (only if URLEditor is active and these rules do not already exist).

After installation, the plugin starts working immediately. Don't forget to check the access rights to the user list (see Requirements).

Plugin Settings in the Admin Panel

All settings are located in Extensions → Users Sitemap → Configuration.

ParameterTypeDefaultDescription
cache_ttlstring3600Cache lifetime in seconds.
perpagestring50000Maximum number of URLs in one sitemap file.
freqselectdefaultDefault change frequency.
prioselect0.5Default priority.
usersradio1 (on)Include user profiles in the sitemap.
users_freqselectdailyChange frequency of profile pages.
users_prioselect0.5Priority of profile pages.
use_pretty_urlsradio1 (on)Use pretty URLs for the sitemap.

It is recommended to keep the default values unless you have specific requirements.

Setting Up Pretty URLs (SEF)

To make your sitemap available at:

  • https://yoursite/sitemap-users.xml – main sitemap
  • https://yoursite/sitemap-users-index.xml – sitemap index (for a large number of URLs)

the URLEditor plugin must be active with any preset other than none.

During installation, the plugin itself adds the following rules to .htaccess (if they are not already there):

RewriteRule ^sitemap-users\.xml$ index.php?r=sitemap_users [L]
RewriteRule ^sitemap-users-index\.xml$ index.php?r=sitemap_users&a=index [L]

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):

Sitemap: https://yoursite/index.php?r=sitemap_users
Sitemap: https://yoursite/index.php?r=sitemap_users&a=index
Sitemap: https://yoursite/sitemap-users.xml
Sitemap: https://yoursite/sitemap-users-index.xml

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):

  1. Output protection: clears buffers, sets the Content-Type: application/xml; charset=utf-8 header.
  2. Getting parameters: $d (part number) and $a (action: 'index' for the sitemap index).
  3. Reading plugin settings.
  4. Determining cache paths (folder datas/cache/sitemap_users/).
  5. Generating the sitemap index file (for ?a=index): checks the cache, recalculates parts, builds <sitemapindex>.
  6. 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.
  7. 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.

Usage Example

  1. Install the plugin (see Installation).
  2. In the Cotonti admin panel, enable the right for guests to read the user list (Rights → users → a → Guests: read).
  3. Check that the Sitemap: lines have appeared in robots.txt.
  4. Open https://yoursite/sitemap-users.xml — you will see XML with a list of user profiles.
  5. 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.



Rating based on reviews:
Stars received: 0
Total reviews: 0
Average rating: 0
8 minutes read

Reviews to products

No reviews yet


Add to Cart

Product has no downloadable file

 

Category Extentions
SEO and optimization

Page Discussion in Telegram

Content author

webitproff

Offline

webitproff

Last logged: 2026-08-05 11:32

  • Чем могу помочь?

    Оказываю весь спектр услуг по CMF Cotonti. Разработка открытых и закрытых корпоративных интернет порталов, небольших социальных сетей, торговые площадки, маркетплейсы, биржи фриланса, каталоги товаров оптовых поставщиков, интернет-магазин под заказ, чтобы делать совместные покупки и групповые совместные продажи от имени нескольких продавцов.

  • Разработки на GitHub бесплатно
  • Market PRO Showcase

    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.