Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to add a view counter to forums-loop??

  • @vegasparty607

    Participant

    I want to add another cell to the forums loop that displays the views that the topic has.

    How do I do this? Is this possible?

Viewing 10 replies - 1 through 10 (of 10 total)
  • @vegasparty607

    Participant

    bump

    @vegasparty607

    Participant

    bump

    @r-a-y

    Keymaster

    You need to port over a bbPress plugin and make it compatible with BuddyPress:
    https://bbpress.org/plugins/topic/bb-topic-views/

    @vegasparty607

    Participant

    How do I do that? I’m not a programmer at all

    @r-a-y

    Keymaster

    You can’t if you’re not familiar with code, as it takes some time getting used to how the plugin developer wrote the code to begin with and how to make it fit within BuddyPress.

    @gunju2221

    Participant

    @jillian, found the little snippet in the plugin from bbpress and attempted to implement it for you, experimenting myself: @r-a-y, help me on any corrections:

    `// update meta
    $value = get_site_option($bp->current_component”_topic_views_”.$topic);
    add_site_option($bp->current_component”_topic_views_”.$topic, $value+1);`

    Than the function added:

    `function bp_the_topic_view_count($topic_id = false, $echo = true) {
    global $action_variables;
    global $bp;
    global $forum_template;

    if($topic_id == false)
    $views = get_site_option($bp->current_component”_topic_views_”.$forum_template->topic->topic_id);
    else
    $views = get_site_option($bp->current_component”_topic_views_”.$topic_id);

    if(!$views)
    return false;

    if($echo)
    {
    if($views == 1)
    echo apply_filters( ‘bp_the_topic_post_count’, $views.” view” );
    else
    echo apply_filters( ‘bp_the_topic_post_count’, $views.” views” );
    }else
    {
    if($views == 1)
    return apply_filters( ‘bp_the_topic_post_count’, $views.” view” );
    else
    return apply_filters( ‘bp_the_topic_post_count’, $views.” views” );

    }
    `

    Not tested.

    @gunju2221

    Participant

    Actually not from the bbpress, rather some from simple machines.

    @vegasparty607

    Participant

    im confused!

    @r-a-y

    Keymaster

    That code doesn’t look like it will work.
    Should use internal bbPress meta functions to save the count, instead of WPs.

    @vegasparty607

    Participant

    ok…. i dont know how to do that

    i’ll pay you ray for a little small project?

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘How to add a view counter to forums-loop??’ is closed to new replies.
Skip to toolbar