Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save TrywaR/9ab48c685b55c09bfce1819e818bd477 to your computer and use it in GitHub Desktop.
Save TrywaR/9ab48c685b55c09bfce1819e818bd477 to your computer and use it in GitHub Desktop.
MODX Revo | Tagger > 404 для страниц без результатов, убрать дубли
<?php
# Должно быть включено системное событие OnWebPageInit
// $modx->log(modX::LOG_LEVEL_ERROR, print_r($_GET,1));
if (isset($_GET['teg'])){
$return = false;
$arrTags = explode(',', $_GET['teg']);
if (count($arrTags) > 1){
# Если больше 1 тега то возвращяем 404
$return = true;
}else{
# Если по такому тегу нет результатов, возвращаем 404
$params = array(
'tags' => $_GET['teg'],
'where' => '{"isfolder": 0}'
);
$sSql = $modx->runSnippet('TaggerGetResourcesWhere', $params);
$params = array(
'parents' => '6',
'where' => $sSql,
'tpl' => '@INLINE ,',
);
$res = $modx->runSnippet('pdoResources', $params);
if ($res === '')
$return = true;
}
if ($return)
$modx->sendErrorPage();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment