We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Render Partial in Controller

Hi. sorry my english is not so good. I have a problem when using partial view. i need only html string in my partial file not all html tag (include header and footer). when i use partial in controller, it send whole html tag string. this is my controller code

<?php
class CourseController extends ControllerBase {
    public function indexAction(){
    $view = new View\Simple();
        $view->setViewsDir(__DIR__."/../views/");
        echo $view->partial('course/partial/_list_course',[
            'courseList' => $courseList
        ]);
    }
}

this is my example partial view

<div>test</div>

how to get only string <div>test</div>? not all html tag (include header and footer).



841
Accepted
answer

ahh...... sorry for my stupid question. i only add $this->view->disable(); and works perfectly..