About this topic

  • Posted by COWIS 1 year ago. There are 2 posts. The latest reply is from byron.
  • This topic is not resolved
  1. Hi
    I am using wordpress MU (Network) with Buddypress and would like to assign the gallery to a group instead of a post. Is this possible?
    Regards
    Jacob

  2. Hi COWIS,

    I really don't know how you would do that. I haven't used MU or Buddypress, so I'm not familiar with their functions.

    If you can make you way around PHP, you can probably make it work if you can figure out what the Group ID is on the page you want to show the gallery on. What you'd need to do (and I'm just guessing here) is:

    1) Figure out what Group ID you're working with
    2) Figure out which gallery is related to it...you could do this by creating a Custom field using PhotoSmash's Custom Field editor and call it group_id. Then you can set the Group ID on one of your images from that Gallery in Photo Manager (there a section in each image for editing the custom fields). Then you'd need a little SQL. You could put it into a function like:

    function getGalleryIDForGroup($group_id){
    
    global $wpdb;
    if( (int)$group_id ){
    $gallery_id = $wpdb->get_var("SELECT b.gallery_id FROM " . PSCUSTOMDATATABLE . " a JOIN "
    . PSIMAGESTABLE . " b ON a.image_id = b.image_id WHERE a.group_id = " . (int)$group_id );
    }
    
    return $gallery_id;
    
    }

    You should stick that function in your theme's functions.php file.

    Next, in your theme's file where you want to show the gallery, you'd do something like:

    <php
    $group_id = << I have no idea how you get that, but there's probably a variable or something >>;
    
    if( (int)$group_id ){
    $gallery_id = getGalleryIDForGroup($group_id);
    
    if( (int)$gallery_id ){
    echo do_shortcode("[photosmash id=" . (int)$gallery_id . "]");
    }
    
    }

    There could be bugs in what I've just posted, since that's off the top of my head and I didn't test.

    Cheers,
    Byron

RSS feed for this topic