예전에 @이온디님이 관련 팁을 구하셨었는데, 어쩌면 이미 답을 구하셨는지도 모르겠네요.

그래도 관련 팁을 찾는 분들이 계실까 해서 대강이라도 정리해봅니다.

 

1. 컨텐츠 위젯 폴더의 content.class.php 제일 아랫 부분 정도에 다음과 같이 추가해줍니다.

    function getMemberSrl() 
    {
        return $this->get('member_srl');
    }
    function getUploadedFiles()
    {
        if(!$this->get('uploaded_count')) return;
        $oFileModel = &getModel('file');
        $file_list = $oFileModel->getFiles($this->get('document_srl'), array(), 'file_srl', true);
        return $file_list;
    }

위의 빨간색 글씨 942~948 부분을 추가해주는 것이죠.

 

2. 이제 위젯 스킨 파일에서 $item->getUploadedFiles() 변수를 활용해보시면 순조롭게 출력이 되는 걸 확인하실 수 있을 겁니다.

 

3. 이후에 첨부파일 중에서 이미지 파일만 골라낸다든지, 어떤 이미지만 선택할 것인지 등등에 관해선 어지간해선 다들 아실 것이므로 또르르르... 아니면 구글링으로...

 

※ 참고로 저는 (루프 돌리는 거 귀찮아서ㅋ) 출력할 원본 이미지를 문서 내 파일 첨부 목록에서 제일 앞에 두고, <img src="{$item->getUploadedFiles()[0]->uploaded_filename}" /> 등으로 불러오고 있답니다 :)

윤삼

profile
아무래도 중급 초반 수준의 코딩 오타쿠인 것 같습니다.
  • profile

    코어 수정 없이 스킨 파일에서만 원본 파일을 불러오려면 이렇게 하면 되는군요.

    $widget_info->content_items를 루프 돌린 반복문 내에서...

    {@
       $oFileModel = &getModel('file');
       $file_list = $oFileModel->getFiles($item->get('document_srl'), array(), 'file_srl', true);
    }
    <block loop="$file_list=>$k,$file">
        {$file->uploaded_filename}
    </block>

     

    ※ 물론, 원본 파일이 문서 내 첨부파일 목록에서 맨 앞에 있는 경우라면 루프 돌리지 않고 {$file_list[0]->uploaded_filename}로 그냥 해도 되겠구요

    {@
       $oFileModel = &getModel('file');
       $file_list = $oFileModel->getFiles($item->get('document_srl'), array(), 'file_srl', true);
    }
    {$file_list[0]->uploaded_filename}

     

    .... 아아, 팁이랍시고 올렸는데 뭔가 두서 없는 거 같아서 이번 팁도 폭망인가봐ㅠ

  • profile ?

    여담이지만 후자의 경우에는 첨부파일이 하나도 없을 수 있으니 첨부파일이 있는지 예외처리를 해야할 거에요.
    html이나 javascript 코딩 등에 따라서 의도치 않은 동작을 할 수도 있거든요.

  • ? profile

    아... 지적 감사합니다. 이렇게 해야 하겠군요.

    <block cond="$item->get('uploaded_count')">
       {@
          $oFileModel = &getModel('file');
          $file_list = $oFileModel->getFiles($item->get('document_srl'), array(), 'file_srl', true);
       }
       <block loop="$file_list=>$k,$file">
           {$file->uploaded_filename}
       </block>
    </block>

     

    그리고,

    <block cond="$item->get('uploaded_count')">
       {@
          $oFileModel = &getModel('file');
          $file_list = $oFileModel->getFiles($item->get('document_srl'), array(), 'file_srl', true);
       }
       {$file_list[0]->uploaded_filename}
    </block>

     

  • profile
    지난번에 보니 함수 자체가 코어에 없더군요 .. ㅋㅋ
  • profile profile
    맞아요. 그래서 아예 위의 첨부파일 리스트를 비롯해서 확장변수 함수 정도는 코어에서 지원해줘도 좋겠다는 생각이 들더라구요.
    라이믹스 깃허브에 이슈로 올려봐야겠어요ㅎㅎ
  • profile
    와 감사합니다 간만에 위젯 보고 있는데 이것때문에 골머리였거든요
  • profile profile
    (물론 지금도 그렇지만) 정말 아무것도 모르던 시절에 짰던 거여서 본문에서 댓글까지 코드가 난삽합니다ㅜㅜ
  • profile profile
    ㅋㅋㅋ 아니에요 깔끔해요
  • profile

    ./widgets/calendar_plannerXE123/  를 가지고 배너출력을 하려고 합니다.

     

    파일첨부이미지를 가져와 표시하려고 하는데 뭐가 문제일까요?   $item->get('document_srl')   $item 에 해당하는 걸 못찾겠습니다. 

     

    <!--// 당일일정만표시(달력숨김 끝)-->
        <!--@end-->
        <!--@if($mini_display_option == "F" || $mini_display_option == "T" )-->
        <div class='Mini_TodayPlanList'>
         
                <h4 style="text-align: center;"><span style="color:#e74c3c;"><span
                            style="background-color:#dddddd;">{$lang->pln_today_event}:
                            {@//출처: https://offbyone.tistory.com/38 [쉬고 싶은 개발자]
                            $today = date("Y-m-d");
                            $weekString = array("일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일");
                            echo($weekString[date('w', strtotime($today))]);
                            }
                        </span></span></h4>
                    <!--@if($today_schedule != null )-->
                    <h5><span class="image blinking"><span style="color:#1abc9c;"><span style="background-color:#ecf0f1;">{@echo $today_schedule}</span></span></span></h5>                     
                        
                            {@
                                // 문서 정보 로드
                                if(Context::get('document_srl')) {
                                $oDocument = Context::get('oDocument');
                                } else {
                                $oDocumentModel = getModel('document');
                                $args = new stdClass();
                                $args->list_count = $this->list_count;
                                $args->module_srl = $this->module_srl;
                                $args->page = Context::get('page');
                                $output = $oDocumentModel->getDocumentList($args, true);
                                $document_list = array_values($output->data);
                                $oDocument = $document_list[0];
                                unset($document_list);
                                }
    
                                if(!$oDocument->document_srl) return;
    
                            
                            $oFileModel = getModel('file');
                            $file_list = $oFileModel->getFiles($item->get('document_srl'), array(), 'file_srl', true);
                            }
                            {$file_list[0]->uploaded_filename}
                        
                    <!--@else-->
                    <h5><span style="color:#1abc9c;"><span style="background-color:#ecf0f1;">{@ echo $lang->pln_no_event}</span></span></h5>                      
                    <!--@end-->
        </div>
        <!--@end-->
    </div>

     

  • profile profile
    글쎄요. $oDocument->document_srl 으로도 해보셨을까요?
  • profile profile
    $file_list = $oFileModel->getFiles($item->get('document_srl'), array(), 'file_srl', true);

    $file_list = $oFileModel->getFiles($oDocument->document_srl), array(), 'file_srl', true);

    이렇게 말인가요?
  • profile profile
    네네 왠지 그런 느낌.
    근데 요즘 따라 알림이 누락되는 것 같네요;;;
  • profile profile
    괄호를 하나 빼셔야겠어요.
    $file_list = $oFileModel->getFiles($oDocument->document_srl, array(), 'file_srl', true);