简体   繁体   English

Geocore - TPL和PHP文件(Smarty)

[英]Geocore - TPL and PHP Files (Smarty)

I'm using Geocore to develop a site. 我正在使用Geocore开发一个网站。

In assigning templates for a specific page, we have a .tpl file for that. 在为特定页面分配模板时,我们有一个.tpl文件。
This is to separate the business logic with the template (front-end), blah.. etc. 这是为了将业务逻辑与模板(前端),blah等分开。等等。

I already have basic knowledge on how to include php variables in the .tpl file using the smarty syntax. 我已经掌握了如何使用smarty语法在.tpl文件中包含php变量的基本知识。 The problem is, how do I assign a .php file so that the variables can be read in the template(.tpl)? 问题是,如何分配.php文件以便可以在模板(.tpl)中读取变量?

I guess you are talking about already existing .tpl files found in geoCore. 我想你在谈论geoCore中已经存在的.tpl文件。 A particular .tpl file would be called by an already existing .php file. 特定的.tpl文件将由现有的.php文件调用。 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. 如果需要将新的smarty变量传递给.tpl文件,则需要找出哪个PHP文件调用.tpl文件,然后将新变量添加到特定的PHP文件中。

You can't "assign" a PHP file to a template. 您不能将PHP文件“分配”到模板。 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. 这种关系反过来:从给定的PHP文件中,您调用一个特定的模板来用于呈现其内容。 You can assign individual variables to that template via smarty's assign() , from inside the PHP file that uses it. 您可以通过smarty的assign()从使用它的PHP文件中将单个变量分配给该模板。

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 . 如果您需要在整个PHP文件和给定模板之间创建一个接口,最好的办法是根据http://www.smarty.net/docs/en/plugins.tpl创建一个自定义的Smarty插件。 GeoCore has several built-in plugins that might help get you started: take a look in the /classes/geo_smarty_plugins/ directory GeoCore有几个内置的插件,可以帮助你入门:看一下/classes/geo_smarty_plugins/目录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM