Skip to:
Content
Pages
Categories
Search
Top
Bottom

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

Viewing 10 replies - 1 through 10 (of 10 total)
  • bump

    bump


    r-a-y
    Moderator

    @r-a-y

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

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


    r-a-y
    Moderator

    @r-a-y

    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.


    Virtuali
    Participant

    @gunju2221

    @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.


    Virtuali
    Participant

    @gunju2221

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

    im confused!


    r-a-y
    Moderator

    @r-a-y

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

    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