웹마스터 팁


 라르게덴님의 이전글, 다음글 가져오는 소스를 봤는데 제가 코어를 건드리는걸 별로 안좋아해서

 그냥 제 방식대로 게시판 스킨에서 바로 쓸 수 있게 만들어봤습니다.


 필요하신 분은 쓰세요.


 * 발코딩이므로 코드해석하려고 하시면 정신건강에 해로우니 해석하려고 하지마세요.


{@$doc_count = count($document_list)}
	{@$z=0}
	<!--@foreach($document_list as $no => $document)-->
		{@ $doc_srl[$z] = $document->document_srl}
		<!--@if($document->document_srl == $oDocument->document_srl)-->
			{@ $now_z = $z }
		<!--@end-->
		{@$z++;}
	<!--@end-->

	<!--@if($now_z == 0 && $page > 1)-->

		{@
			$oModuleModel = &getModel('module');
			$module_srl_temp = $oModuleModel->getModuleSrlByMid($mid);

			if(is_array($module_srl_temp)) $module_srl = $module_srl_temp[0];
			else $module_srl = $module_srl_temp;

			$args->module_srl = $module_srl;
			$args->category_srl = $category_srl;
			$args->list_count = $module_info->list_count;
			$args->search_target = $search_target;
			$args->search_keyword = $search_keyword;
			$args->page = $page-1;
			$args->sort_index = $module_info->sort_index;
			$args->order_type = $module_info->order_type;

			$docList_output = executeQueryArray('document.getDocumentList', $args);
		}

		{@$x=0}
		<!--@foreach($docList_output->data as $doc)-->
			<!--@if($x == count($docList_output->data) - 1)-->
				{@ $beforeDoc = $doc->document_srl }
			<!--@end-->
			{@$x++;}
		<!--@end-->

		{@ $afterDoc = $doc_srl[$now_z+1] }

	<!--@else if($now_z == $doc_count - 1 && $page < $total_page)-->

		{@
			$oModuleModel = &getModel('module');
			$module_srl_temp = $oModuleModel->getModuleSrlByMid($mid);

			if(is_array($module_srl_temp)) $module_srl = $module_srl_temp[0];
			else $module_srl = $module_srl_temp;

			$args->module_srl = $module_srl;
			$args->category_srl = $category_srl;
			$args->list_count = $module_info->list_count;
			$args->search_target = $search_target;
			$args->search_keyword = $search_keyword;
			$args->page = $page+1;
			$args->sort_index = $module_info->sort_index;
			$args->order_type = $module_info->order_type;

			$docList_output = executeQueryArray('document.getDocumentList', $args);
		}

		{@$x=0}
		<!--@foreach($docList_output->data as $doc)-->
			<!--@if($x == 0)-->
				{@ $afterDoc = $doc->document_srl }
			<!--@end-->
			{@$x++;}
		<!--@end-->

		{@ $beforeDoc = $doc_srl[$now_z-1] }

	<!--@else-->

		{@ $beforeDoc = $doc_srl[$now_z-1]; $afterDoc = $doc_srl[$now_z+1]; }

	<!--@end-->

	<!--@if(!$beforeDoc)-->
		{@ $beforeDoc = $oDocument->document_srl }
	<!--@else if(!$afterDoc)-->
		{@ $afterDoc = $oDocument->document_srl }
	<!--@end-->



<a href="{getUrl('document_srl',$beforeDoc,'listStyle',$listStyle, 'cpage','', 'page', '')}">이전글</a>
<a href="{getUrl('document_srl',$afterDoc,'listStyle',$listStyle, 'cpage','', 'page', '')}">다음글</a>


$beforeDoc은 이전글

$afterDoc은 다음글

사용하실려면 윗처럼 getUrl 에서 page 값을 빈값('')처리 해줘야 합니다.




14.07.15

팁을 올리고 나서 생각보다 반응이 좋아서 코드를 약간 업데이트 해서 다시 올립니다. 참고 하시라고 주석도 조금 달아봤습니다.

많은 도움이 됬으면 합니다!


<!-- 이전글, 다음글 구하기 : s -->
{@$doc_count = count($document_list)}
{@$z=0}
<!--@foreach($document_list as $no => $document)-->
	{@ $doc_srl[$z] = $document->document_srl}
	<!--@if($document->document_srl == $oDocument->document_srl)-->
		{@ $now_z = $z }
	<!--@end-->
	{@$z++;}
<!--@end-->

<!-- 현재 글이 현제 페이지에서 첫번째 글이며, 현재 페이지가 1이 아닐 때 -->
<!-- 이전 페이지의 document_list를 가져와서 마지막 글의 document_srl을 구한다 -->
<!--@if($now_z == 0 && $page > 1)-->
	{@
		$oModuleModel = &getModel('module');
		$module_srl_temp = $oModuleModel->getModuleSrlByMid($mid);

		if(is_array($module_srl_temp)) $module_srl = $module_srl_temp[0];
		else $module_srl = $module_srl_temp;

		$args->module_srl = $module_srl;
		$args->category_srl = $category_srl;
		$args->list_count = $module_info->list_count;
		$args->search_target = $search_target;
		$args->search_keyword = $search_keyword;
		$args->page = $page-1;
		$args->sort_index = $module_info->sort_index;
		$args->order_type = $module_info->order_type;

		$docList_output = executeQueryArray('document.getDocumentList', $args);
	}

	{@$x=0}
	<!--@foreach($docList_output->data as $doc)-->
		<!--@if($x == count($docList_output->data) - 1)-->
			{@ $beforeDoc = $doc->document_srl }
		<!--@end-->
		{@$x++;}
	<!--@end-->
	{@ $afterDoc = $doc_srl[$now_z+1] }

<!-- 현재 글이 현제 페이지에서 가장 마지막 글이며, 현재 페이지가 마지막 페이지가 아닐 때 -->
<!-- 다음 페이지의 document_list를 가져와서 첫번째 글의 document_srl을 구한다 -->
<!--@else if($now_z == $doc_count - 1 && $page < $total_page)-->
	{@
		$oModuleModel = &getModel('module');
		$module_srl_temp = $oModuleModel->getModuleSrlByMid($mid);

		if(is_array($module_srl_temp)) $module_srl = $module_srl_temp[0];
		else $module_srl = $module_srl_temp;

		$args->module_srl = $module_srl;
		$args->category_srl = $category_srl;
		$args->list_count = $module_info->list_count;
		$args->search_target = $search_target;
		$args->search_keyword = $search_keyword;
		$args->page = $page+1;
		$args->sort_index = $module_info->sort_index;
		$args->order_type = $module_info->order_type;

		$docList_output = executeQueryArray('document.getDocumentList', $args);
	}

	{@$x=0}
	<!--@foreach($docList_output->data as $doc)-->
		<!-- 첫번째 글일 경우 -->
		<!--@if($x == 0)-->
			{@ $afterDoc = $doc->document_srl }
		<!--@end-->
		{@$x++;}
	<!--@end-->
	{@ $beforeDoc = $doc_srl[$now_z-1] }

<!-- 그 외 -->
<!--@else-->
	{@ $beforeDoc = $doc_srl[$now_z-1]; $afterDoc = $doc_srl[$now_z+1]; }
<!--@end-->

<!--@if($beforeDoc)-->
	{@ $beforeHref = getUrl('document_srl',$beforeDoc,'listStyle',$listStyle, 'cpage','', 'page', '') }
<!--@else-->
	{@ $beforeHref = "javascript:;" }
<!--@end-->

<!--@if($afterDoc)-->
	{@ $afterHref = getUrl('document_srl',$afterDoc,'listStyle',$listStyle, 'cpage','', 'page', '') }
<!--@else-->
	{@ $afterHref = "javascript:;" }
<!--@end-->

<!-- 이전글, 다음글 구하기 : e -->

<style>
	a#prevDocBtn, a#nextDocBtn { border: 1px solid green }
	a#prevDocBtn.disabled, a#nextDocBtn.disabled { border: 1px solid red; cursor: text }
</style>

<a href="{$beforeHref}" id="prevDocBtn" class="disabled"|cond="!$beforeDoc">이전글</a>
<a href="{$afterHref}" id="nextDocBtn" class="disabled"|cond="!$afterDoc">다음글</a>


이전글이 없거나 다음글이 없을 경우 자동으로 버튼이 disable 됩니다. 스타일화 하시려면 <style> 부분을 활용하시길^^;

 

제목 글쓴이 날짜
출석부 소시랑 스킨 출석회원없을때 우측위젯이 아래로 떨어지는 현상 해결방법 [3] garnecia 2013.02.23
팝업창 자동 사이즈 조절 js Alex 2013.02.17
이미디오 (이미지->동영상) 기능을 적용해보자. [8] file asterisk 2013.02.12
이전글, 다음글 코어 건드리지 않고 사용하기 (모듈X, 애드온X) (업데이트) [8] 시니시즘 2013.01.26
1.5.4 업데이트 후 글 등록 무응답 상태 발생하는 경우 [2] 멀티비타민 2013.01.13
네이버 검색 API XE하고 연동하기 [3] mindpainter 2013.01.09
모바일 페이지모듈에서 스킨 설정안 되는 버그 수정법 [2] sejin7940 2013.01.08
회원정보 수정 위해 비밀번호 재입력 후 튕기는 경우 [2] sejin7940 2013.01.06
모바일 게시판의 목록수 / 페이지수 / 검색시 목록수 등을 별도 설정할 수 있게하려면 [2] sejin7940 2012.12.30
게시판 '스킨 관리' 페이지에 저장 버튼 및 목차 추가하기 [1] file TUW 2012.12.25
XE 비회원이 귀찮게 이메일 홈페이지 입력 안하도록 하기 [7] jhrun 2012.12.16
일반게시판에서 모듈게시판 혹은 모듈게시판(에서 일반게시판예로들어 일반게시판 -> 게시판DX 혹은 그 반대)으로 게시글 이동시키는 방법 (DB에서) [1] file 장포크 2012.11.28
본문내 이미지 조절 애드온 기능 확장 - 원본이미지 모달 제거 / 작은이미지 크게 확장하기 [2] sejin7940 2012.11.25
xe에서 폼메일 구성하려는데 폼메일을 사용하려면 메일서버는 어떻게 ? 폼메일 2012.11.23
사이트 내 닉네임을 일괄 변경하기 [6] 윈컴이 2012.11.09
XE 다국어로 페이지/글 작성하기 [4] jhrun 2012.11.05
330 오류(net::ERR_CONTENT_DECODING_FAILED): 알 수 없는 오류 - 해결책 [2] 하얀마법 2012.10.25
게시판 글작성 및 댓글작성이 안될때 [2] 똑디 2012.10.18
외부로그인 (레이아웃 파일만 수정) [4] 투씨 2012.10.13
Admin 페이지에서 사이트맵 삭제가 안될 때 file FontBox 2012.10.06