묻고답하기
확장검색을 위해 XML을 추가 했는데 처리가 안됩니다.ㅠ
2017.04.26 01:52
_search.html에서는
<input type="hidden" id="reg_search_target" name="search_target" value="extra_vars2"/>
<input type="hidden" id="reg_search_keyword" name="search_keyword" value=""/>
<input type="hidden" id="e1_search_target" name="search_targetA" value="extra_vars9"/>
<input type="hidden" id="ot_search_target" name="search_targetB" value="extra_vars10"/>
<input type="hidden" id="e2_search_target" name="search_targetC" value="extra_vars11"/>
<input type="hidden" id="e1_search_keyword" name="search_keywordA" value=""/>
<input type="hidden" id="ot_search_keyword" name="search_keywordB" value=""/>
<input type="hidden" id="e2_search_keyword" name="search_keywordC" value=""/>
이런식으로 Get파라미터를 추가해주었고
document.model.php의 _setSearchOption()에서는
if(strpos($search_target,'extra_vars')!==false) {
$args->var_idx = substr($search_target, strlen('extra_vars'));
$args->var_value = str_replace(' ','%',$search_keyword);
$args->sort_index = 'documents.'.$args->sort_index;
$query_id = 'document.getDocumentListWithExtraVarsMulti';
$args->var_idxA=$args->var_idx; $args->var_valueA=$args->var_value;
$args->var_idxB=$args->var_idx; $args->var_valueB=$args->var_value;
$args->var_idxC=$args->var_idx; $args->var_valueC=$args->var_value;
$Context_GetVars = Context::getRequestVars();
$Context_GetVars = json_decode(json_encode($Context_GetVars), true);
$search_keywordA=""; $search_keywordB=""; $search_keywordC="";
//var_dump($Context_GetVars["search_keywordA"]);
if(isset($Context_GetVars["search_keyworda"])) $search_keywordA=$Context_GetVars["search_keyworda"];
if(isset($Context_GetVars["search_keywordb"])) $search_keywordB=$Context_GetVars["search_keywordb"];
if(isset($Context_GetVars["search_keywordc"])) $search_keywordC=$Context_GetVars["search_keywordc"];
if(!empty(trim($search_keywordA)))
{
$args->var_idxA = substr($Context_GetVars["search_targeta"], strlen('extra_vars'));
$args->var_valueA = str_replace(' ','%',' '.$search_keywordA.' ');
}
if(!empty(trim($search_keywordB)))
{
$args->var_idxB = substr($Context_GetVars["search_targetb"], strlen('extra_vars'));
$args->var_valueB = str_replace(' ','%',' '.$search_keywordB.' ');
}
if(!empty(trim($search_keywordC)))
{
$args->var_idxC = substr($Context_GetVars["search_targetc"], strlen('extra_vars'));
$args->var_valueC = str_replace(' ','%',' '.$search_keywordC.' ');
}
}
이런식으로 변경을 해주었습니다.
마지막으로 getDocumentListWithExtraVarsMulti.xml을 추가하여 아래와 같이 설정해주었습니다.
<query id="getDocumentListWithExtraVarsMulti" action="select">
<tables>
<table name="documents" />
<table name="document_extra_vars" alias="extra_vars" type="left join">
<conditions>
<condition operation="equal" column="extra_vars.document_srl" default="documents.document_srl" pipe="and" />
</conditions>
</table>
<table name="document_extra_vars" alias="extra_varsA" type="left join">
<conditions>
<condition operation="equal" column="extra_varsA.document_srl" default="extra_vars.document_srl" pipe="and" />
</conditions>
</table>
<table name="document_extra_vars" alias="extra_varsB" type="left join">
<conditions>
<condition operation="equal" column="extra_varsB.document_srl" default="extra_varsA.document_srl" pipe="and" />
</conditions>
</table>
<table name="document_extra_vars" alias="extra_varsC" type="left join">
<conditions>
<condition operation="equal" column="extra_varsC.document_srl" default="extra_varsB.document_srl" pipe="and" />
</conditions>
</table>
</tables>
<columns>
<column name="documents.*" />
</columns>
<conditions>
<condition operation="in" column="documents.module_srl" var="module_srl" filter="number" />
<condition operation="in" column="documents.category_srl" var="category_srl" filter="number" pipe="and" />
<condition operation="equal" column="documents.member_srl" var="member_srl" filter="number" pipe="and" />
<condition operation="in" column="documents.status" var="statusList" pipe="and" />
<condition operation="equal" column="extra_vars.var_idx" var="var_idx" pipe="and" />
<condition operation="like" column="extra_vars.value" var="var_value" pipe="and" />
<condition operation="equal" column="extra_varsA.var_idx" var="var_idxA" pipe="and" />
<condition operation="like" column="extra_varsA.value" var="var_valueA" pipe="and" />
<condition operation="equal" column="extra_varsB.var_idx" var="var_idxB" pipe="and" />
<condition operation="like" column="extra_varsB.value" var="var_valueB" pipe="and" />
<condition operation="equal" column="extra_varsC.var_idx" var="var_idxC" pipe="and" />
<condition operation="like" column="extra_varsC.value" var="var_valueC" pipe="and" />
</conditions>
<groups>
<group column="documents.document_srl" />
</groups>
<navigation>
<index var="sort_index" default="documents.list_order" order="order_type" />
<list_count var="list_count" default="20" />
<page_count var="page_count" default="10" />
<page var="page" default="1" />
</navigation>
</query>
일단 쿼리 실행 결과는 정상적으로 동작한것을 $output을 var_dump로 확인했고
board.view.php의 $this->dispBoardContentList(); 실행 후에도 Context::get('document_list') 를 덤프떴더니 제대로 들어가 있는게 확인 되는데
실제로 검색버튼을 누르면 그냥 전체리스트만 띄워주고있네요..
제가 뭔가 처리를 잘못한 부분이나 추가로 수정해줘야 할 부분이 있을까요?ㅠㅜㅠㅜ