2016-11-03 5 views
0

여러 하위 모듈이 구현 된 팔콘 앱이 있습니다. 폴더 구조는 다음과 같습니다.여러보기 디렉토리가있는보기 렌더링

root 
    app 
     controllers 
     models 
     views 
    modules 
     restaurants 
      controllers 
      models 
      views 
     tables 
      controllers 
      models 
      views 
     chairs 
      controllers 
      models 
      views 
    public 

views 디렉토리는 modules 폴더를 가리 킵니다. 이 방법으로, 내가보기를 선택해야 할 때 나는 단지 할 수 있습니다 : $this->view->pick('tables/views/index').

내 문제는보기를 렌더링 할 때 (예 : 순수한 HTML을 문자열로 가져 오는 것), 그렇게 할 수없는 것 같습니다.

$this->view->disable(); 

$this->view->pick('restaurants/views/pdf'); 

$html = $this->view->getContent(); 
$html = utf8_encode($html); 

$pdf = new mPDF(); 
$pdf->WriteHTML($html); 
$pdf->SetTitle('This is a test'); 
$pdf->Output('test.pdf', "I"); 

나는 이것을 할 수 있습니까?

+0

https://docs.phalconphp.com/en/latest/reference/views.html#stand-alone-component – Timothy

답변

0

모듈 이름을 사용하여보기 서비스에 적절한보기 디렉토리를 직접 설정할 수 있습니다. 그렇게하면 팔콘이 컨트롤러와 자동으로 연결하기 때문에 pick 함수를 사용할 필요가 없습니다.

 $module_name = $di->get('router')->getModuleName(); 

     $viewsDir = __DIR__."/modules/".$module_name."/views/"; 

     $view = new View(); 

     $view->setViewsDir($viewsDir);