1
mravojed
PATCH: paged view for comments in flat mode
  • 2005/1/28 23:31

  • mravojed

  • Just popping in

  • Posts: 3

  • Since: 2005/1/18


Hi, this is a hack to show page navigation buttons in comment lists.
It is easy going, and not really hard hack. Don't know what the guys at xoops.org used, but this one is not complicated.
However, it works with FLAT view only. Other view modes are intact.

Change include/comment_view.php:

Around line 75, add this:

$com_limit = isset($_GET['com_limit']) ? intval($_GET['com_limit']) : 10;
$com_start = isset($_GET['com_start']) ? intval($_GET['com_start']) : 0;


just before

$com_id = isset($_GET['com_id']) ? intval($_GET['com_id']) : 0;
$com_rootid = isset($_GET['com_rootid']) ? intval($_GET['com_rootid']) : 0;


(note: 10 is default number of comments to show in flat view. This should be configurable from admin page, but I'm lazy to
program it).

and then change

if ($com_mode == 'flat') {
    
$comments =& $comment_handler->getByItemId($xoopsModule->getVar('mid'), $com_itemid$com_dborder);


to:

if ($com_mode == 'flat') {
    
$total $comment_handler->getCountByItemId($xoopsModule->getVar('mid'), $com_itemid);
    
$comments =& $comment_handler->getByItemId($xoopsModule->getVar('mid'), $com_itemid$com_dbordernull$com_limit$com_start);


and after last $xoopsTpl->assing(...) add following:

if(isset($total)) {
    include_once 
XOOPS_ROOT_PATH.'/class/pagenav.php';
                                                                                                            
    
$q "";
    foreach(
$_GET as $key => $val) {
        if(
$key != 'com_start') {
            
$q .= '&'.urlencode($key).'='.urlencode($val);
          }
      }
 
    
$pagenav = new XoopsPageNav($total$com_limit$com_start'com_start'substr($q1));
    
$xoopsTpl->assign('commentpagenav_text'$pagenav->renderNav());
    
$xoopsTpl->assign('commentpagenav_img'$pagenav->renderImageNav());
  }



And that is all you need to change in code.

Also, you have to modify system_comments_flat.html template
to add navigation buttons. Just add

<{$commentpagenav_img}>


At top, and to the bottom of that template.

Hope it works for you. It works for me at http://www.srbovanje.com

Final note:
It has some issues with showing correct page when invoked from list-of-recent-comments block. But I'm looking into that, and hopefully I'll find solution quickly.

2
mravojed
Re: PATCH: paged view for comments in flat mode
  • 2005/1/29 0:48

  • mravojed

  • Just popping in

  • Posts: 3

  • Since: 2005/1/18


Update:

This is the missing code to calculate correct com_start from given com_id:

if(($com_id 0) && ($com_start == 0) && ($com_limit 1)) {
     
$criteria = new CriteriaCompo(new Criteria('com_modid'intval($xoopsModule->getVar('mid'))));
     
$criteria->add(new Criteria('com_itemid'intval($com_itemid)));
     
$criteria->add(new Criteria('com_id'intval($com_id), $com_dborder == 'ASC' "<" ">="));

     
$count $comment_handler->getCount($criteria);

     
$com_start sprintf("%d", ($count $com_limit)) * $com_limit;
  }


You have to put it just after
if ($com_mode == 'flat') {



And by the way, you can grab already modified comment_view.php from here
http://mravojed.mindnever.org/comment_view.php.gz
(this is comment_view.php from 2.0.9.2).


If you use this file, only thing you have to change is comment_flat.html template, and you are ready to rock!

N-joy.

Login

Who's Online

306 user(s) are online (209 user(s) are browsing Support Forums)


Members: 0


Guests: 306


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits