joeey1984ad / buddypress-media

Automatically exported from code.google.com/p/buddypress-media
0 stars 0 forks source link

There is no clean way to show all images on site (in sidebar) when on a picture page #73

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
On my site, I want to display all album images site-wide. This works great when 
i'm on most pages, however when I'm on an album view or single view the current 
user's image displays in this sidebar rather than all images. 

I tracked down the issue to be the bp_album_default_query_args() sets the id if 
the current action matchs $bp->album->single_slug.

My horrible hack is to reset $bp->current_action while the script processes 
then set it back. ugh. 

perhaps you need another core function called bp_album_get_all_pictures() or 
perhaps you should not be called the defaults so many times (for example in 
query_pictures(), because you already call it in BP_Album_Template() I could be 
wrong here though). 

here is my hacky code to get all images to display in the sidebar, please let 
me know if there is a cleaner way to do this:

    <?php 
    global $bp; 
    // beware horrible hack...
    $save_current_action = $bp->current_action; 
    $bp->current_action = 'hack-to-show-all-albums';
    bp_album_query_pictures( array( 'owner_id'=> '', 'page'=>1, 'max'=>9 ,'privacy'=>'public' ,'per_page'=> 9 ,'ordersort'=>'DESC' ,'orderkey'=>'id' ) );
    $bp->current_action = $save_current_action; 
    ?>

    <?php if ( bp_album_has_pictures() ) : while ( bp_album_has_pictures() ) : bp_album_the_picture(); ?>
        <a href="<?php bp_album_picture_url() ?>"><img src="<?php bp_album_picture_thumb_url() ?>" /></a>
    <?php endwhile;  endif; ?>

Original issue reported on code.google.com by dwen...@yahoo.com on 28 Mar 2011 at 4:34

GoogleCodeExporter commented 9 years ago
I forgot to say... Thank you so much for this awesome, well written, clean 
plugin!

Original comment by dwen...@yahoo.com on 28 Mar 2011 at 4:59

GoogleCodeExporter commented 9 years ago
Hey, this is working fine.
Thanks for the snippet!

Original comment by Vladimir...@gmail.com on 8 Apr 2011 at 5:00