Q&A

if(!defined("__XE__")) exit();
$document_srl = Context::get('document_srl');
$oDocumentModel = getModel('document');
$oDocument = $oDocumentModel->getDocument($document_srl);
if($act == 'procCommentVoteUp' && $called_position == 'after_module_proc' && $oDocument->get('module_srl')=='64695') {

코드

}

 

 

위와 같이 작성해서 작동이 되는줄 알았더니 $oDocument->get('module_srl')=='64695' 이부분이 적용이 되지 않아 모든 문서가 작동하지 않는 상황이네요. 

 

어디에 오류가 있는건가요?

댓글 11

  • after_module_proc이면 $this->module_srl==''64695' 로 안 되려나요?

    그리고 저렇게 하시면 $oDcoument 뽑아오는 구문이 애드온 호출시점마다 반복될 거 같아요.
  • @윤삼
    그럼 실제 작업이 이루어지는 곳에서 모듈번호를 추출해서 조건을 걸 수 있을까요? 댓글이 소속된 문서번호도 동일합니다.

    $comment_srl = Context::get('target_srl'); //procCommentVoteUp에서 받아오는 값을 가져온다.

    $oCommentModel = getModel('comment');
    $oComment = $oCommentModel->getComment($comment_srl, FALSE, FALSE);
    $member_srl = $oComment->get('member_srl'); //댓글 작성자의 유저번호
  • @웹지기
    애드온 설정에서 모듈 설정을 해주면 그 모듈에서만 작동하지 않나요?
    그걸 $this->module_srl로 받아와서 필요한 부분에 조건을 걸면 될 것 같은데요.
  • @윤삼
    타임라인을 사용하는 사이트에서는 꼭 문서가 소속된 문서번호를 확인해서 작동시켜야 할 때가 있어서요.
  • @웹지기
    아, 그렇겠네요;;; 이렇게 해보면 어떨까요. 문서가 떴을 때만 사용하고, 해당 문서가 소속된 모듈번호가 64695가 아니면 애드온 작동 중지

    if(!defined("__XE__")) exit();

    if($act == 'procCommentVoteUp' && $called_position == 'after_module_proc' && Context::get('document_srl')) {

    $document_srl = Context::get('document_srl');
    $oDocumentModel = getModel('document');
    $oDocument = $oDocumentModel->getDocument($document_srl);
    if($oDocument->get('module_srl') != '64695') return;

    코드

    }
  • @윤삼
    네. 적용해 보겠습니다.
    그럼
    $document_srl = Context::get('document_srl');
    $oDocumentModel = getModel('document');
    $oDocument = $oDocumentModel->getDocument($document_srl);
    if($oDocument->get('module_srl') != '64695') return;

    이 위치가 영향을 주는건가요?

    $document_srl = Context::get('document_srl');
    $oDocumentModel = getModel('document');
    $oDocument = $oDocumentModel->getDocument($document_srl);
    if($oDocument->get('module_srl') != '64695') return;

    이 코드는 애드온 최상단에 넣어봤는데 안되더라구요. 모듈번호는 정확히 넣었는데요.


    말씀 하신 위치로 변경해 보고 확인해 보겠습니다.
  • @윤삼
    이상하게 모듈번호를 못불러오는 거 같습니다.
    코드 위치를 바꿔봐도 다 안되는 것 보니 어딘가 오류가 있나봐요...

    64695 번호에 소속된 문서에서만 동작되어야 하는데 지금 모두 리턴되어 버리네요...
  • @웹지기
    디버깅 모드를 켜고 하나씩 점검해보시면 좋을 것 같아요ㅠ
  • @윤삼
    문서의 모듈번호를 왜 못불러오는지는 제가 지식이 없어 파악을 못하겠어서...

    $comment_srl = Context::get('target_srl'); //procCommentVoteUp에서 받아오는 값을 가져온다.

    $oCommentModel = getModel('comment');
    $oComment = $oCommentModel->getComment($comment_srl, FALSE, FALSE);
    $member_srl = $oComment->get('member_srl'); //댓글 작성자의 유저번호
    if($oComment->get('module_srl') != '64695') return;

    이렇게 기존코드에서 댓글로 모듈번호를 불러오니 잘 되네요..


    다른 애드온에서 응용할때 약간 퀴즈가 남은 상황이네요 ㅋ

    담변 감사합니다.
  • $oModuleModel = getModel('module');
    $ggmodule_info = $oModuleModel->getModuleInfoByDocumentSrl($document_srl);
    $ggmodule_srl = $ggmodule_info->module_srl;

    한번 해보실래요?

  • @GG
    답변 감사합니다. 다른 애드온에서 필요할때 적용해 볼게요.