Skip to content

Instantly share code, notes, and snippets.

@DerZyklop
Created April 23, 2014 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DerZyklop/11222482 to your computer and use it in GitHub Desktop.
Save DerZyklop/11222482 to your computer and use it in GitHub Desktop.
A xmlsitemap for Kirby CMS without listing the children of "kontakt"
<?php
$ignore = array('sitemap', 'error');
foreach ($pages->find('kontakt')->children() as $value) {
array_push($ignore, $value->uri());
}
// send the right header
header('Content-type: text/xml; charset="utf-8"');
// echo the doctype
echo '<?xml version="1.0" encoding="utf-8"?>';
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php foreach($pages->index() as $p): ?>
<?php if(in_array($p->uri(), $ignore)) continue ?>
<url>
<loc><?php echo html($p->url()) ?></loc>
<lastmod><?php echo $p->modified('c') ?></lastmod>
<priority><?php echo ($p->isHomePage()) ? 1 : number_format(0.5/$p->depth(), 1) ?></priority>
</url>
<?php endforeach ?>
</urlset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment