별점 댓글 기능을 메인에 추출할수가없나요 ?
본문
<?php
include './_common.php';
$sql = "select cf_st_config from `{$g5['config_table']}`";
$tmp = sql_fetch($sql);
$st_config = unserialize($tmp['cf_st_config']);
if($ref_table == '') exit;
if($ref_id == '') exit;
$TN = 'tl_star';
$sql_common = " from {$TN} ";
$sql_search = " where ref_table='{$ref_table}' and ref_id='{$ref_id}' and st_show=1 ";
if (!$sst) {
$sst = "st_id";
$sod = "desc";
}
$sql_order = " order by {$sst} {$sod} ";
$sql = " select count(*) as cnt
{$sql_common}
{$sql_search} ";
$row = sql_fetch($sql);
$total_count = $row['cnt'];
$rows = $st_config['st_page_rows'];
$total_page = ceil($total_count / $rows); // 전체 페이지 계산
if ($page < 1) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함
$sql = " select *
{$sql_common}
{$sql_search}
{$sql_order}
limit {$from_record}, {$rows} ";
$result = sql_query($sql);
?>
<ul>
<?php
while($row = sql_fetch_array($result)) {
$st_date = substr($row['st_datetime'],0,10);
if($st_date == date('Y-m-d')) $st_date = substr($row['st_datetime'],11,5);
?>
<li>
<div class="point">
<span class="star-point-bg">
<i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i>
<div class="star-point" style="width:<?php echo ($row['st_point']*10).'%'?>;">
<span class="star-point-fg">
<i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i>
</span>
</div>
</span>
<span class="point-str"><?php echo $row['st_point'];?></span>
</div>
<div class="memo"><?php echo get_text($row['st_memo'],1)?></div>
<div class="name"><?php echo $row['st_name'] ?>
<?php if($row['mb_id'] == $member['mb_id'] || $is_admin) { ?>
<button class="btn_del" data-st_id="<?php echo $row['st_id']; ?>" type="button" style="font-family:dotum;"><i class="fa fa-trash"></i></button>
<?php } ?>
<div class="st_date"><i class="fa fa-clock-o" aria-hidden="true"></i> <?php echo $st_date; ?></div>
<?php if($is_admin) { ?>
<div class="st_ip"><?php echo $row['st_ip']; ?></div>
<?php } ?>
</div>
</li>
<?php
}
?>
</ul>
<?php echo get_paging(G5_IS_MOBILE ? $st_config['st_mobile_pages'] : $st_config['st_write_pages'], $page, $total_page, "javascript:st_list(",")"); ?>
<?php echo get_text($row['st_memo'],1)?>
<?php echo $row['st_name'] ?>
<?php echo $st_date; ?>
이부분을 메인에다가 추출할수가없나요 ?
답변 2
별점플러그인은 추가로 제작된 부분이라,
메인에 추출하는 부분은 따로 제작해야 합니다.
어떤 방식으로 메인 추출을 할지에 따라 달라질 것 같네요.
좀더 구체적으로 질문해주시고,
직접 안되시면 제작의뢰 하셔야 할듯 하네요..^^;;
정확히 무슨 기능을 사용하시려는지는 모르겠지만 저 위의 코드를 전부 메인에 붙여넣었을 때 오류가 나나요? 꼼꼼하게 보진 않았지만 원래 코드에 오류가 나지 않았다면 마찬가지로 사용이 가능할 것 같은데요. 메인에 넣으시고 html 부분만 적당하게 메인에 맞게 수정해주시면 될 것 같습니다.
$ref_table, $ref_id가 common.php 또는 다른 extend에서 정의가 된게 아니라면
if($ref_table == '') exit;
if($ref_id == '') exit;
위에 $ref_table, $ref_id만 정의해주시면 될 것 같네요.