Skip to content

Commit

Permalink
check for new parameter tt_news.single_page.*.keepListedAsPage to kee…
Browse files Browse the repository at this point in the history
…p single view pages listed

tt_news single page views can now be optionally kept on sitemap.xml output (e.g. for dual-mode pages which contain both a LIST and SINGLE view on the same page and toggle the active tt_news mode based upon parameters passed on URL).

Can be used by setting keepListedAsPage as follows: (10 = your copy of plugin.tx_weeaargooglesitemap_pi1 on a PAGE TLO)


    10.tt_news.single_page {
        1 = {$newsPageContainingSingleView}
        1.pid_list = {$newsFolder}
        
        # list in sitemap.xml despite being a single page view
        1.keepListedAsPage = 1
    }
  • Loading branch information
Daniel Neugebauer committed Nov 19, 2014
1 parent 4207caf commit cbe4a3f
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions pi1/class.tx_weeaargooglesitemap_pi1.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class tx_weeaargooglesitemap_pi1 extends tslib_pibase {
var $url;
var $usedSites = array();
var $allowedDoktypes = array(2, 1);
var $newsSinglePages = array();
var $excludedPages = array();
var $localizedIds = array();
var $languageParamIf0 = TRUE;
var $validCode = array('google', 'sitemap_org');
Expand Down Expand Up @@ -298,7 +298,7 @@ function check_cat_ids($ids, $id) {
}

function generateItem($pages_row, $id_name = 'uid') {
if (!$this->data[$pages_row[$id_name]][0] == 1 && count($pages_row) > 0 && (!in_array($pages_row[$id_name], $this->usedSites) || isset($pages_row["sys_language_uid"])) && (in_array($pages_row['doktype'], $this->allowedDoktypes) || isset($pages_row["sys_language_uid"]) ) && !in_array($pages_row[$id_name], $this->newsSinglePages)) {
if (!$this->data[$pages_row[$id_name]][0] == 1 && count($pages_row) > 0 && (!in_array($pages_row[$id_name], $this->usedSites) || isset($pages_row["sys_language_uid"])) && (in_array($pages_row['doktype'], $this->allowedDoktypes) || isset($pages_row["sys_language_uid"]) ) && !in_array($pages_row[$id_name], $this->excludedPages)) {
$langID = (isset($pages_row["sys_language_uid"])) ? $pages_row["sys_language_uid"] : $this->sys_language_uid;

$link = (substr($link, 0, 1) == '/') ? substr($link, 1) : $link;
Expand Down Expand Up @@ -344,12 +344,27 @@ function getData() {
$this->data[$row['pid']] = array($row['disabled'], $row['priority'], $row['changefreq']);
}

/* get news single pages */

// check if configured tt_news single view pages should be excluded or
// kept
if (is_array($this->conf["tt_news."]["single_page."]) && count($this->conf["tt_news."]["single_page."]) > 0) {
foreach ($this->conf["tt_news."]["single_page."] as $no => $test) {
if (!strpos($no, ".")) {
$this->newsSinglePages[] = $test;
$singlePagesConfig = $this->conf["tt_news."]["single_page."];
foreach ($singlePagesConfig as $key => $singlePage) {
$isSinglePageConfigLeafNode = (strpos($key, ".") === false);

// single pages are configured on parent level of detailed
// configuration, so we trigger on leaf nodes on first level
// beneath single_page
if ($isSinglePageConfigLeafNode) {
$shouldBeExcluded = true;

$hasSubConfig = array_key_exists($key.'.', $singlePagesConfig);
if ($hasSubConfig) {
$shouldBeExcluded = !(array_key_exists('keepListedAsPage', $singlePagesConfig[$key.'.']) && ($singlePagesConfig[$key.'.']['keepListedAsPage'] != 0));
}

if ($shouldBeExcluded) {
$this->excludedPages[] = $singlePage;
}
}
}
}
Expand Down

0 comments on commit cbe4a3f

Please sign in to comment.