mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX #2390: Not indexed pages are removed from sitemap.xml
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@62910 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
a47f5834a2
commit
2a1d4376e2
@ -998,14 +998,16 @@ class SiteTree extends DataObject {
|
||||
* the site tree, so it must be calculated dynamically.
|
||||
*/
|
||||
function getPriority() {
|
||||
if($this->getField('Priority') === null) {
|
||||
if(!$this->getField('Priority')) {
|
||||
$parentStack = $this->parentStack();
|
||||
$numParents = is_array($parentStack) ? count($parentStack) - 1: 0;
|
||||
return max(0.1, 1.0 - ($numParents / 10));
|
||||
}
|
||||
|
||||
} else if($this->getField('Priority') == -1) {
|
||||
return 0;
|
||||
} else {
|
||||
return $this->getField('Priority');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a FieldSet with which to create the CMS editing form.
|
||||
@ -1085,7 +1087,8 @@ class SiteTree extends DataObject {
|
||||
|
||||
|
||||
$pagePriorities = array(
|
||||
'0.0' => _t('SiteTree.PRIORITYNOTINDEXED', "Not indexed"),
|
||||
'' => _t('SiteTree.PRIORITYAUTOSET','Auto-set based on page depth'),
|
||||
'-1' => _t('SiteTree.PRIORITYNOTINDEXED', "Not indexed"), // We set this to -ve one because a blank value implies auto-generation of Priority
|
||||
'1.0' => '1 - ' . _t('SiteTree.PRIORITYMOSTIMPORTANT', "Most important"),
|
||||
'0.9' => '2',
|
||||
'0.8' => '3',
|
||||
|
@ -34,12 +34,7 @@ class GoogleSitemap extends Controller {
|
||||
if(parse_url($page->AbsoluteLink(), PHP_URL_HOST) == $_SERVER['HTTP_HOST'] && !($page instanceof ErrorPage)) {
|
||||
|
||||
// If the page has been set to 0 priority, we set a flag so it won't be included
|
||||
if(isset($page->Priority) && $page->Priority <= 0) {
|
||||
$page->Include = false;
|
||||
} else {
|
||||
$page->Include = true;
|
||||
}
|
||||
|
||||
if(!isset($page->Priority) || $page->Priority > 0) {
|
||||
// The one field that isn't easy to deal with in the template is
|
||||
// Change frequency, so we set that here.
|
||||
$properties = $page->toMap();
|
||||
@ -70,6 +65,7 @@ class GoogleSitemap extends Controller {
|
||||
$newPages->push($page);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $newPages;
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
<% control Items %>
|
||||
<% if Include %>
|
||||
<url>
|
||||
<loc>$AbsoluteLink</loc>
|
||||
<lastmod>$LastEdited.Format(c)</lastmod>
|
||||
<% if ChangeFreq %><changefreq>$ChangeFreq</changefreq><% end_if %>
|
||||
<% if Priority %><priority>$Priority</priority><% end_if %>
|
||||
</url>
|
||||
<% end_if %>
|
||||
<% end_control %>
|
||||
</urlset>
|
Loading…
Reference in New Issue
Block a user