웹마스터 팁


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

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


 필요하신 분은 쓰세요.


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


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

 

제목 글쓴이 날짜
특정 확장변수를 글 추천자에게만 보이게 하기 [10] 뮤랑이 2010.01.11
xe초보가 업데이트 하기 글로벌 2010.01.06
개인서버(윈도XP) + apmsetup6 + XE 설치하기 [1] 꽃들 2010.01.06
APM_Setup 7 사용자중에서 첨부 파일 업로드시 100%에서 사라지는 문제 [2] 레드파카 2010.01.04
widgets/member_group/스킨/스킨명/list.html 에 성별아이콘 나타내기 [2] file 늘푸른이 2010.01.03
첨부파일이 용량에 따라 등록되기도 하고 안되기도 할 때 해결방법 (웹호스팅) [1] 꽃들 2010.01.02
스패머에게 대항하라! 스팸봇 차단 방법 (검증 안됨) [1] 빛의바다 2009.12.26
1.3.1.1 에서 첫 화면 안나오시는분들 [1] 하늘03 2009.12.26
회원과 비회원 구분하여 출력하기 [6] NEARSTORY 2009.12.26
Lighttpd에서 XE를 사용할 때의 mod_rewrite 규칙 [2] 행복한고니 2009.12.23
파일 첨부 문제 해결 방법 - 여러 시도 중 하나 일 뿐입니다. 쫑아빠™ 2009.12.19
[뻘팁] XE 설치된 사이트 찾기 [3] SMaker 2009.12.18
크롬에서 이미지조절 애드온 액티브박스 lytebox mod 가 동작하지 않을때 구구치 2009.12.14
PHP 5부터, 객체는 명시적으로 새로운 것을 만드는 clone 키워드를 사용하지 않는 한 참조로 할당됩니다. [1] 난다날아 2009.12.12
첨부파일 100%에서 증발~ 문제..별짓 다해도 안되는 분..참고해보세요 [9] thejeon 2009.12.11
레이아웃에 위젯을 넣고 위젯 스타일 적용하기 [2] 김성걸310 2009.12.11
최신 댓글 보여주는 기능에 관련해 손정호547 2009.12.11
초보팁] 외부페이지에서 가져올 시 새창 띄우기 안되는거 수정하기(자바) [1] 파라테일 2009.12.10
메일 중복 발송 문제 해결 방법 [1] SMaker 2009.12.09
웹페이지 메시지 만들기 [초보자대응] [6] file cabnb 2009.12.09