bbPress

Simple, fast, elegant

bbPress Plugin Browser »

bb Topic Views (1.6.4)

Configuration

Function calls:

most_viewed_list (parameters)  
    Parameters accepted:
    $list_length (default is 10), $before_list (default is "<ul>"), $after_list (default is "</ul>"), $before_item (default
    is "<li>"), $after_item = "</li>")

    Use this function anywhere you want to show a list of your most viewed topics.

most_viewed_table (parameters)
    Parameters accepted:
    $list_length (default is 10)

    Use this function on the front/forum/tags pages to insert a table of your most-viewed posts.  Again, if you are not
    using the default theme you may have to make some changes to the styling of the table.

show_view_count ()
    If used in a "topic loop," this function will display the number of times a topic has been viewed.

To add a view count column to front page, forum, and/or tags page tables, make the following modifications. Note: these apply to the default Kakumei theme. If you are using a different theme, or a highly modified version of the default, your modifications may be slightly different.

1.  Open bb-topic-views.php and change $append_to_title to zero.  This will prevent the view count from
being appended to the end of the topic title.
2.  Open front-page.php.  Find <table id="latest"> (around line 21).  Replace everything between this opening
tag and </table> (around line 46) with the following:


<table id="latest">
<tr>
    <th><?php _e('Topic'); ?> — <?php new_topic(); ?></th>
    <th><?php _e('Views'); ?></th>
    <th><?php _e('Posts'); ?></th>
    <th><?php _e('Last Poster'); ?></th>
    <th><?php _e('Freshness'); ?></th>
</tr>


<?php if ( $super_stickies ) : foreach ( $super_stickies as $topic ) : ?>
<tr<?php topic_class(); ?>>
    <td><?php _e('Sticky:'); ?> <big><a href="<?php topic_link(); ?>"><?php topic_title(); ?></a></big></td>
    <td class="num"><?php show_view_count(); ?></td>
    <td class="num"><?php topic_posts(); ?></td>
    <td class="num"><?php topic_last_poster(); ?></td>
    <td class="num"><small><?php topic_time(); ?></small></td>
</tr>
<?php endforeach; endif; ?>


<?php if ( $topics ) : foreach ( $topics as $topic ) : ?>
<tr<?php topic_class(); ?>>
    <td><a href="<?php topic_link(); ?>"><?php topic_title(); ?></a></td>
    <td class="num"><?php show_view_count(); ?></td>
    <td class="num"><?php topic_posts(); ?></td>
    <td class="num"><?php topic_last_poster(); ?></td>
    <td class="num"><small><?php topic_time(); ?></small></td>
</tr>
<?php endforeach; endif; ?>
</table>
  1. Open forum.php and make the same changes.
  2. Open tag-single.php. Find the opening and closing tags (around line 11 and line 27) and replace everything between them with the following:

    — > ">
  3. You can rearrange the order of the columns if you'd like, just make sure you get them in the right order for each section.

Example

You can see this plugin in action at http://blog.wittmania.com/bbpress or http://bbshowcase.org/forums/

Code is Poetry.