Extend sitemap

Permalink
Within the current generated sitemap, I would like to add some more entries using the following line of code:
echo file_get_contents('http://voorraad.yoursite.nl/sitemap.xml?include=true');

I can't figure out where to add this in jobs/generate_sitemap.php
The output needs to be within <urlset></urlset>

Dutchwave
 
Mainio replied on at Permalink Reply
Mainio
Probably the easiest option would be to hook to an event named "on_sitemap_xml_ready".

Here's some documentation on how to hook into events (although not this particular event):
http://documentation.concrete5.org/developers/application-events/ho...

Within that event, you should get the full XML document as a Simlple XML element that you can modify prior to that XML being saved to a file.
hunterwebs replied on at Permalink Reply
This post saved me a lot of time, thank you. My solution was:

Inside
application/boostrap/app.php


Added this code:
Events::addListener('on_sitemap_xml_ready', function($event) {
    $sitemap = $event->getSubject()['xmlDoc'];
    // put your additional sitemap.xml URLs below
    $url = $sitemap->addChild('url');
    $url->addChild('loc', BASE_URL . '/woot');
    $url->addChild('lastmod', date('Y-m-d\TH:i:sP', time()));
    $url->addChild('changefreq', 'monthly');
    $url->addChild('priority', '0.5');
});
Myq replied on at Permalink Reply
Myq
Nice!

If you have time, this might make a great tutorial:https://documentation.concrete5.org/tutorials...