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.

Phalcon Partial Recursive

Hi, We are using Phalcon Partials with variables recursively. Since the Phalcon v3 update, we have the problem, that the variables of the parent partial is overwritten by the child partial. In v2 everything worked fine. As an example for our usecase:


{{ partial("partials/category", ['category': category]) }}


{{ category.getId() }} //everything is fine

{{ partial("partials/category", ['category': category.getChildCategory()]) }}

{{ category.getId() }} //displays category id of child

Do you have any idea how we could prevent this? Thanks a lot


i dont pass params to particials i just use them, but havent test it in volt



what'is strange here, is that this partial rendering change between v2 and v3.

But the hierarchical rendering process could expalin it and looks quiet logical: child partial is populated with "category:category.getChildCategory()", so calling after that data fetching category.getId() will naturaly give you the id of the child category.

My thought: create a copy of partials/category (say partials/chlidCategory) and pass him partial("partials/childCategory", ['childCategory': category.getChildCategory()])

And, finally, it is known as good mvc practice to populate data in the controller and the pass data to the view.


Hi, @le51 thanks for your answer. Our problem why we can't implement a "parent partial" and a "child partial" is that we theoretically have an unlimited depth, so the parent category could have for example a child, a child-child and so on. We now solved the problem by implementing a method which renders the partial with a simple view. As a simple view doesn't override the variables of its parent simple view this works fine, although it isn't really code-wise a really nice solution. I still think it would be nice if you could partials recursively like you could in phalcon 2.x.