I have a a few XHTML widgets and containers that have static or mostly static content. When I say mostly static, I mean a widget which is using one or more variables passed to it from a DB or a configuration. These are all used in more than one frontend page. Currently, I have stored them as PHP functions that return a XHTML string, and these functions are stored in a singular “functions” file that is “included” on every page. Where applicable, I either pass these functions configuration values or do some DB calls from within.
Is there another better way to store these in PHP code? Or is what I am doing pretty standard?
(I am not using Smarty or another template system and I’d rather not add another layer of abstraction.)
That’s pretty standard, most you can do is separate them into files for each and then have a “includes” files that includes each one of them.
This way you would only have to load what you need per script / page.