public static function sitemap() { $xml = new SimpleXMLElement('<urlset />'); $xml->addAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9'); $_GET = array(); URL::absolute(true); $links = array(); $Page = new Content_Page(); foreach ($Page->findShortList(array('IsEnabled = 1', 'Link <> '), 'Position asc') as $Page) { if (!in_array($Page->Link, $links)) { $links[] = $Page->Link; foreach ($Page->getController()->getSitemapNode() as $link) { $node = $xml->addChild('url'); $node->addChild('loc', $link); } } } $xml = $xml->asXML(); $xml = str_replace('<?xml version="1.0"?>', '<?xml version="1.0" encoding="UTF-8"?>', $xml); $dom = new DOMDocument('1.0'); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $dom->loadXML($xml); $xml = $dom->saveXML(); file_put_contents(FILES_DIR . '/sitemap.xml', $xml); }