Skip to content

Commit

Permalink
#29 use change frequency as max age
Browse files Browse the repository at this point in the history
  • Loading branch information
svanschu committed Nov 13, 2017
1 parent e1cbc3e commit c95df4c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/com_schuweb_sitemap/views/xml/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}

if ($params->get('cacheControlUseChangeFrequency', 1) == 1) {
//TODO
$cacheControl += 'max-age=' + $this->changeFreq;
} else {
if ($maxAge = $params->getInt('cacheControlMaxAge', 0) > 0) {
$cacheControl += 'max-age=' + $maxAge;
Expand Down
33 changes: 33 additions & 0 deletions components/com_schuweb_sitemap/views/xml/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,39 @@ function display($tpl = null)
$this->sitemapItems = $this->get('SitemapItems');
$this->extensions = $this->get('Extensions');

$freq = 31536000;
foreach ($this->items as $item) {
foreach ($item as $iitem) {
foreach ($iitem->items as $iitems) {
switch ($iitems->changefreq) {
case "never":
case "yearly":
if ($freq > 31536000)
$freq = 31536000;
break;
case "monthly":
if ($freq > 18144000)
$freq = 18144000;
break;
case "weekly":
if ($freq > 604800)
$freq = 604800;
break;
case "daily": //60 Sekunden x 60 Minuten x 24 Stunden
if ($freq > 86400)
$freq = 86400;
break;
case "hourly":
if ($freq > 3600)
$freq = 3600;
break;
}
}
}
}

$this->changeFreq = $freq;

// Check for errors.
if (count($errors = $this->get('Errors'))) {
$app->enqueueMessage(implode("\n", $errors), 'warning');
Expand Down

0 comments on commit c95df4c

Please sign in to comment.