SMFHacks.com

Modifications/Themes => Modifications Talk => Topic started by: Toddie on May 06, 2023, 05:13:22 am

Title: Pretty Urls SEO Pro
Post by: Toddie on May 06, 2023, 05:13:22 am
I would like to save the sitemap (automatically) daily in the root directory as sitemap.xml.
Does anyone have an idea how I could do that?


Thank you!
Title: Re: Pretty Urls SEO Pro
Post by: SMFHacks on May 06, 2023, 03:30:11 pm
You would need to make changes.
Open themes/default/PrettyUrls.template.php
Find the function function template_pretty_xml_sitemap() and the code inside and replace with
Code: [Select]
function template_pretty_xml_sitemap()
{
global $context, $scripturl, $boarddir;

$data = '';

$data .= '<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
<loc>' . fix_possible_url($scripturl) . '</loc>
<lastmod>' . $context['sitemap']['main']['time'] . '</lastmod>
<changefreq>always</changefreq>
<priority>1.0</priority>
</url>';

foreach ($context['sitemap']['items'] as $item)
$data .= '
<url>
<loc>' . $item['url'] . '</loc>
<lastmod>' . $item['time'] . '</lastmod>
<changefreq>' . (empty($item['changefreq']) ? 'daily' : $item['changefreq']) . '</changefreq>
<priority>' . $item['priority'] . '</priority>
</url>';

$data .= '
</urlset>';

echo $data;

file_put_contents($boarddir .'/sitemap.xml');
}

Then you can setup a task or cronjob to call
sitenamecom/index.php?action=sitemaps&xml=1