웹마스터 팁


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

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


 필요하신 분은 쓰세요.


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


{@$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> 부분을 활용하시길^^;

 

제목 글쓴이 날짜
XE이전 작업순서 elancer 2019.03.28
[도로명주소 krzip] 1.7.4 이전 버전들에 이용하기 [3] XE플스 2014.02.06
호스팅 변경이나 이전시 썸네일 문제 점검사항 맥노턴 2016.03.07
XE 서버 이전할 때 통채로 압축해서 옮기는 완벽한 방법-로그인, 첨부파일문제 해결 [5] 웰빙샵 지영 2009.09.15
XE 1.5 이상으로 DB 이전시 일부 DB가 빠질 경우 - 내용추가(0203) [7] sejin7940 2012.02.02
300기가 Zboard4->XE 이전기 [14] file forest535 2015.02.13
데이타 이전 시 xml 파일 임포트 속도 높이기 ^^ forest535 2015.02.17
제로보드4에서 xe로 이전시 갤러리 게시판 이미지 깨어지는 현상 해결방법 [2] 최르토스 2012.04.22
이전글, 다음글 코어 건드리지 않고 사용하기 (모듈X, 애드온X) (업데이트) [8] 시니시즘 2013.01.26
데이터 이전 후 list_order 조정 [1] wooildang 2013.04.07
이전/다음 글버튼 출력 애드온의 버튼을 사이트 밖으로 빼봅시다..^^ [5] file 착한악마 2014.04.03
[팁 시리즈 1] 웹 사이트 이전 및 복구/백업(이)가 되지 않습니다! [6] Omega3 2014.02.28
그누보드 > XE 이전툴 이용하여 이전하는 방법 [4] 개터리 2013.04.26
MyISAM --> InnoBD 이전시 문제점 및 고려사항(엔진 교체) [8] 좋은아빠되기 2013.07.24
apm7 -> ubuntu 아파치 서버이전후 http500 에러가 날때 [1] sweetchip_ 2012.12.26
이전글, 다음글 얻기 [25] 라르게덴 2008.05.29
Zbxe 서버 이전하기 [4] 팔공산 2007.08.22
그누보드 데이터를 XE 로 이전하는 컨버터 입니다. [2] file joyhmbc 2012.04.27
제로보드4 에서 xe 1.5 버전설치후 xml 파일 이전시 파일 누락되는 현상해결 [4] 때린데 또때려 2012.03.24
XE를 다른 호스팅업체로 이전하기 (서버이전) [8] file Gekkou 2010.02.03