0
votes

I'm using Geocore to develop a site.

In assigning templates for a specific page, we have a .tpl file for that.
This is to separate the business logic with the template (front-end), blah.. etc.

I already have basic knowledge on how to include php variables in the .tpl file using the smarty syntax. The problem is, how do I assign a .php file so that the variables can be read in the template(.tpl)?

2
You pass them via smarty's assign() method - zerkms
then, i could already call the variable in any tpl files? - Severino Lorilla Jr.
that depends on how you define "any" - zerkms
sorry, i can't just seem to picture it all out. Where should i put my .php files? in the template folder in geocore? - Severino Lorilla Jr.
I don't even know what is geocore, I've just said how to pass a variable from an arbitrary php to an arbitrary template. - zerkms

2 Answers

2
votes

You can't "assign" a PHP file to a template. That relationship works the other way around: from within a given PHP file, you call a specific template to be used for rendering its contents. You can assign individual variables to that template via smarty's assign(), from inside the PHP file that uses it.

If you need to create an interface between an entire PHP file and a given template, your best bet is to create a custom Smarty plugin, per http://www.smarty.net/docs/en/plugins.tpl. GeoCore has several built-in plugins that might help get you started: take a look in the /classes/geo_smarty_plugins/ directory

1
votes

I guess you are talking about already existing .tpl files found in geoCore. A particular .tpl file would be called by an already existing .php file. If you need to pass a new smarty variable to the .tpl file you need to find out which PHP file calls the .tpl file and then add the new variable to THAT particular PHP file.