форум общения русскоязычных пользователей CMS Текстпаттерн
Вы не зашли.
Немного изменил функцию tru_tags_handler из плагина tru_tags. Теперь работает плагин ob1_pagination в связке с tru_tags. Полное описание на сайте http://www.solo-line.ru/articles/dorabo … a-tru_tags Всем удачи.
function tru_tags_handler($atts) {
$pg = urldecode(strip_tags(gps('pg')));
$pg = (!empty($pg)) ? $pg : 1;
$tag_parameter = tru_tags_tag_parameter(array(), false);
if (!empty($tag_parameter)) {
if (tru_tags_redirect_if_needed($tag_parameter)) {
return '';
}
$clean_atts = tru_tags_fixup_query_atts($atts, $tag_parameter);
$pageby = (empty($clean_atts['pageby']) ? $clean_atts['limit'] : $clean_atts['pageby']);
$offset = ($pg - 1) * $pageby;
$clean_atts['pageby'] = $pageby;
$clean_atts['offset'] = $offset;
if ($clean_atts['keywords']) {
$keys = doSlash(do_list($clean_atts['keywords']));
foreach ($keys as $key) {
$keyparts[] = "FIND_IN_SET('".$key."',Keywords)";
}
$keywords = " and (" . join(' or ',$keyparts) . ")";
}
else {$keywords = "";}
$where = "1=1" . $keywords;
$grand_total = safe_count('textpattern',$where);
$total = $grand_total - $offset;
$numPages = ceil($grand_total/$pageby);
$pageout['pg'] = $pg;
$pageout['numPages'] = $numPages;
$pageout['s'] = 'tag';
$pageout['c'] = '';
$pageout['grand_total'] = $grand_total;
$pageout['total'] = $total;
global $thispage;
if (empty($thispage)) $thispage = $pageout;
$result = doArticles($clean_atts, true); #function in TXP code
if (trim($result) == '') {
if (isset($atts['noarticles'])) {
tru_tags_redirect($atts['noarticles'], true);
} else if (isset($atts['404redirect']) && !$atts['404redirect']) {
return $result;
} else {
txp_die(gTxt('404_not_found'), '404');
}
} else {
return $result;
}
} else {
return tru_tags_cloud($atts);
}
}
Неактивен
Спасибо! Полезный код.
Неактивен
Немного подправил код.
Теперь работают поля section, category, autor, time.
Не работают поля month, customfieldname ну и другие.
Внимание! Код пока полностью не протестирован. У меня вроде как работает.
function tru_tags_handler($atts) {
$pg = urldecode(strip_tags(gps('pg')));
$pg = (!empty($pg)) ? $pg : 1;
$tag_parameter = tru_tags_tag_parameter(array(), false);
if (!empty($tag_parameter)) {
if (tru_tags_redirect_if_needed($tag_parameter)) {
return '';
}
$clean_atts = tru_tags_fixup_query_atts($atts, $tag_parameter);
$pageby = (empty($clean_atts['pageby']) ? $clean_atts['limit'] : $clean_atts['pageby']);
$offset = ($pg - 1) * $pageby;
$clean_atts['pageby'] = $pageby;
$clean_atts['offset'] = $offset;
if ($clean_atts['keywords']) {
$keys = doSlash(do_list($clean_atts['keywords']));
foreach ($keys as $key) {
$keyparts[] = "FIND_IN_SET('".$key."',Keywords)";
}
$keywords = " and (" . join(' or ',$keyparts) . ")";
}
else {$keywords = "";}
if ($clean_atts['section']) {
$section = " and Section IN ('".join("','", doSlash(do_list($clean_atts['section'])))."')";
}
else {$section = "";}
if ($clean_atts['category']) {
$category = join("','", doSlash(do_list($clean_atts['category'])));
$category = " and (Category1 IN ('".$category."') or Category2 IN ('".$category."'))";
}
else { $category = ""; }
if ($clean_atts['status']) {
$status = join("','", doSlash(do_list($clean_atts['status'])));
}
else { $status = " and Status >= 4"; }
if ($clean_atts['autor']) {
$autor = " and AuthorID IN ('".join("','", doSlash(do_list($clean_atts['autor'])))."')";
}
else { $autor = ""; }
if ($clean_atts['time']) {
$time = $clean_atts['time'];
switch ($time) {
case 'any':
$time = ""; break;
case 'future':
$time = " and Posted > now()"; break;
default:
$time = " and Posted <= now()";
}
}
else { $time = " and Posted <= now()"; }
$where = "1=1" . $keywords . $section . $category . $status . $autor . $time;
$grand_total = safe_count('textpattern',$where);
$total = $grand_total - $offset;
$numPages = ceil($grand_total/$pageby);
$pageout['pg'] = $pg;
$pageout['numPages'] = $numPages;
$pageout['s'] = '';
$pageout['c'] = '';
$pageout['grand_total'] = $grand_total;
$pageout['total'] = $total;
global $thispage;
if (empty($thispage)) $thispage = $pageout;
$result = doArticles($clean_atts, true); #function in TXP code
if (trim($result) == '') {
if (isset($atts['noarticles'])) {
tru_tags_redirect($atts['noarticles'], true);
} else if (isset($atts['404redirect']) && !$atts['404redirect']) {
return $result;
} else {
txp_die(gTxt('404_not_found'), '404');
}
} else {
return $result;
}
} else {
return tru_tags_cloud($atts);
}
}
Неактивен