From 49543c24925925e19dfb7ed066043918633e7f46 Mon Sep 17 00:00:00 2001 From: Lester Caine Date: Thu, 21 May 2026 10:19:09 +0100 Subject: Tidy automatic generation of sitemap --- sitemap.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 sitemap.php diff --git a/sitemap.php b/sitemap.php new file mode 100644 index 0000000..4137ce6 --- /dev/null +++ b/sitemap.php @@ -0,0 +1,35 @@ +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' ); -- cgit v1.3