본문 바로가기

php 헛다리/CI4 헛다리

ci4 parser 파서

728x90

ci4 parser 파서

 

class DashboardDefaultController extends BaseController
{

    private $parser; // 파서사용
    private $arr_class_common;

    public function initController(
        RequestInterface $request
        , ResponseInterface $response
        , LoggerInterface $logger
    )
    {
        parent::initController($request, $response, $logger);
        // Add your code here.

        $this->arr_class_common = array(
            "siteURL" => base_url() //base_url은 config파일에 설정되어 있다.
        );

        $this->parser = \Config\Services::parser(); // 파서사용

    }// end - fun



    public function dashboard_list()
    {

        // 위젯 - 좌측메뉴 및 로그인 정보 표시 예정
        $widget = new MyWidget();
        $arr_VARIABLE_DATA['widget'] = $widget->render(); 

        $arr_VARIABLE_DATA['title'] = "dashboard_list";

        // 메소드 파서 처리 // setData( raw ) 해야 html 정상출력됨
        $arr_VARIABLE_DATA['html_contents'] = 
                 $this->parser->setData($arr_VARIABLE_DATA, 'raw')->render("DashboardDefault/dashboard_list");
        
        // 레이아웃 파서 // setData( raw ) 해야 html 정상출력됨
        return $this->parser->setData($arr_VARIABLE_DATA, 'raw')->render("layout_default");


    }// end - fun

?>

/app/Views/DashboardDefault/dashboard_list.php
title : {title}
{widget}

/app/Views/layout_default.php
{html_contents}
728x90

'php 헛다리 > CI4 헛다리' 카테고리의 다른 글

ci4 파서사용시 자바스크립트 알수없는 Syntax 에러  (0) 2024.11.11
CI4 컨트롤러에서 모델 호출하는 방법  (0) 2024.11.10
ci4 post  (0) 2024.10.10
ci4 session 세션  (0) 2024.10.10
ci4 쿼리빌더  (0) 2024.10.10