mirror of
https://github.com/wilr/silverstripe-googlesitemaps.git
synced 2024-10-22 11:05:48 +02:00
ENHANCEMENT: added ability to define a custom prority to dataobjects.
This commit is contained in:
parent
805c7e2ee4
commit
65c59fc020
@ -10,7 +10,7 @@
|
||||
* sitemap whenever the GoogleBot visits your website.
|
||||
*
|
||||
* Enabling notification of Google after every publish (in your _config.php):
|
||||
|
||||
*
|
||||
* <example>
|
||||
* GoogleSitemap::enable_google_notificaton();
|
||||
* </example>
|
||||
@ -55,37 +55,40 @@ class GoogleSitemap extends Controller {
|
||||
*/
|
||||
public static $google_sitemap_dataobjects_changefreq = array();
|
||||
|
||||
/**
|
||||
* List of DataObjects priority
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $google_sitemap_dataobjects_priority = array();
|
||||
/**
|
||||
* List of DataObjects priority
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $google_sitemap_dataobjects_priority = array();
|
||||
|
||||
/**
|
||||
/**
|
||||
* Decorates the given DataObject with {@link GoogleSitemapDecorator}
|
||||
* and pushes the class name to the registered DataObjects.
|
||||
* Note that all registered DataObjects need the method AbsoluteLink().
|
||||
*
|
||||
* @param string $className name of DataObject to register
|
||||
* @param string $changeFreq how often is this DataObject updated?
|
||||
* Possible values:
|
||||
* always, hourly, daily, weekly, monthly, yearly, never
|
||||
* @param string $priority How important is this DataObject in comparison to other urls?
|
||||
* Possible values: 0.1, 0.2 ... , 0.9, 1.0
|
||||
* Possible values:
|
||||
* always, hourly, daily, weekly, monthly, yearly, never
|
||||
* @param string $priority How important is this DataObject in comparison to other urls?
|
||||
* Possible values: 0.1, 0.2 ... , 0.9, 1.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function register_dataobject($className, $changeFreq = 'monthly', $priority = '0.6') {
|
||||
if (!self::is_registered($className)) {
|
||||
Object::add_extension($className, 'GoogleSitemapDecorator');
|
||||
|
||||
self::$google_sitemap_dataobjects[] = $className;
|
||||
if ($changeFreq === null) {
|
||||
self::$google_sitemap_dataobjects_changefreq[] = "monthly";
|
||||
} else {
|
||||
self::$google_sitemap_dataobjects_changefreq[] = $changeFreq;
|
||||
}
|
||||
self::$google_sitemap_dataobjects_priority[] = $priority;
|
||||
|
||||
if (!$changeFreq) {
|
||||
self::$google_sitemap_dataobjects_changefreq[] = "monthly";
|
||||
} else {
|
||||
self::$google_sitemap_dataobjects_changefreq[] = $changeFreq;
|
||||
}
|
||||
|
||||
self::$google_sitemap_dataobjects_priority[] = $priority;
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,7 +135,7 @@ class GoogleSitemap extends Controller {
|
||||
|
||||
/**
|
||||
* Returns all the links to {@link SiteTree} pages and
|
||||
* {@link DataObject} urls on the page
|
||||
* {@link DataObject} urls on the page.
|
||||
*
|
||||
* @return DataObjectSet
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user