diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-21 10:19:09 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-21 10:19:09 +0100 |
| commit | 49543c24925925e19dfb7ed066043918633e7f46 (patch) | |
| tree | f6fbd4c9664ce8d823e47b55911193bbc06c95b4 /sitemap.php | |
| parent | 006594468320fa99289a5374bb47236d00368da7 (diff) | |
| download | articles-49543c24925925e19dfb7ed066043918633e7f46.tar.gz articles-49543c24925925e19dfb7ed066043918633e7f46.tar.bz2 articles-49543c24925925e19dfb7ed066043918633e7f46.zip | |
Tidy automatic generation of sitemap
Diffstat (limited to 'sitemap.php')
| -rw-r--r-- | sitemap.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/sitemap.php b/sitemap.php new file mode 100644 index 0000000..4137ce6 --- /dev/null +++ b/sitemap.php @@ -0,0 +1,35 @@ +<?php +/** + * @package articles + * @subpackage functions + */ + +require_once '../kernel/includes/setup_inc.php'; +use Bitweaver\Articles\BitArticle; + +$gBitSystem->verifyPackage( 'articles' ); + +$gSiteMapHash = []; +$article = new BitArticle(); +$listHash = [ 'max_records' => -1, 'sort_mode' => 'last_modified_desc' ]; + +if( $articles = $article->getList( $listHash ) ) { + foreach( $articles as $row ) { + if( empty( $row['display_url'] ) ) continue; + $age = time() - $row['last_modified']; + if( $age < 86400 ) $freq = 'daily'; + elseif( $age < 86400 * 7 ) $freq = 'weekly'; + else $freq = 'monthly'; + $gSiteMapHash[$row['content_id']] = [ + 'loc' => BIT_BASE_URI . $row['display_url'], + 'lastmod' => date( 'Y-m-d', $row['last_modified'] ), + 'changefreq' => $freq, + 'priority' => 0.7, + ]; + } +} + +$gBitSmarty->assign( 'gSiteMapHash', $gSiteMapHash ); +$gBitThemes->setFormatHeader( 'xml' ); +header( 'Content-Type: application/xml; charset=utf-8' ); +$gBitSystem->display( 'bitpackage:kernel/sitemap.tpl' ); |
