그누보드

lib.php( latest_multi) 그누보드 최신글 게시판여러개 합쳐 불러오기

헤롱헤롱이 2020. 5. 28. 09:58










 


function latest_multi($skin_dir='', $bo_table_multy, $rows=10, $subject_len=40,$options=array())
{
    global $g5;
      
      $findMulti = stripos($bo_table_multy,"|");
      if($findMulti){
            $tableExp = explode("|", $bo_table_multy);
      }
    if (!$skin_dir) $skin_dir = 'basic';
    if(preg_match('#^theme/(.+)$#', $skin_dir, $match)) {
        if (G5_IS_MOBILE) {
            $latest_skin_path = G5_THEME_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
            if(!is_dir($latest_skin_path))
                $latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
            $latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path);
        } else {
            $latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
            $latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path);
        }
        $skin_dir = $match[1];
    } else {
        if(G5_IS_MOBILE) {
            $latest_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;
            $latest_skin_url  = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;
        } else {
            $latest_skin_path = G5_SKIN_PATH.'/latest/'.$skin_dir;
            $latest_skin_url  = G5_SKIN_URL.'/latest/'.$skin_dir;
        }
    }
      $sql_select = "  ";
      
      if($bo_table_multy){
          $bo_array = explode("|",$bo_table_multy);
      }else{
          $bo_array = explode("|",$bo_table);
      }
      
      $sWhere = "";
      if($options)
      {
          $sWhere = " WHERE ". $options["where"];
      }
      
      for($i=0; $i<count($bo_array); $i++){
          if($i==0){
              $union = "(SELECT `wr_id`, `wr_subject`, `wr_datetime`, '{$bo_array[$i]}' as 'bo_table', `wr_1`, `wr_2`, `wr_num`, `wr_reply` FROM `g5_write_{$bo_array[$i]}` {$sWhere} order by `bo_table`,`wr_num`,`wr_reply` LIMIT 0, 6)";
          }else{
              $union .= "UNION ALL (SELECT `wr_id`, `wr_subject`, `wr_datetime`, '{$bo_array[$i]}' as 'bo_table', `wr_1`, `wr_2`, `wr_num`, `wr_reply` FROM `g5_write_{$bo_array[$i]}` {$sWhere} order by `bo_table`,`wr_num`,`wr_reply` LIMIT 0, 6)";
          }
      }
      $union .=" order by `bo_table`,`wr_num`,`wr_reply` LIMIT 0,{$rows};";
      
      $aa = sql_query($union);
      
      $i=0;
      
      $list = array();
      
      foreach($bo_array as $key => $val)
      {
          $list[$val] = "";
      }
      
      while($aabb = sql_fetch_array($aa)){
         
          $list[$aabb['bo_table']][$i]['wr_id'] = $aabb['wr_id'];
          $list[$aabb['bo_table']][$i]['subject'] = $aabb['wr_subject'];
          $list[$aabb['bo_table']][$i]['wr_subject'] = $aabb['wr_subject'];
          $list[$aabb['bo_table']][$i]['bo_table'] = $aabb['bo_table'];
          $list[$aabb['bo_table']][$i]['wr_1'] = $aabb['wr_1'];
          $list[$aabb['bo_table']][$i]['wr_2'] = $aabb['wr_2'];
         
         
          $list[$aabb['bo_table']][$i]['href'] = G5_BBS_URL.'/board.php?bo_table='.$aabb['bo_table'].'&amp;wr_id='.$aabb['wr_id'];
         
          $tmpName = sql_fetch(" SELECT * FROM g5_board WHERE bo_table = '{$aabb['bo_table']}' ");
          $list[$aabb['bo_table']][$i]['ca_name'] = $tmpName["bo_subject"];
          $i++;
      }
      
      ob_start();
    include $latest_skin_path.'/latest.skin.php';
    $content = ob_get_contents();
      ob_end_clean();
      return $content;
}


skin.php

<ul class="als-wrapper">
                  <?php
                  foreach($list as $key => $val)
                  {
                     
                      foreach($list[$key] as $subKey => $subVal)
                      {
                          $thumb = get_list_thumbnail($subVal['bo_table'], $subVal['wr_id'], 300,200);
                  ?>
                  <li class="als-item" onclick="location.href='<?php echo $subVal['href'] ?>';">
                  <div style="background:#f6f6f6;">
                        <div class="imgArea">
                        <?php if($thumb['src']) : ?>
                              <img src="<?php echo $thumb['src']; ?>">
                        <?php endif; ?>
                        </div>
                        <div class="malrang0"><?php echo $subVal['subject'] ?></div>
                  <div class="malrang_re" ><?php echo $subVal['wr_1'] ?></div>
                  </div>
                  
                  <div class="malrang" style="width:300px; ">
                  <p style=" overflow: hidden;text-overflow: ellipsis; white-space: normal;width: 270px;height: 200px;"><?php echo $subVal['wr_2'] ?></p></div>
                  </li>
                  <?php
                      }
                  }
                  ?>
                  
            </ul>