Using Partials

Can a partial be an action from a controller? I would like to include an action from one controller inside another controllers action view.

Example: like including the login/action inside a page view of another controller.

Is this possible? If, so how. I would think thats what a partial/include is but it doesn't seem to work.


not entirely sure how it works but should go smth like.

function partial()
        View::LEVEL_LAYOUT => true,
        View::LEVEL_MAIN_LAYOUT => true
    return $this->view->partials("smth");

Where would this function go?


erm your controller perhaps havent tested it

From what I understand partials or includes should be any controller/action. Yet, when using volt to add a partial or include from a different controller it doesn't render.

Yet, I've solved the issue by Ajax. I'm just going to load the view. Which I tested and works and renders the controller action.

Seems ridiculous to me that the partials don't at like an Ajax load or a traditional Php include.

Unless I'm confused and there is a simple way to achieve this.. Then the documention for phalcon is lacking.

On Friday, February 13, 2015, 7thcubic <[email protected]> wrote:

You should be able to use partial() to render any template, regardless of what it's originally used for. Could you paste the relevant template code?

Basically I have a user controller and a controller called creatives. I want to place user/info into a slide out panel on the creatives/index. When I put {{ partial("user/info") }} inside creatives/index view file it only renders the html from user/info and doesn't render out the variables I'm sending to the user/info view. If I goto user/info view it works fine.

On Tuesday, February 17, 2015, quasipickle <[email protected]> wrote:

I assume you've looked at the source to verify? I know that's probably the first thing you did - but every once in a while even the best of us forget the basics.

Have you tried using partial() with a view file that isn't action-specific?

Yes. It works but if I pass any value to the view it fails.

On Tuesday, February 17, 2015, quasipickle <[email protected] <javascript:_e(%7B%7D,'cvml','[email protected]');>> wrote:

What do you mean "pass any value"? Are you referring to this:

{{ partial('user/info',['some_name':'some_value'] }}

By "fail" do you mean the whole partial fails to render, or the value just doesn't get displayed?

I'm passing variables to the user/info view in the user/info action. Request it as a partial in creative/index view - the variables don't show when requested using the volt short cut {{ some variable }}.

On Tuesday, February 17, 2015, quasipickle <[email protected]> wrote:

Ah, I see. But the partial does render - it's just the variables don't display?

Yes. Which doesn't make sense. I can Ajax the view in and the variables then display.

On Tuesday, February 17, 2015, quasipickle <[email protected]> wrote:

I'm not sure why that's happening. If you've only got a few variables, you can pass them to the partial() function like I showed a few posts ago. That'll certainly be simpler than using AJAX to load the content.

Yeah, it's been baffling me for awhile now. I just don't want to wind up ajaxing everything or sending tons of variables to the main index view. I really like phalcon over other frameworks.

On Tuesday, February 17, 2015, quasipickle <[email protected]> wrote:

Solved the issue. When using controller views as partials just remember to set model variables to public not private.

On Tuesday, February 17, 2015, Andrew Romano <[email protected]> wrote:

I am newbie with phalcon. What I am trying to do is to keep the header and footer of my initial index.volt in all the views and forms in my app. Do you think that using partials will be a good approach? Nevertheless I would like to learn more about partialswhere can I find more information . I have browsed the phalcon documentation but sometimes I am getting confuse. I will appreciate any help.