Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter to exclude tt_news categories #5

Open
dmitryd opened this issue Apr 11, 2013 · 0 comments
Open

Parameter to exclude tt_news categories #5

dmitryd opened this issue Apr 11, 2013 · 0 comments

Comments

@dmitryd
Copy link
Owner

dmitryd commented Apr 11, 2013

I think it's a good idea to have parameter to exclude special tt_news categories from google sitemap. In addition I have created a diff file in which the parameter "excludeCat" passed as array. The array has the advantage that the individual category UIDs can be validated with intval. The diff file refers to the file class.tx_ddgooglesitemap_ttnews.php

--- class.tx_ddgooglesitemap_ttnews.php-rev33290.svn000.tmp.php Mi Mai 19 10:39:46 2010
+++ C:/Users/Christian/Desktop/dd_googlesitemap/trunk/class.tx_ddgooglesitemap_ttnews.php   Sa Nov 24 21:46:36 2012
@@ -75,6 +75,13 @@
    protected $isNewsSitemap;

    /**
+    * Comma separated cat uid list
+    *
+    * @var string
+    */
+   protected $excludeCategory;
+   
+   /**
     * Single view page
     *
     * @var int
@@ -106,6 +113,16 @@
        $this->isNewsSitemap = (t3lib_div::_GET('type') === 'news');
        $rendererClass = ($this->isNewsSitemap ?
            'tx_ddgooglesitemap_news_renderer' : 'tx_ddgooglesitemap_normal_renderer');
+           
+       $excludeArray = t3lib_div::_GP('excludeCat');
+       if (is_array($excludeArray)) {
+           foreach ($excludeArray AS $excludeCat) {
+               $this->excludeCategory .= intval($excludeCat) . ',';
+           }
+           $this->excludeCategory = rtrim($this->excludeCategory, ',');
+       }
+       unset($excludeArray);
+       
        $this->renderer = t3lib_div::makeInstance($rendererClass);
    }

@@ -120,11 +137,21 @@

        if (count($this->pidList) > 0) {
            t3lib_div::loadTCA('tt_news');
-           $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,datetime,keywords',
-               'tt_news', 'pid IN (' . implode(',', $this->pidList) . ')' .
-               ($this->isNewsSitemap ? ' AND crdate>=' . (time() - 48*60*60) : '') .
-               $this->cObj->enableFields('tt_news'), '', 'datetime DESC'
-           );
+           
+           if (!empty($this->excludeCategory)) {
+               $res = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('uid,title,datetime,keywords', 
+                   'tt_news', 'tt_news_cat_mm', '', ' AND pid IN (' . implode(',', $this->pidList) . ')' .
+                   ($this->isNewsSitemap ? ' AND crdate>=' . (time() - 48*60*60) : '') . 
+                   ' AND tt_news_cat_mm.uid_foreign NOT IN (' . $this->excludeCategory . ')' . 
+                   $this->cObj->enableFields('tt_news'), '', 'datetime DESC');
+           } else {
+               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,title,datetime,keywords',
+                   'tt_news', 'pid IN (' . implode(',', $this->pidList) . ')' .
+                   ($this->isNewsSitemap ? ' AND crdate>=' . (time() - 48*60*60) : '') .
+                   $this->cObj->enableFields('tt_news'), '', 'datetime DESC'
+               );
+           }
+           
            $rowCount = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
            while (false !== ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))) {
                if (($url = $this->getNewsItemUrl($row['uid']))) {

Imported from Forge: http://forge.typo3.org/issues/43271
Author: Christian Wolfram

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant