Skip to content
This repository has been archived by the owner on Aug 8, 2022. It is now read-only.

Fixes #512 #513

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions Classes/Hook/SitemapIndexHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ abstract class SitemapIndexHook implements SingletonInterface
*/
protected $pageTypeBlacklist = array();

/**
* List of whitelisted page types (Setup PAGE object typeNum)
*
* @var array
*/
protected $pageTypeWhitelist = array();

/**
* Page index status
*
Expand Down Expand Up @@ -157,6 +164,9 @@ protected function initConfiguration()

// Init blacklist for PAGE typenum
$this->pageTypeBlacklist = SitemapUtility::getPageTypeBlacklist();

// Init whitelist for PAGE typenum
$this->pageTypeWhitelist = SitemapUtility::getPageTypeWhitelist();
}

/**
Expand Down Expand Up @@ -293,9 +303,15 @@ protected function checkIfCurrentPageIsIndexable()

$tsfe = self::getTsfe();

// Check for type blacklisting (from typoscript PAGE object)
if (in_array($tsfe->type, $this->pageTypeBlacklist)) {
return false;
if (!empty($this->pageTypeWhitelist)) {
if (!in_array($tsfe->type, $this->pageTypeWhitelist)) {
return false;
}
} else {
// Check for type blacklisting (from typoscript PAGE object)
if (in_array($tsfe->type, $this->pageTypeBlacklist)) {
return false;
}
}

// Check if page is excluded from search engines
Expand Down
17 changes: 17 additions & 0 deletions Classes/Utility/SitemapUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,23 @@ public static function getPageTypeBlacklist()
return $ret;
}

/**
* Get list of whitelisted PAGE typenum (typoscript object)
*
* @return array
*/
public static function getPageTypeWhitelist()
{
$pageTypeWhitelist = [];
if (isset($GLOBALS['TSFE']->tmpl->setup['plugin.']['metaseo.']['sitemap.']['index.']['pageTypeWhitelist'])
&& strlen($GLOBALS['TSFE']->tmpl->setup['plugin.']['metaseo.']['sitemap.']['index.']['pageTypeWhitelist'])
>= 1) {
$pageTypeWhitelist = Typo3GeneralUtility::trimExplode(',',
$GLOBALS['TSFE']->tmpl->setup['plugin.']['metaseo.']['sitemap.']['index.']['pageTypeWhitelist']);
}
return $pageTypeWhitelist;
}

/**
* Return list of sitemap pages
*
Expand Down
3 changes: 3 additions & 0 deletions Configuration/TypoScript/setup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,9 @@ plugin.metaseo {
# Blacklist for SetupTS PAGE object typeNums
pageTypeBlacklist =

# Whitelist for SetupTS PAGE object typeNums (when set then pageTypeBlacklist is ignored)
pageTypeWhitelist =

allowNoStaticCachable = {$plugin.metaseo.sitemap.index.allowNoStaticCachable}
allowNoCache = {$plugin.metaseo.sitemap.index.allowNoCache}

Expand Down
3 changes: 3 additions & 0 deletions Documentation/DeveloperManual/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ plugin.metaseo.sitemap.index.blacklist List of Regular Exp

plugin.metaseo.sitemap.index.pageTypeBlacklist List of blacklisted page typeNums (SetupTS PAGE objects) String, comma separated

plugin.metaseo.sitemap.index.pageTypeWhitelist List of whitelisted page typeNums (SetupTS PAGE objects) String, comma separated
If set then "pageTypeBlacklist" is ignored.

plugin.metaseo.sitemap.index.fileExtension List of allowed file extensions for indexing List

Default:
Expand Down