We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Duplicate view rendering

Hello,

I am using multiple viewsDirs and I need to confirm, that actual template targeting in Phalcon works as intended.

I have 2 view dirs:

  1. .../skins/my_skin/views
  2. .../frontend/views/

I would expect, as in other frameworks, that if I have template block/footer.volt under both directories, it will check for first existing template under views dirs and render it.

But current implementation in Phalcon works much different, it checks every time all directories and renders all templates found. So the most priority directory is the last one and not the first one.

This is causing some performance overhead and it is causing problem when you want to render some partial, because it is rendered multiple times.

This for loop is causing the unexpected behavior

https://github.com/phalcon/cphalcon/blob/master/phalcon/mvc/view.zep#L665

Is this functionality intended?



85.5k
Accepted
answer
edited Aug '17

https://github.com/phalcon/cphalcon/commit/e9968fe0460036d74d67d4bea35a76479b1d5777

i have the same problem.

i have a fork with that commit reverted. I keep forgetting adding a PR with tests so we can remove this commit from master branch

//edit: I wrote to Serghei to take a closer look when he can, so we can fix that issue properly, not like me

I am using customized View, which solves this duplication, but future fix will be very nice. Thak @Izo for bug confirmation.