Q&A

Widget 코드 질문

2023.04.26 07:02
2,291
0
CMS/프레임워크 Rhymix 2.1
개발 언어 PHP 7.4

예전 사이트에 bannerlist라는 테이블을 읽어서 화면에 표시해주는것 widget으로 구현해보려고 하는데, template not found라는 오류가 발생합니다.

아래와 같은 방법이 틀렸나요?

조언 부탁드립니다.

 

 

banner_view.class.php

 

<?php

 

class banner_view extends WidgetHandler

{

 

    function proc($args)

    {

 

        $oDB = DB::getInstance();

 

        $query = $oDB->prepare('SELECT * from bannerlist  order by banner_type , start_dt ');

        $query->execute();

        $result = $query->fetchAll();

 

        $tpl_file = 'banner_list';

        Context::set('bannerlist', $result);

        // Compile a template

        $oTemplate = &TemplateHandler::getInstance();

        return $oTemplate->compile($tpl_path, $tpl_file);

    }

}

 

banner_list.html

<load target="./css/widget.css" />

<div >

   <!--@foreach($bannerlist as $banner)-->

        <p align='center'>

        <a href='{$banner->link_url}' target='_blank'>

        <img src='{$banner->img_url}' width='{$banner->img_width}' height='{$banner->img_height}' border='0' title ='{$banner->tooltip}' ></a></p>

        <p align='center'>

        Expired date:{$banner->end_dt}"

        </p>

    <!--@end-->

    <br>  

 </div>

 

댓글 2

  • 2023.04.26 07:08 #1759175
    올리신게 코드의 전부인가요? $tpl_path를 선언하는 부분이 없는것 같습니다.

    예를들어 콘텐츠 위젯은 $tpl_path = sprintf('%sskins/%s', $this->widget_path, $args->skin); 와 같이 스킨/스킨폴더명을 지정하고 있습니다.
  • 2023.04.26 07:21 #1759179
    감사합니다~.

    어이없는 실수 였네요. 첫번째 위젯 만들기를 성공했습니다. ^^