mirror of
https://github.com/wilr/silverstripe-googlesitemaps.git
synced 2024-10-22 11:05:48 +02:00
Compare commits
2 Commits
59acd419ef
...
3f75c06a77
Author | SHA1 | Date | |
---|---|---|---|
|
3f75c06a77 | ||
|
a13d3dd9de |
@ -4,7 +4,6 @@ Name: googlesitemaps
|
|||||||
Wilr\GoogleSitemaps\GoogleSitemap:
|
Wilr\GoogleSitemaps\GoogleSitemap:
|
||||||
enabled: true
|
enabled: true
|
||||||
objects_per_sitemap: 1000
|
objects_per_sitemap: 1000
|
||||||
google_notification_enabled: false
|
|
||||||
use_show_in_search: true
|
use_show_in_search: true
|
||||||
---
|
---
|
||||||
Only:
|
Only:
|
||||||
|
@ -38,14 +38,10 @@ After: googlesitemaps
|
|||||||
Wilr\GoogleSitemaps\GoogleSitemap:
|
Wilr\GoogleSitemaps\GoogleSitemap:
|
||||||
enabled: true
|
enabled: true
|
||||||
objects_per_sitemap: 1000
|
objects_per_sitemap: 1000
|
||||||
google_notification_enabled: false
|
|
||||||
use_show_in_search: true
|
use_show_in_search: true
|
||||||
```
|
```
|
||||||
|
|
||||||
You can now alter any of those properties to set your needs. A popular option
|
You can now alter any of those properties to set your needs.
|
||||||
is to turn on automatic pinging so that Google is notified of any updates to
|
|
||||||
your page. You can set this in the file we created in the last paragraph by
|
|
||||||
editing the `google_notification_enabled` option to true
|
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
---
|
---
|
||||||
@ -55,7 +51,6 @@ After: googlesitemaps
|
|||||||
Wilr\GoogleSitemaps\GoogleSitemap:
|
Wilr\GoogleSitemaps\GoogleSitemap:
|
||||||
enabled: true
|
enabled: true
|
||||||
objects_per_sitemap: 1000
|
objects_per_sitemap: 1000
|
||||||
google_notification_enabled: true
|
|
||||||
use_show_in_search: true
|
use_show_in_search: true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -73,24 +73,6 @@ class GoogleSitemapExtension extends DataExtension
|
|||||||
return $can;
|
return $can;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function onAfterPublish()
|
|
||||||
{
|
|
||||||
GoogleSitemap::ping();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function onAfterUnpublish()
|
|
||||||
{
|
|
||||||
GoogleSitemap::ping();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default value of the priority field depends on the depth of the page in
|
* The default value of the priority field depends on the depth of the page in
|
||||||
* the site tree, so it must be calculated dynamically.
|
* the site tree, so it must be calculated dynamically.
|
||||||
|
@ -29,17 +29,8 @@ use ReflectionException;
|
|||||||
* The GoogleSitemap handle requests to 'sitemap.xml' the other two classes are
|
* The GoogleSitemap handle requests to 'sitemap.xml' the other two classes are
|
||||||
* used to render the sitemap.
|
* used to render the sitemap.
|
||||||
*
|
*
|
||||||
* You can notify ("ping") Google about a changed sitemap automatically whenever
|
* The config file is usually located in the _config folder of your project folder.
|
||||||
* a new page is published or unpublished.
|
* e.g. app/_config/googlesitemaps.yml
|
||||||
*
|
|
||||||
* By default, Google is not notified, and will pick up your new sitemap
|
|
||||||
* whenever the GoogleBot visits your website.
|
|
||||||
*
|
|
||||||
* To Enable notification of Google after every publish set google_notification_enabled
|
|
||||||
* to true in the googlesitemaps.yml config file.
|
|
||||||
*
|
|
||||||
* This file is usually located in the _config folder of your project folder.
|
|
||||||
* e.g mysite/_config/googlesitemaps.yml
|
|
||||||
*
|
*
|
||||||
* <example>
|
* <example>
|
||||||
* ---
|
* ---
|
||||||
@ -49,7 +40,6 @@ use ReflectionException;
|
|||||||
* Wilr\GoogleSitemaps\GoogleSitemap:
|
* Wilr\GoogleSitemaps\GoogleSitemap:
|
||||||
* enabled: true
|
* enabled: true
|
||||||
* objects_per_sitemap: 1000
|
* objects_per_sitemap: 1000
|
||||||
* google_notification_enabled: true
|
|
||||||
* use_show_in_search: true
|
* use_show_in_search: true
|
||||||
* </example>
|
* </example>
|
||||||
*
|
*
|
||||||
@ -84,15 +74,6 @@ class GoogleSitemap
|
|||||||
*/
|
*/
|
||||||
private static $exclude_redirector_pages = true;
|
private static $exclude_redirector_pages = true;
|
||||||
|
|
||||||
/**
|
|
||||||
* @config
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private static $search_indexes = [
|
|
||||||
'google' => 'http://www.google.com/webmasters/sitemaps/ping?sitemap='
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decorates the given DataObject with {@link GoogleSitemapDecorator}
|
* Decorates the given DataObject with {@link GoogleSitemapDecorator}
|
||||||
* and pushes the class name to the registered DataObjects.
|
* and pushes the class name to the registered DataObjects.
|
||||||
@ -452,41 +433,6 @@ class GoogleSitemap
|
|||||||
return static::inst()->getSitemaps();
|
return static::inst()->getSitemaps();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Notifies search indexes about changes to your sitemap. This behavior is disabled
|
|
||||||
* by default, to enable, read the documentation provided in the docs folder.
|
|
||||||
*
|
|
||||||
* After notifications have been enabled, every publish / unpublish of a page.
|
|
||||||
* will notify enabled search indexes of the update.
|
|
||||||
*
|
|
||||||
* If the site is in development mode no ping will be sent.
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public static function ping()
|
|
||||||
{
|
|
||||||
if (!self::enabled() || Director::isDev()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$location = urlencode(Controller::join_links(
|
|
||||||
Director::absoluteBaseURL(),
|
|
||||||
'sitemap.xml'
|
|
||||||
));
|
|
||||||
|
|
||||||
$response = true;
|
|
||||||
|
|
||||||
foreach (self::config()->search_indexes as $name => $url) {
|
|
||||||
$configName = $name . '_notification_enabled';
|
|
||||||
|
|
||||||
if (self::config()->$configName) {
|
|
||||||
$response = $response && file_get_contents($url . $location);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is GoogleSitemap enabled?
|
* Is GoogleSitemap enabled?
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user