Php Calls In Controllers Or Templates

Hi,

I am working on a new theme for our website.

I have been placing all of my calls for template variables in my addon controllers versus the smarty templates. Which is working fine and resulted in very clean template files. I guess in the strict definition, controllers is probably where these calls belong.

Does this have any impact on caching performance of the pages? I wouldn't have thought so, but I am not quite aware of the smarty internals and how that all works. Either way the functions are called right?

Later on, I will look at full page caching for my site, so the calls should be minimised as much as possible.

Just want to make sure I am not painting myself into a corner :)

Yes, your solution is right. In ideal CS-Cart templates should not have any calls of php functions and CS-Cart team is working on it

Yes, think of a standard 3-tier architecture (backend (DB), business rules and presentation).

Any "data" should be addressed in the business rules layer (PHP controllers in this case) and the data should be "used" in the presentation layer.

While smarty supports variable modifiers (I.e. {"foo"|bar} ) they should generally NOT be used for other than data formatting (of which many are smarty builtin functions, not php functions).

Regarding caching, template variables become PHP variables in the cached smarty templates. Hence the value of those variables is determined dynamically and the values are not cached. Smarty assumes that if you're using a "variable" versus a constant, that the variable might change for different views of that page based on the business rules and therefore the values are determined at runtime. However, the layouts (html) are effectively cached.

Hope that provides further clarity.