모듈 프론트엔드 북마크 목록(List) 보기
BOOKMARK Module dispBookmarkList
프론트엔드 북마크 목록(List) 보기
▶ 모델(Model) 스타일
bookmark 모듈이 가지고 있는 모델(Model) 파일을 이용해 bookmarks 테이블에서 목록을 가져오기 위한 과정이다.
▶ 쿼리 스타일(executeQueryArray)
모델(Model) 파일을 사용하지 않고 executeQueryArray() 쿼리를 이용해 직접 목록을 가져올 수 있다.
1. 프론트엔드 뷰(View) 파일 작성하기
bookmark/bookmark.view.php
<? php /** * @class bookmarkView * @author XE스쿨 북마크 모듈 만들기 예제 * @brief bookmark 모듈의 view class **/ class bookmarkView extends bookmark { ...중략 /** * @brief 목록 **/ function dispBookmarkList() { // module_srl 확인 $module_srl = Context ::get( 'module_srl' ); $args ->module_srl = $module_srl ; $args ->page = Context::get( 'page' ); $args ->list_count = $this ->list_count; // 쿼리를 이용해 직접 목록을 가져옴 (bookmark.model.php 모델파일을 사용하지 않는 경우) //$output = executeQueryArray('bookmark.getBookmarkList', $args); //if(!$output->data) $output->data = array(); // bookmark 모델을 이용해 목록을 가져옴 (bookmark.model.php 모델파일을 사용하는 경우) $oBookmarkModel = &getModel( 'bookmark' ); $output = $oBookmarkModel ->getBookmarkList( $args ); if (! $output ->data) $output ->data = array (); // $bookmark_list 변수에 담는다. Context::set( 'bookmark_list' , $output ->data); Context::set( 'page' , $output ->page); Context::set( 'page_navigation' , $output ->page_navigation); // template_file을 list.html로 지정 $this ->setTemplateFile( 'list' ); } } ?> |
북마크 모듈 만들기 예제에서는 bookmark 모델을 이용해 목록을 가져오도록 작성되어 있고 모델(Model) 파일을 포함하고 있다. 만약 쿼리를 이용해 목록을 가져오려면 위 실행문의 주석을 풀고 아래 실행문은 주석으로 처리한다. 모델파일을 이용하지 않는 경우 bookmark.model.php 파일은 필요하지 않게 된다.
2. 프론트엔드 모델(model) 파일 작성하기
bookmark/bookmark.model.php
<? php /** * @class bookmarkModel * @author XE스쿨 북마크 모듈 만들기 예제 * @brief bookmark 모듈의 model class **/ class bookmarkModel extends bookmark { ...중략 // 목록 가져오기 function getBookmarkList( $args ) { $output = executeQueryArray ( 'bookmark.getBookmarkList' , $args ); return $output ; } ...중략 } ?> |
2가지 방법 모두 같은 쿼리 파일(queries/getBookmarkList.xml)을 가리키고 있다.