mirror of
https://github.com/wilr/silverstripe-googlesitemaps.git
synced 2024-10-22 11:05:48 +02:00
Correct path to stylesheet, update stylesheets for images
This commit is contained in:
parent
c3fcd84542
commit
adb3ed94fc
@ -30,7 +30,9 @@ class GoogleSitemapController extends Controller
|
||||
*/
|
||||
private static $allowed_actions = [
|
||||
'index',
|
||||
'sitemap'
|
||||
'sitemap',
|
||||
'styleSheetIndex',
|
||||
'styleSheet'
|
||||
];
|
||||
|
||||
|
||||
@ -96,13 +98,13 @@ class GoogleSitemapController extends Controller
|
||||
return str_replace('-', '\\', $class);
|
||||
}
|
||||
|
||||
public function StylesheetIndexPath()
|
||||
public function styleSheetIndex()
|
||||
{
|
||||
return ModuleResourceLoader::resourceURL('wilr/silverstripe-googlesitemaps:xsl/xml-sitemapindex.xsl');
|
||||
return $this->renderWith('xml-sitemapindex');
|
||||
}
|
||||
|
||||
public function StylesheetPath()
|
||||
public function styleSheet()
|
||||
{
|
||||
return ModuleResourceLoader::resourceURL('wilr/silverstripe-googlesitemaps:xsl/xml-sitemap.xsl');
|
||||
return $this->renderWith('xml-sitemap');
|
||||
}
|
||||
}
|
||||
|
@ -7,20 +7,14 @@ use SilverStripe\ErrorPage\ErrorPage;
|
||||
use SilverStripe\Forms\DropdownField;
|
||||
use SilverStripe\Forms\LiteralField;
|
||||
use SilverStripe\Forms\Tab;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
|
||||
class GoogleSitemapSiteTreeExtension extends GoogleSitemapExtension
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private static $db = array(
|
||||
private static $db = [
|
||||
"Priority" => "Varchar(5)"
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* @param FieldList
|
||||
*/
|
||||
public function updateSettingsFields(&$fields)
|
||||
{
|
||||
$prorities = array(
|
||||
@ -65,11 +59,6 @@ class GoogleSitemapSiteTreeExtension extends GoogleSitemapExtension
|
||||
$priority->setEmptyString(_t('GoogleSitemaps.PRIORITYAUTOSET', 'Auto-set based on page depth'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FieldList
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updateFieldLabels(&$labels)
|
||||
{
|
||||
parent::updateFieldLabels($labels);
|
||||
@ -143,20 +132,28 @@ class GoogleSitemapSiteTreeExtension extends GoogleSitemapExtension
|
||||
public function ImagesForSitemap()
|
||||
{
|
||||
$list = new ArrayList();
|
||||
$cachedImages = [];
|
||||
|
||||
foreach ($this->owner->hasOne() as $field => $type) {
|
||||
if (singleton($type) instanceof Image) {
|
||||
$image = $this->owner->getComponent($field);
|
||||
if ($image && $image->exists()) {
|
||||
|
||||
if ($image && $image->exists() && !isset($cachedImages[$image->ID])) {
|
||||
$cachedImages[$image->ID] = true;
|
||||
|
||||
$list->push($image);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->owner->hasMany() as $field => $type) {
|
||||
if (singleton($type) instanceof Image) {
|
||||
$images = $this->owner->getComponents($field);
|
||||
|
||||
foreach ($images as $image) {
|
||||
if ($image && $image->exists()) {
|
||||
if ($image && $image->exists() && !isset($cachedImages[$image->ID])) {
|
||||
$cachedImages[$image->ID] = true;
|
||||
|
||||
$list->push($image);
|
||||
}
|
||||
}
|
||||
@ -164,6 +161,7 @@ class GoogleSitemapSiteTreeExtension extends GoogleSitemapExtension
|
||||
}
|
||||
|
||||
$this->owner->extend('updateImagesForSitemap', $list);
|
||||
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml-stylesheet type='text/xsl' href='$StylesheetIndexPath'?>
|
||||
<?xml-stylesheet type='text/xsl' href='{$BaseHref}sitemap.xml/styleSheetIndex'?>
|
||||
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><% loop Sitemaps %>
|
||||
<sitemap>
|
||||
<loc>{$AbsoluteBaseURL}sitemap.xml/sitemap/$ClassName/$Page.xml</loc>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml-stylesheet type='text/xsl' href='$StylesheetPath'?>
|
||||
<?xml-stylesheet type='text/xsl' href='{$BaseHref}sitemap.xml/styleSheet'?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
|
||||
<% loop $Items %>
|
||||
<url>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<head>
|
||||
<title>XML Sitemap</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link rel="stylesheet" href="resources/wilr/silverstripe-googlesitemaps/css/style.css" />
|
||||
<link rel="stylesheet" href="{$BaseHref}resources/wilr/silverstripe-googlesitemaps/css/style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
@ -38,12 +38,12 @@
|
||||
<xsl:value-of select="sitemap:loc"/>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="imagesCount" select="count(image:image)"/>
|
||||
<a href="{$itemURL}">
|
||||
<a href="{\$itemURL}">
|
||||
<xsl:value-of select="sitemap:loc"/>
|
||||
</a>
|
||||
|
||||
|
||||
<xsl:if test="$imagesCount > 0">
|
||||
<xsl:if test="\$imagesCount > 0">
|
||||
<table class="imagestable" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<th>Images</th>
|
||||
@ -54,10 +54,10 @@
|
||||
</xsl:variable>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="{$imageURL}" width="40px"/>
|
||||
<img src="{\$imageURL}" width="40px"/>
|
||||
</td>
|
||||
<td>
|
||||
<a href="{$imageURL}">
|
||||
<a href="{\$imageURL}">
|
||||
<xsl:value-of select="image:loc"/>
|
||||
</a>
|
||||
</td>
|
||||
@ -72,7 +72,7 @@
|
||||
<xsl:value-of select="concat(sitemap:priority*100,'%')"/>
|
||||
</td>
|
||||
<td>
|
||||
<xsl:value-of select="concat(translate(substring(sitemap:changefreq, 1, 1),concat($lower, $upper),concat($upper, $lower)),substring(sitemap:changefreq, 2))"/>
|
||||
<xsl:value-of select="concat(translate(substring(sitemap:changefreq, 1, 1),concat(\$lower, \$upper),concat(\$upper, \$lower)),substring(sitemap:changefreq, 2))"/>
|
||||
</td>
|
||||
<td>
|
||||
<xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)))"/>
|
@ -6,7 +6,7 @@
|
||||
<head>
|
||||
<title>XML Sitemap</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link rel="stylesheet" href="resources/wilr/silverstripe-googlesitemaps/css/style.css" />
|
||||
<link rel="stylesheet" href="{$BaseHref}resources/wilr/silverstripe-googlesitemaps/css/style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
@ -35,7 +35,7 @@
|
||||
<xsl:variable name="itemURL">
|
||||
<xsl:value-of select="sitemap:loc"/>
|
||||
</xsl:variable>
|
||||
<a href="{$itemURL}">
|
||||
<a href="{\$itemURL}">
|
||||
<xsl:value-of select="sitemap:loc"/>
|
||||
</a>
|
||||
</td>
|
Loading…
Reference in New Issue
Block a user