Textpattern - на русском языке

форум общения русскоязычных пользователей CMS Текстпаттерн

Вы не зашли.

#1 11-06-2010 14:21:36

Redduck
мыслете
Откуда: Челябинск
Зарегистрирован: 12-10-2009
Сообщений: 187
Вебсайт

Плагины tru_tags и ob1_pagination

Немного изменил функцию 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);
    }
}


Учусь потихоньку, а надо бы побыстрей, да лень.
Куба, пой, Куба, пой, Куба, народ свободный мой!

Неактивен

 

#2 14-06-2010 12:58:27

makss
наш
Зарегистрирован: 21-10-2008
Сообщений: 208
Вебсайт

Re: Плагины tru_tags и ob1_pagination

Спасибо!  Полезный код.


aks_rss : RSS parser and aggregator | http://makss.uaho.net/plugins/aks_rss
aks_table : Simple tables in TxP (Ctrl+C, Ctrl+V) | http://makss.uaho.net/plugins/aks_table

Неактивен

 

#3 11-07-2011 04:20:11

Redduck
мыслете
Откуда: Челябинск
Зарегистрирован: 12-10-2009
Сообщений: 187
Вебсайт

Re: Плагины tru_tags и ob1_pagination

Немного подправил код.
Теперь работают поля 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);
    }
}


Учусь потихоньку, а надо бы побыстрей, да лень.
Куба, пой, Куба, пой, Куба, народ свободный мой!

Неактивен

 

Board footer

RSS   Rambler's Top100
Powered by PunBB
Textpattern.ru