diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-21 10:18:33 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-21 10:18:33 +0100 |
| commit | 693dd159a5831494f7b118130b5ff75a56f049e9 (patch) | |
| tree | cd40b1c82345687b908fe152874736fd2f4b8a84 /sitemap.php | |
| parent | 002747de5610de625a0e968005d22865d578bafa (diff) | |
| download | blogs-693dd159a5831494f7b118130b5ff75a56f049e9.tar.gz blogs-693dd159a5831494f7b118130b5ff75a56f049e9.tar.bz2 blogs-693dd159a5831494f7b118130b5ff75a56f049e9.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..53a619e --- /dev/null +++ b/sitemap.php @@ -0,0 +1,35 @@ +<?php +/** + * @package blogs + * @subpackage functions + */ + +require_once '../kernel/includes/setup_inc.php'; +use Bitweaver\Blogs\BitBlogPost; + +$gBitSystem->verifyPackage( 'blogs' ); + +$gSiteMapHash = []; +$post = new BitBlogPost(); +$listHash = [ 'max_records' => -1, 'sort_mode' => 'last_modified_desc' ]; + +if( $posts = $post->getList( $listHash ) ) { + foreach( $posts 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.8, + ]; + } +} + +$gBitSmarty->assign( 'gSiteMapHash', $gSiteMapHash ); +$gBitThemes->setFormatHeader( 'xml' ); +header( 'Content-Type: application/xml; charset=utf-8' ); +$gBitSystem->display( 'bitpackage:kernel/sitemap.tpl' ); |
