correct sitemapindex output
darcs-hash:20080811200058-84dde-8a45ed98a331d3b53ba8e50494e44f52928c7a04.gz
This commit is contained in:
parent
0bba990e2f
commit
e90004964f
35
sitemap.php
35
sitemap.php
@ -29,7 +29,7 @@ function index_map() {
|
|||||||
# Just the file name please.
|
# Just the file name please.
|
||||||
$file_name = preg_replace("|$output_dir|", '', $file_name);
|
$file_name = preg_replace("|$output_dir|", '', $file_name);
|
||||||
|
|
||||||
$index_urls .= url(
|
$index_urls .= sitemap(
|
||||||
array(
|
array(
|
||||||
'url' => $output_url . $file_name,
|
'url' => $output_url . $file_name,
|
||||||
'changefreq' => 'daily'
|
'changefreq' => 'daily'
|
||||||
@ -37,8 +37,7 @@ function index_map() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
write_file($output_paths['index_file'], urlset($index_urls));
|
write_file($output_paths['index_file'], sitemapindex($index_urls));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generate sitemap of standard site elements.
|
# Generate sitemap of standard site elements.
|
||||||
@ -274,6 +273,26 @@ function url($url_args) {
|
|||||||
return $url_out;
|
return $url_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sitemap($sitemap_args) {
|
||||||
|
$url = preg_replace('/&/', '&', $sitemap_args['url']); # escape ampersands for XML
|
||||||
|
$lastmod = $sitemap_args['lastmod'];
|
||||||
|
|
||||||
|
if (is_null($url)) {
|
||||||
|
error("url() arguments require 'url' value.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$sitemap_out = "\t<sitemap>\n";
|
||||||
|
$sitemap_out .= "\t\t<loc>$url</loc>\n";
|
||||||
|
|
||||||
|
if ($lastmod) {
|
||||||
|
$sitemap_out .= "\t\t<lastmod>$lastmod</lastmod>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$sitemap_out .= "\t</sitemap>\n";
|
||||||
|
|
||||||
|
return $sitemap_out;
|
||||||
|
}
|
||||||
|
|
||||||
# Generate a <urlset></urlset> element.
|
# Generate a <urlset></urlset> element.
|
||||||
function urlset($urlset_text) {
|
function urlset($urlset_text) {
|
||||||
$urlset = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
|
$urlset = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
|
||||||
@ -284,6 +303,16 @@ function urlset($urlset_text) {
|
|||||||
return $urlset;
|
return $urlset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Generate a <urlset></urlset> element.
|
||||||
|
function sitemapindex($sitemapindex_text) {
|
||||||
|
$sitemapindex = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
|
||||||
|
'<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n" .
|
||||||
|
$sitemapindex_text .
|
||||||
|
'</sitemapindex>';
|
||||||
|
|
||||||
|
return $sitemapindex;
|
||||||
|
}
|
||||||
|
|
||||||
# Generate a sitemap from an array containing <url></url> elements and write it to a file.
|
# Generate a sitemap from an array containing <url></url> elements and write it to a file.
|
||||||
function array_to_map($url_list, $filename_prefix) {
|
function array_to_map($url_list, $filename_prefix) {
|
||||||
global $output_paths;
|
global $output_paths;
|
||||||
|
Loading…
Reference in New Issue
Block a user