2012-04-17 2 views
0

buddypress 테마 [buddyboss] (http://buddyboss.com/)를 사용하고 있습니다. 주된 이유는이 테마가 그림 갤러리 (위대한 작품)를 관리 할 수 ​​있다는 것이 었습니다.buddypress 테마 (wordpress)에서 기능을 변경해야합니다.

이제 member-loop 내에서 picture-function을 호출하려고합니다.

는 "당신이 buddy_boss_pics.php에서 기능을해야합니다 특히 당신이 줄에서 시작) 기능 buddyboss_pics_screen_picture_grid_content을 (사용해야합니다 다음 buddyboss - 관리자 중 하나가 나에게 말했다. 당신은 작업 파일을 편집해야합니다 285 현재는 displayed_user_id를 사용하고 있기 때문에 members-loop를 사용합니다. "

이 함수가 모습입니다 : 나는 정말 그것을 할 필요가 있기 때문에

function buddyboss_pics_screen_picture_grid_content() 
{ 
    global $bp, $wpdb, $bbpics; 

    $wpdb->show_errors = BUDDY_BOSS_DEBUG; 

    $img_size = is_active_sidebar('Profile') ? 'buddyboss_pic_med' : 'buddyboss_pic_wide'; 

    $gallery_class = is_active_sidebar('Profile') ? 'gallery has-sidebar' : 'gallery'; 

    $user_id = $bp->displayed_user->id; 
    $activity_table = $wpdb->prefix."bp_activity"; 
    $activity_meta_table = $wpdb->prefix."bp_activity_meta"; 

    $pages_sql = "SELECT COUNT(*) FROM $activity_table a INNER JOIN $activity_meta_table am ON a.id = am.activity_id WHERE a.user_id = $user_id AND meta_key = 'bboss_pics_aid'"; 

    $bbpics->grid_num_pics = $wpdb->get_var($pages_sql); 

    $bbpics->grid_current_page = isset($_GET['page']) ? (int) $_GET['page'] : 1; 

    // Prepare a SQL query to retrieve the activity posts 
    // that have pictures associated with them 
    $sql = "SELECT a.*, am.meta_value FROM $activity_table a INNER JOIN $activity_meta_table am ON a.id = am.activity_id WHERE a.user_id = $user_id AND meta_key = 'bboss_pics_aid' ORDER BY a.date_recorded DESC"; 

    buddy_boss_log("SQL: $sql"); 

    $pics = $wpdb->get_results($sql,ARRAY_A); 

    $bbpics->grid_pagination = new BuddyBoss_Paginated($pics, $bbpics->grid_pics_per_page, $bbpics->grid_current_page); 

    buddy_boss_log("RESULT: $pics"); 

    // If we have results let's print out a simple grid 
    if (!empty($pics)) 
    { 
     $bbpics->grid_had_pics = true; 
     $bbpics->grid_num_pics = count($pics); 

어떤 도움이 좋을 것!

+0

당신은 http://wordpress.stackexchange.com/에 대한 답변을 얻을 수 있습니다. – fuxia

답변

0

Untested-하지만이 시도 :

회원 루프에서

, 가까운 PHP 태그>

   buddyboss_pics_members_loop(bp_get_member_user_id()); 

복사 buddyboss_pics_screen_picture_grid_content() 함수 전에이 추가

   <?php 
      /*** 
       * If you want to show specific profile fields here you can, 
       * but it'll add an extra query for each member in the loop 
       * (only one regadless of the number of fields you show): 
       * 
       * bp_member_profile_data('field=the field name'); 
       */ 
      ?> 

를 찾아 members-loop 맨 아래로.

는 PHP 태그 사이에 넣고 buddyboss_pics_members_loop ($의 USER_ID)

로 이름을 변경하고 주석 또는 $ USER_ID = $ BP-> displayed_user-> ID를 삭제;

+0

안녕하세요 .. 설명이 매우 명확하지만 작동하지 않습니다!?!? 문제는 그림 그리드가 나타나지 않고 대신 다른 모든 사용자가 사라진다는 것입니다 ... 젠장 –

+0

두 개의 예제 파일을 업로드했습니다. 어쩌면 저에게 올바른 방법을 보여줄 수 있습니다 ... http : // ge.tt/3uWNXYG/v/0?c –

0

여기 buddyboss_pics_screen_picture_grid_content() 함수는 주로 user_id를 사용하여 데이터베이스에서 이미지를 가져옵니다.

간단한 당신은 회원-loop.php 파일에 while 루프 내에서 함수를 호출 한 : buddyboss_pics_screen_picture_grid_content(bp_member_user_id())

다음은이 함수의 매개 변수 member_user_id를 전달합니다.

리틀 편집 아래의 주요 buddyboss_pics_screen_picture_grid_content() 기능 : 변경 다음은

는 :

function buddyboss_pics_screen_picture_grid_content($user_id = null) 
{ 

    //Remove this code 
    $user_id = $bp->displayed_user->id; 

    //Put new Code 
    if (empty($user_id)) { 
     $user_id = $bp->displayed_user->id; 
    } else { 
     $user_id = $user_id; 
    } 

}