Skip to:
Content
Pages
Categories
Search
Top
Bottom

Sorting Topic Loop


  • chuyqwerty
    Participant

    @chuyqwerty

    Hi, I really like the bbpress plugin and I almost got everything to work the way I want it to. I was hoping someone could help me on getting a feature that I really want and that I thought would be very helpful.

    For the list of topics under a forum, I want to have a way to sort the topics. So I want like a dropdown to “Order By” with choices like these: “Date, Most Replies, Recently Active” etc.

    I found ways to order them by all those options, but I just do not know how to make a dropdown list where I can pick them from.

    Help would be very much appreciated.

    Thank you.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi,

    Interesting topic, I would be interested in your queries and how you show it 🙂

    For the dropdown, how about something like this:

    function casiepa_template_before_topics_loop() {
    	?>
    	<select name="menu1" id="menu1">
    	<option value="">Order by...</option>
    	<option value="http://www.example.com/?order=date">By date</option>
    	<option value="http://www.example.com/?order=pop">Nbr of Replies</option>
    	</select>
    	<script type="text/javascript">
    	 var urlmenu = document.getElementById( 'menu1' );
    	 urlmenu.onchange = function() {
    	      window.open( this.options[ this.selectedIndex ].value );
    	 };
    	</script>
    	<?php
    }; 
    add_action( 'bbp_template_before_topics_loop', 'casiepa_template_before_topics_loop', 10, 0 );

    chuyqwerty
    Participant

    @chuyqwerty

    Hey, thank you so much for replying. I will try to use what you gave me here and see if I can get it to work. I will post what my loop-topics.php looks like in a bit so you can see what I did to try to get the dropdown to work. I do not really know php well so do not laugh… lol

    What I originally had did everything I wanted, except it ignored all sticky posts and it was sorting everything as a normal topic, which is obviously not good.

    Give me a few minutes and I will post my current loop-topics.php

    I really appreciate the help, by the way 🙂


    chuyqwerty
    Participant

    @chuyqwerty

    Ok, this is a dumb question but how do I paste source code here?…

    If not too long, you can put it between backquotes.
    So click the ‘code’ button (one but last button in the box where you type your reply), paste your code, then click that same button that will now be called ‘/code’

    If it too long, paste it somewhere else like pastebin or github and just put a link.


    chuyqwerty
    Participant

    @chuyqwerty

    Ok thanks for the explanation. I guess it was too long so it was not going through.

    Here is my looptopics.php code. I got the filtering to work correctly, except a big problem is that it ignores sticky posts. It does not even grab the sticky css class so I definitely did something wrong.

    http://pastebin.com/u4Ci0kYK

    Thanks for the help


    chuyqwerty
    Participant

    @chuyqwerty

    @casiepa, just wondering if you had a chance to look at my code.

    Thanks

    I had a quick look and it seems nice, but had no time yet to understand your sticky issue. I might only find time during next weekend, sorry.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Skip to toolbar