default_amp_content.php
2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* @package JMAP::SITEMAP::components::com_jmap
* @subpackage views
* @subpackage sitemap
* @subpackage tmpl
* @author Joomla! Extensions Store
* @copyright (C) 2015 - Joomla! Extensions Store
* @license GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html
*/
defined ( '_JEXEC' ) or die ( 'Restricted access' );
$priority = $this->sourceparams->get ( 'priority', '0.5' );
$changefreq = $this->sourceparams->get ( 'changefreq', 'daily' );
$showPageBreaks = $this->cparams->get ( 'show_pagebreaks', 1 );
// Get default menu - home and check if a single article is linked, if so skip to avoid duplicated content
$homeArticleID = false;
$defaultMenu = $this->application->getMenu()->getDefault(JFactory::getLanguage()->getTag());
if( isset($defaultMenu->query['option']) &&
isset($defaultMenu->query['view']) &&
$defaultMenu->query['option'] == 'com_content' &&
$defaultMenu->query['view'] == 'article') {
$homeArticleID = (int)$defaultMenu->query['id'];
}
if (count ( $this->source->data ) != 0) {
require_once (JPATH_BASE . '/components/com_content/helpers/route.php');
foreach ( $this->source->data as $elm ) {
// Element category empty da right join
if(!$elm->id) {
continue;
}
// Article found as linked to home, skip and avoid duplicate link
if((int)$elm->id === $homeArticleID) {
continue;
}
$elm->slug = $elm->alias ? ($elm->id . ':' . $elm->alias) : $elm->id;
$seolink = JRoute::_ ( ContentHelperRoute::getArticleRoute ( $elm->slug, $elm->catslug, $elm->language ) );
// Skip outputting
if(array_key_exists($seolink, $this->outputtedLinksBuffer)) {
continue;
}
// Else store to prevent duplication
$this->outputtedLinksBuffer[$seolink] = true;
$timestamp = (isset($elm->modified) && $elm->modified != FALSE && $elm->modified != -1) ? $elm->modified : time();
$modified = gmdate('Y-m-d\TH:i:s\Z', $timestamp);
?>
<url>
<loc><?php echo $this->sefSuffixEnabled ? $this->liveSite . str_ireplace('.html', '.' . $this->ampSuffix . '.html', $seolink) : $this->liveSite . $seolink . '/' . $this->ampSuffix; ?></loc>
<lastmod><?php echo $modified; ?></lastmod>
<changefreq><?php echo $changefreq;?></changefreq>
<priority><?php echo $elm->priority ? $elm->priority : $priority;?></priority>
</url>
<?php
}
}