1

Topic: Сортировка тем форума punbb в один клик pan_sorting_topics

Данная сортировка в виде стрелок вверх и вниз сортирует темы по возрастанию и убыванию.
Структура расширения
/extensions/pan_sorting_topics/img/button_down.png
/extensions/pan_sorting_topics/img/button_up.png
/extensions/pan_sorting_topics/lang/English.php
/extensions/pan_sorting_topics/lang/Russian.php
/extensions/pan_sorting_topics/index.html
/extensions/pan_sorting_topics/manifest.xml

manifest.xml

Spoiler
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE extension SYSTEM "ext-1.0.dtd">

<extension engine="1.0">
  <id>pan_sorting_topics</id>
  <title>Sorting topics (Up / Down)</title>
  <version>0.4</version>
  <description>Сортировка топиков в один клик при нажатии на стрелку (по возрастанию и убыванию).</description>
  <author>https://punbb.softplaza.net</author>
  <minversion>1.4.0</minversion>
  <maxtestedon>1.4.2</maxtestedon>
  
  <install><![CDATA[

  ]]></install>

  <uninstall><![CDATA[
  ]]></uninstall>

  <hooks>
    <hook id="vf_qr_get_topics"><![CDATA[
  
if (!empty($_GET['sort_by']))
{
  if($_GET['sort_by'] == 'subject_ASC') 
    $query['ORDER BY'] = 't.sticky ASC, t.subject ASC';
  if($_GET['sort_by'] == 'subject_DESC') 
    $query['ORDER BY'] = 't.sticky ASC, t.subject DESC';
  if($_GET['sort_by'] == 'posted_ASC') 
    $query['ORDER BY'] = 't.sticky ASC, t.posted ASC';
  if($_GET['sort_by'] == 'posted_DESC') 
    $query['ORDER BY'] = 't.sticky ASC, t.posted DESC';
  if($_GET['sort_by'] == 'num_replies_ASC') 
    $query['ORDER BY'] = 't.sticky ASC, t.num_replies ASC';
  if($_GET['sort_by'] == 'num_replies_DESC') 
    $query['ORDER BY'] = 't.sticky ASC, t.num_replies DESC';
  if($_GET['sort_by'] == 'num_views_ASC') 
    $query['ORDER BY'] = 't.sticky ASC, t.num_views ASC';
  if($_GET['sort_by'] == 'num_views_DESC') 
    $query['ORDER BY'] = 't.sticky ASC, t.num_views DESC';
  if($_GET['sort_by'] == 'last_post_ASC') 
    $query['ORDER BY'] = 't.sticky ASC, t.last_post ASC';
  if($_GET['sort_by'] == 'last_post_DESC') 
    $query['ORDER BY'] = 't.sticky ASC, t.last_post DESC';
}

    ]]></hook>

    <hook id="vf_start"><![CDATA[
    
if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'.php'))
  require $ext_info['path'].'/lang/'.$forum_user['language'].'.php';
else
  require $ext_info['path'].'/lang/English.php';
  
    ]]></hook>
    
    <hook id="vf_main_output_start"><![CDATA[

$forum_page['item_header2'] = array();
$forum_page['item_header2']['subject']['title'] = '<strong class="subject-title">'.$lang_pan_sorting_topics['Sort to name'].'
<a href="'.forum_link($forum_url['forum'], $id).'&sort_by=subject_ASC"><img src="'.FORUM_ROOT.'extensions/'.$ext_info['id'].'/img/button_up.png"></a>
<a href="'.forum_link($forum_url['forum'], $id).'&sort_by=subject_DESC"><img src="'.FORUM_ROOT.'extensions/'.$ext_info['id'].'/img/button_up.png"></a>
'.$lang_pan_sorting_topics['Sort to date'].'<a href="'.forum_link($forum_url['forum'], $id).'&sort_by=posted_ASC"><img src="'.FORUM_ROOT.'extensions/'.$ext_info['id'].'/img/button_up.png"></a>
<a href="'.forum_link($forum_url['forum'], $id).'&sort_by=posted_DESC"><img src="'.FORUM_ROOT.'extensions/'.$ext_info['id'].'/img/button_down.png"></a></strong>';

$forum_page['item_header2']['info']['replies'] = '<strong class="info-replies">
<a href="'.forum_link($forum_url['forum'], $id).'&sort_by=num_replies_ASC"><img src="'.FORUM_ROOT.'extensions/'.$ext_info['id'].'/img/button_up.png"></a>  
<a href="'.forum_link($forum_url['forum'], $id).'&sort_by=num_replies_DESC"><img src="'.FORUM_ROOT.'extensions/'.$ext_info['id'].'/img/button_down.png"></a></strong>';

if ($forum_config['o_topic_views'] == '1')
  $forum_page['item_header2']['info']['views'] = '<strong class="info-views">
  <a href="'.forum_link($forum_url['forum'], $id).'&sort_by=num_views_ASC"><img src="'.FORUM_ROOT.'extensions/'.$ext_info['id'].'/img/button_up.png"></a>  
  <a href="'.forum_link($forum_url['forum'], $id).'&sort_by=num_views_DESC"><img src="'.FORUM_ROOT.'extensions/'.$ext_info['id'].'/img/button_down.png"></a></strong>';

$forum_page['item_header2']['info']['lastpost'] = '<strong class="info-lastpost">
<a href="'.forum_link($forum_url['forum'], $id).'&sort_by=last_post_ASC"><img src="'.FORUM_ROOT.'extensions/'.$ext_info['id'].'/img/button_up.png"></a>  
<a href="'.forum_link($forum_url['forum'], $id).'&sort_by=last_post_DESC"><img src="'.FORUM_ROOT.'extensions/'.$ext_info['id'].'/img/button_down.png"></a></strong>';
    
    ]]></hook>
    
    <hook id="vf_pre_topic_loop_start"><![CDATA[
    
?>

  <div class="main-subhead">
    <p class="item-summary<?php echo ($forum_config['o_topic_views'] == '1') ? ' forum-views' : ' forum-noview' ?>"><span><?php printf($lang_forum['Forum subtitle'], implode(' ', $forum_page['item_header2']['subject']), implode(', ', $forum_page['item_header2']['info'])) ?></span></p>
  </div>
<?php
    
    ]]></hook>  
  </hooks>
</extension>

Russian.php

Spoiler
<?php

$lang_pan_sorting_topics = array(

'Sort to name'      => 'Сортировка по названию ',
'Sort to date'    => ' дате создания ',

);

?>

English.php

Spoiler
<?php

$lang_pan_sorting_topics = array(

'Sort to name'      => 'Sort to name ',
'Sort to date'    => ' to date ',

);

?>

2

Re: Сортировка тем форума punbb в один клик pan_sorting_topics

вот изображения которые можно использовать, хотя можно и свои.
https://punbb.softplaza.net/extensions/ … n_down.png
https://punbb.softplaza.net/extensions/ … ton_up.png

ВНИМАНИЕ! Конфликт с Quadric SEO Optimizer.