}
<!--@foreach($other_data as $key => $other)-->
{@
//문서번호만 배열로 저장
$others[] = $other->document_srl;
}
<!--@end-->
{@
//document 모듈의 함수를 사용하기 위해...문서번호로 새로운 문서 리스트 생성
$oOthers = getModel('document');
$other_list = $oOthers->getDocuments($others);
}
<!-- 출력 -->
<!--@foreach($other_list as $key => $other)-->
{$other->getTitle()}
<!--@end-->
댓글 8
SELECT * FROM xe_documents WHERE (모듈번호, 검색조건, 공개여부 등 다른 조건들) AND 정렬조건 < 현재글 ORDER BY 정렬조건 DESC LIMIT 5;
// 다음글 5개 (순서대로)
SELECT * FROM xe_documents WHERE (모듈번호, 검색조건, 공개여부 등 다른 조건들) AND 정렬조건 > 현재글 ORDER BY 정렬조건 ASC LIMIT 5;
대략 이런식으로 쿼리하시면 되는데, XML로 작성하는 것은 숙제...
정렬조건은 어떤 컬럼을 쓰시느냐에 따라 ASC, DESC, 부등호의 방향 등을 뒤집어야 할 수도 있습니다.
알려주신 방법으로 xml 쿼리 작성했습니다.
혹시나 해서 xml 코드도 같이 올립니다. document 모듈에서 게시글 불러오는 걸 카피했습니다..ㅋㅋ(document_list)
줄강조한 부분이 추가된 부분입니다.
<tables>
<table name="documents" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
<condition operation="in" column="module_srl" var="module_srl" filter="number" />
<condition operation="notin" column="module_srl" var="exclude_module_srl" filter="number" pipe="and" />
<condition operation="in" column="category_srl" var="category_srl" pipe="and" />
<condition operation="equal" column="is_notice" var="s_is_notice" pipe="and" />
<condition operation="equal" column="member_srl" var="member_srl" filter="number" pipe="and" />
<condition operation="in" column="status" var="statusList" pipe="and" />
<group pipe="and">
<condition operation="more" column="list_order" var="division" pipe="and" />
<condition operation="below" column="list_order" var="last_division" pipe="and" />
</group>
<group pipe="and">
<condition operation="like" column="title" var="s_title" />
<condition operation="like" column="content" var="s_content" pipe="or" />
<condition operation="like" column="user_name" var="s_user_name" pipe="or" />
<condition operation="like" column="user_id" var="s_user_id" pipe="or" />
<condition operation="like" column="nick_name" var="s_nick_name" pipe="or" />
<condition operation="like" column="email_address" var="s_email_address" pipe="or" />
<condition operation="like" column="homepage" var="s_homepage" pipe="or" />
<condition operation="like" column="tags" var="s_tags" pipe="or" />
<condition operation="equal" column="member_srl" var="s_member_srl" pipe="or" />
<condition operation="more" column="readed_count" var="s_readed_count" pipe="or" />
<condition operation="more" column="voted_count" var="s_voted_count" pipe="or" />
<condition operation="less" column="blamed_count" var="s_blamed_count" pipe="or" />
<condition operation="more" column="comment_count" var="s_comment_count" pipe="or" />
<condition operation="more" column="trackback_count" var="s_trackback_count" pipe="or" />
<condition operation="more" column="uploaded_count" var="s_uploaded_count" pipe="or" />
<condition operation="like_prefix" column="regdate" var="s_regdate" pipe="or" />
<condition operation="like_prefix" column="last_update" var="s_last_update" pipe="or" />
<condition operation="like_prefix" column="ipaddress" var="s_ipaddress" pipe="or" />
</group>
<group pipe="and">
<condition operation="more" column="last_update" var="start_date" pipe="and" />
<condition operation="less" column="last_update" var="end_date" pipe="and" />
</group>
<group pipe="and">
<condition operation="less" column="document_srl" var="prev_document_srl" pipe="and" />
<condition operation="excess" column="document_srl" var="next_document_srl" pipe="and" />
</group>
</conditions>
<navigation>
<index var="sort_index" default="list_order" order="order_type" />
<list_count var="list_count" default="5" />
<page_count var="page_count" default="1" />
<page var="page" default="1" />
</navigation>
</query>
직접 써보면서 테스트해 보세요. order_type을 이리저리 바꿔봐야 할 거예요.
실제로 작동합니다...ㅋㅋ ( 위의 xml은 디폴트 값이고.. 실제 사용시 오더값을 정해줘서..)
코드는 이러 합니다. ( 게시판 스킨에서 삽입해서 템플릿 문법입니다.)
$args = new stdClass;
$args->next_document_srl = $document_srl;
$args->order_type = 'asc';
$args->list_count = 3;
$other_next = executeQuery('board.getDocumentOtherList', $args);
unset($args->next_document_srl);
$next_list_count = abs(count($other_next->data) - $args->list_count);
$args->list_count = 5 + $next_list_count;
$args->prev_document_srl = $document_srl;
$other_prev = executeQuery('board.getDocumentOtherList', $args);
//2개의 리스트를 합침
$other_data = array_merge($other_next->data, $other_prev->data);
}
<!--@foreach($other_data as $key => $other)-->
{@
//문서번호만 배열로 저장
$others[] = $other->document_srl;
}
<!--@end-->
{@
//document 모듈의 함수를 사용하기 위해...문서번호로 새로운 문서 리스트 생성
$oOthers = getModel('document');
$other_list = $oOthers->getDocuments($others);
}
<!-- 출력 -->
<!--@foreach($other_list as $key => $other)-->
{$other->getTitle()}
<!--@end-->
}
2개를 하나로 합칠 수 있겠군요..-_-;;; 일단 귀찮은 관계로.. .일단은 내비둘 생각입니다.. 나중에 혹시 속도 문제라든지 있으면.. 그 때 대응하기로...(허윽)
속도 문제가 있다면 그냥 캐싱을 하셔야... ㅎㅎ
감사합니다.