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

partials dir not under views dir?

According to official documentation,

...a partials sub-directory... must be a directory under the views directory

Now let's suppose we have a multi-module app where each module has its own views directory, and we need to use some module-independent HTML fragments (maybe static, maybe containing some vars to be defined in appropriate controllers). Using partials appears a reasonable approach, but we cannot access views placed NOT under the this or that module views directory.

E.g. we have two modules:

  • home
  • orders

Each module has its own view dir:

  • home
  • -- views
  • orders
  • -- views

In plus we want to used some shared partial views from the dir shared/views:

  • home
  • -- views
  • orders
  • -- views
  • shared
  • -- views

Using the current implementation of partials gives no possibility to do so.

Any idea? Thanks in advance.



1.7k
edited Mar '14

Thanks Karol, but this part of manual appears to contain nothing helping to solve the problem. Or maybe I just couldn't find a right recipe there. Once again, I like the default views hierarchy defined in \Phalcon\Mvc\View class; I just would like to use arbitrary (not under current module views directory) path for partials.

OK, there's a function \Phalcon\Mvc\View->setPartialsDir(dir) to set that directory. But it just appends its argument to the current module views dir. Maybe Phalcon has a function like \Phalcon\Mvc\View->setAbsPartialsDir(absdir) but I didn't find it.

edited Mar '14

maybe than partial you want use something like this
https://forum.phalcon.io/discussion/1459/rendering-external-partial-#C5168