Forums

Problem with paging (1 post)

  1. IKTP
    Member
    Posted 1 year ago #

    I currently allow users to sort through their comments with the following code and plan to use something similar for posts but am having some issues with paging.

    Change the sort option:

    if (empty($_GET['orderby'])){
    $orderby=comment_karma;} else {
    $orderby = $_GET['orderby']; }
    if (empty($_GET['order'])){
    $order=DESC;} else {
    $order = $_GET['order'];
    }

    Sorting links:

    <li class="<?php echo $commentpopularclass; ?>"><a href="?orderby=comment_karma&order=DESC">Popularity</a></li>
    
    <li class="<?php echo $commentnewclass; ?>"><a href="?orderby=comment_date_gmt&order=DESC" >New to Old</a></li>
    <li class="<?php echo $commentoldclass; ?>"><a href="?orderby=comment_date_gmt&order=ASC">Old to New</a></li>

    This code sets the default rating of comments by number of votes (commentkarma) but also allows users to see comments sorted by new to old or old to new. The issue I am having is that when you are in a non-default category, say old to new, and switch pages, when it loads page 2 it will load it with the default sorting option, i.e. the url will read /comment-page-2/#comments and since the ?orderby doesnt get transfered the sorting option goes back to the default. I would also like that whenever you switch sorting options you go back to page 1.

    Can anyone help? Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic