Patrick Manser
Patrick Manser

Reputation: 1183

Load partials based on action parameter in Phalcon

I want to load a partial view in Phalcon based on the route parameter.

I have this action, which determines the name of the partial:

public function addAction($discipline = null)
{
    if (isset($discipline)) {
        $this->view->partial = 'add' . $discipline . '.phtml';
    } else {
        $this->view->partial = 'addstatic.phtml';
    }
}

And in the main view, I want to load this partial with the Volt-command partial, like so:

{{ partial('partials/training/' ~ partial) }}

But I am facing this error:

View 'C:\xampp\htdocs\apneist_social/app/views/partials/training/addstatic.phtml' was not found in the views directory

If I browse to this file with the directory browser, I can find the file though.

Upvotes: 2

Views: 192

Answers (2)

Juri
Juri

Reputation: 1367

Wait a minute, why you using volt and want to use phtml in addstatic ? Use volt everwhere :D

Upvotes: 0

Nikolay Mihaylov
Nikolay Mihaylov

Reputation: 3876

Remove the extension (.phtml). Like:

$this->view->partial = 'addstatic';

Upvotes: 1

Related Questions