• Resolved tapiohuuhaa

    (@tapiohuuhaa)


    I would like to add 1-3 buttons to the forum topics listing in order to change the default order. I would code it to changed template, if I would know what functions to use.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Robin W

    (@robin-w)

    answered in bbpress support forum, but very complicated to do

    Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    This was not very complicated because I needed just three options. In fact when used default order I just prevented changing the order:

    `function my_custom_display_topic_index_query () {
    global $_GET,$_COOKIE;
    if(isset($_GET[‘myOrderBy’]) && !($_GET[‘myOrderBy’]==’default’)){ // if seleted default, it just doon’t change anything or returns original listing order
    $args[‘orderby’] =$_GET[‘myOrderBy’];
    if($_GET[‘myOrderBy’]==’post_date’) $args[‘order’] = ‘DESC’;
    else $args[‘order’] = ‘ASC’;
    }elseif(isset($_COOKIE[‘myOrderBy’]) && !($_COOKIE[‘myOrderBy’]==’default’)){
    $args[‘orderby’] =$_COOKIE[‘myOrderBy’];
    if($_COOKIE[‘myOrderBy’]==’post_date’) $args[‘order’] = ‘DESC’;
    else $args[‘order’] = ‘ASC’;
    }
    return $args;
    }

    if((isset($_GET[‘myOrderBy’]) && !($_GET[‘myOrderBy’]==’default’)))
    add_filter(‘bbp_before_has_topics_parse_args’, ‘my_custom_display_topic_index_query’ );
    elseif(isset($_COOKIE[‘myOrderBy’]) && !($_COOKIE[‘myOrderBy’]==’default’) && !isset($_GET[‘myOrderBy’]))
    add_filter(‘bbp_before_has_topics_parse_args’, ‘my_custom_display_topic_index_query’ );

    function printSelections(){
    global $_SERVER,$_GET,$_COOKIE;
    $selval=$_GET[‘myOrderBy’];
    $extraClass=’ active-button’;
    if(isset($selval)){
    if($selval==’post_date’) $extraClass2=$extraClass;
    elseif($selval==’post_title’) $extraClass3=$extraClass;
    elseif($selval==’default’) $extraClass1=$extraClass;
    }elseif(isset($_COOKIE[‘myOrderBy’])){
    if($_COOKIE[‘myOrderBy’]==’post_date’) $extraClass2=$extraClass;
    elseif($_COOKIE[‘myOrderBy’]==’post_title’) $extraClass3=$extraClass;
    elseif($_COOKIE[‘myOrderBy’]==’default’) $extraClass1=$extraClass;
    }elseif(!isset($selval) && !isset($_COOKIE[‘myOrderBy’])){$extraClass1=$extraClass;}
    $currentUrl=’https://’ . $_SERVER[‘HTTP_HOST’]. $_SERVER[‘REQUEST_URI’];
    $myUrlPos= stripos($currentUrl,’?’);
    if($myUrlPos)
    $currentUrl=substr($currentUrl,0,$myUrlPos);
    return ‘<div class=”queries”>
    <table class=”querytable” style=”width:auto!important;margin:0!important;padding:0!important;border-width:0″><tr>
    <th>J?rjestys:</th><td style=”padding:0 3px!important”>
    <a id=”orderbutton1″ class=”subscription-toggle orderbutton’.$extraClass1.'” href=”‘.$currentUrl.’?myOrderBy=default” style=”padding-left:6px!important”>Kommentoitu</a></td><td style=”padding:0 3px 0 0!important”><a id=”orderbutton2″ class=”subscription-toggle orderbutton’.$extraClass2.'” href=”‘.$currentUrl.’?myOrderBy=post_date” style=”padding-left:6px!important”>Aloitettu</a></td><td style=”padding:0 3px 0 0!important”><a id=”orderbutton3″ class=”subscription-toggle orderbutton’.$extraClass3.'” href=”‘.$currentUrl.’?myOrderBy=post_title” style=”padding-left:6px!important”>Otsikko</a></td></tr></table></div>’;
    }`

    Works as expected here:
    https://www.sanaristikkofoorumi.net/wordpress/forums/forum/sanaristikot/suomen-kuvalehti/

    • This reply was modified 5 years, 5 months ago by tapiohuuhaa.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding order buttons’ is closed to new replies.