티스토리 뷰

xe 카테고리 정보 얻어오는 방법이다.


xe 카테고리 타이틀에서 포인트차감이라고 되어 있으면 포인트를 차감하고 포인트비차감으로 되어 있으면 포인트비차감해달라는 의뢰가 있었다.


xe/modules/point/point.controller.php 파일을 열어보면 아래와 같이 있다.


function triggerUpdateReadedCount(&$obj) {

....


}


여기서 obj를 찍어보면 


documentItem Object

(

    [document_srl] => 1423

    [lang_code] => ko

    [allow_trackback_status] => 

    [columnList] => Array

        (

        )


    [allowscriptaccessList] => Array

        (

        )


    [allowscriptaccessKey] => 0

    [uploadedFiles] => Array

        (

        )


    [error] => 0

    [message] => success

    [variables] => Array

        (

            [document_srl] => 1423

            [module_srl] => 1420

            [category_srl] => 1422

....

이런식으로 출력된다. 


따라서 category_srl 정보를 가져오려면 $obj->variables["category_srl"] 과 같이 하면 되고 그거를 바탕으로 모든 카테고리 정보를 가져오려면 아래와 같이 하면 된다.


$oDocumentModel = &getModel('document');

$o= $oDocumentModel->getCategory($obj->variables["category_srl"]);

debugPrint($o->title); //카테고리 명을 찍는다.


이런식으로 하는거고...


의뢰한대로 카테고리 타이틀이 포인트미차감일때는 포인트모듈이 동작하지 말아야 하기 때문에


(작업전 백업을 해놔야 한다.)

/modules/point/point.controller.php 파일을 열어보면 아래와 같은 함수가 있다.

function triggerUpdateReadedCount(&$obj) {

}

이 함수를 조회했을때 사용되는 함수이다.

여기서 이 함수 마지막 부분에 

$cur_point += $point;
$this->setPoint($member_srl,$cur_point);

이부분을 

$oDocumentModel = &getModel('document');
$o= $oDocumentModel->getCategory($obj->variables["category_srl"]);
debugPrint($o->title);

if($o->title=="포인트미차감"){

}else{
$cur_point += $point;
$this->setPoint($member_srl,$cur_point);
}

이렇게 바꾸면 된다^^

===================================================


그러나..


글쓰기에서는 포인트가 동작안한다는 의뢰인의 말이 있었다.


왜그러나.. 추적을 해보다가


글쓰기 즉, function triggerInsertDocument(&$obj) {


이부분에 있는 파라미터 &$obj는 위의것들과는 다르다. 


[2017-03-24 22:35:07 point.controller.php:69] - mem(9.04MB)

stdClass Object

(

    [_filter] => insert

    [error_return_url] => /xe/index.php?mid=vr_dong2&act=dispBoardWrite

    [act] => procBoardInsertDocument

    [mid] => vr_dong2

    [content] => <p>88</p>

    [category_srl] => 1421

    [title] => 88

    [comment_status] => ALLOW

    [allow_trackback] => Y

    [status] => PUBLIC

    [module] => board

    [module_srl] => 1420

    [is_notice] => N

    [commentStatus] => ALLOW

    [notify_message] => N

    [ipaddress] => 127.0.0.1

    [extra_vars] => N;

    [document_srl] => 1456

    [readed_count] => 0

    [list_order] => -1457

    [update_order] => -1457

    [member_srl] => 1433

    [user_id] => xe

    [user_name] => xe

    [nick_name] => xe

    [email_address] => aaa@aaa.com

    [homepage] => 

    [lang_code] => ko

)


이런식으로 되어 있다.


그래서 아래와 같이 수정해야 한다.


$oDocumentModel = &getModel('document');
$o= $oDocumentModel->getCategory($obj->category_srl);
if($o->title=="포인트비차감"){
}else{
$this->setPoint($member_srl,$cur_point);
}

//$this->setPoint($member_srl,$cur_point);

투표 Vote 쪽도 안된다고 하니 위와 같이 쓰면 될듯 하다.


댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함