Skip to:
Content
Pages
Categories
Search
Top
Bottom

Is there a template tag that counts, for making an unique ID

  • This is my forum layout.

    <div id="wrapper">

    <header> header stuff </header>

    <div id=”content”>

    <aside> Topic of Forum info (like a sidebar) </aside>

    <section>

    <header><h1>Topic title</h1></header>

    <hgroup class=”reply-ID” id=”-1″> reply author stuff </hgroup>

    <article class=”reply-ID” id=”-1″> reply content </article>

    <hgroup class=”reply-ID” id=”-2″> reply author stuff </hgroup>

    <article class=”reply-ID” id=”-2″> reply content </article>

    <–! repeats of the above code –>

    </section>

    </div><!– end #content –>

    <footer> footer stuff </footer>

    </div><!– end #wrapper –>

    It would be very helpful to have an (extra) counter on my first <hgroup> and <article> pair of tags. This way i could only style the starting topic content and make it stand out, because the first author always-/most of the time has a question and i would like to make it stand out more from the other replies.

    I don’t want a topic or forum ID because those are too unique.

    I need something that starts counting by Zero or One on every new topic like a Reply counter 1, 2, 3, 4, 5, I could add them to an ID or Class (shown above) to make it unique.

    Something like a WP-comments counter.

Viewing 6 replies - 1 through 6 (of 6 total)

  • Anointed
    Moderator

    @anointed

    Just taking a shot at this:

    I am guessing that you are talking about the single-topic page which displays the first topic followed by all the replies.

    If this is the case:

    Add the following line to your functions.php file

    add_filter( 'bbp_show_lead_topic', '__return_true' );

    What this is going to do is separate out the lead topic from all the replies. It creates a great separation where you can then style the first topic completely different than the replies. Pretty cool actually.

    *Make sure to use the default theme to see this in action. You don’t have any of the needed logic in your code above, so your code wont output the separation. You can find the needed logic in the template files.

    This is a lot more elegant than counters and it’s built in.

    Hope it helps. (there are tons of cool hidden ‘secrets’ like this within the code, thnx JJ!)


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    I am pretty sure there is a function for getting the reply position. If not, one can be created using code from the bbp_get_reply_url() function as an example.

    WOW!

    This is a stunning feature!

    I like all those little sexy features, it can make your forum stand out and become a little eye-catcher.

    Thank you so much for this.

    Btw: someone should make a blog (category) about all those kinda features, i think lots of people would love to do this.

    @JJJ

    :) Yeah i see it now you said so, <?php bbp_reply_postion(); ?> does the numbering


    Anointed
    Moderator

    @anointed

    :)

    Yeah I have been finding tons of hidden gems in the plugin.

    I suck at documentation. I’m hoping that someone will come along and help out with that part someday. JJ is crazy busy and I find it hard to spend more than an hr a day here. There are some great support people here, and I believe that now the plugin is released that more people will jump in and help out.

    Just a little update:

    Is there also a way to say ‘import lead template only once at the first page’ ??

    Now i have made this function work and it’s great it sticks the first post into a lead template so i can style it different but when the single-topic template goes over lets say 25 replies and to the 2nd or 3rd page it will again stick this first lead template to the top.

    That can be a little bit frustrated for users i think, jumping to the 2nd page and have the topic authors post at the top of the 2nd page again.


    Anointed
    Moderator

    @anointed

    wrap the initial topic function output in something like the following:

    if ( ! isset ( $GLOBALS['paged'] ) or ( $GLOBALS['paged'] < 2 ) )
    {
    // run your code
    }

    says if not paged, then run code…

Viewing 6 replies - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.