Skip to:
Content
Pages
Categories
Search
Top
Bottom

get favorites list

  • Hi,

    Is there a way of getting a user’s favorites to display without on a forum page other than /profile/#/favorite ?

    I’ve looked at the code but I don’t want to dig too deeply into it as I’m sure it will change a lot during the next year.

    Basically what I want to do is create a unified profile page, which has been possible with everything except favorites.

    See http://www.surrealroad.com/forum/1 if this doesn’t make sense

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

  • Alifar
    Blocked

    @56alifar

    Has anyone figer this out?


    kevinjohngallagher
    Member

    @kevinjohngallagher

    Looking in “favourites.php”, right in the root of BBpress (so its not hidden), i found this:

    $topics = get_user_favorites( $user->ID, true );

    I’d use that and output the array, but then again, i’d not have bumped 2 different 2 year old threads, let alone doing it before looking in the file cunningly named Favourites.php ;-)


    Alifar
    Blocked

    @56alifar

    Thanks, but how can i put this in my template?


    kevinjohngallagher
    Member

    @kevinjohngallagher

    Two ways:

    1) It’s an array, so just cycle through it and output the bits you want, this will allow you to style it as you please. If you’re unsure of what it returns use: print_r($topics);

    2) Alternatively, you could just copy all 3 lines from the Favourites.php file:

    $topics = get_user_favorites( $user->ID, true );

    $favorites_total = isset($user->favorites) ? count(explode(‘,’, $user->favorites)) : 0;

    bb_load_template( ‘favorites.php’, array(‘favorites_total’) );

    This will output the favourites in the way you’ve described in your template folder.

    ==========================================

    At the end of the day, BBpress has a number of issues, but if it can already do something, all you really need to do is copy and paste the code :)


    Alifar
    Blocked

    @56alifar

    Sorry, a bit of a PHP Noob, if I insert the following code in my template:

    $topics = get_user_favorites( $user->ID, true );

    $favorites_total = isset($user->favorites) ? count(explode(‘,’, $user->favorites)) : 0;

    bb_load_template( ‘favorites.php’, array(‘favorites_total’) );

    I get an error


    kevinjohngallagher
    Member

    @kevinjohngallagher

    What error do you get mate?


    chrishajer
    Participant

    @chrishajer

    Was that snippet of code wrapped in <?php tags ?>?

    <?php
    $topics = get_user_favorites( $user->ID, true );
    $favorites_total = isset($user->favorites) ? count(explode(',', $user->favorites)) : 0;
    bb_load_template( 'favorites.php', array('favorites_total') );
    ?>


    Alifar
    Blocked

    @56alifar

    Nope didn’t work, i got the entire website loading serveral times in my sidebar where i put the following code:

    <?php

    $topics = get_user_favorites( $user->ID, true );

    $favorites_total = isset($user->favorites) ? count(explode(',', $user->favorites)) : 0;

    bb_load_template( 'favorites.php', array('favorites_total') );

    ?>


    kevinjohngallagher
    Member

    @kevinjohngallagher

    What error do you get mate?

    :)


    Alifar
    Blocked

    @56alifar

    Like i said, i got the entire website loading serveral times in my sidebar where i put the code.


    kevinjohngallagher
    Member

    @kevinjohngallagher

    The entire website?

    So it’s going in an infinte loop?

    Please, be less specific, don’t post any code, oooh and don’t include a screenshot. Guessing is a really worth while use of my time :)

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

You must be logged in to reply to this topic.