Process Tags in Plugin

给你一囗甜甜゛ 提交于 2019-12-11 12:25:21

问题


I have an Expression Engine plugin that has a file parameter for example:

{exp:my_plugin file='/css/css.js'}

I can get the parameter in the plugin using

$file = $this->EE->TMPL->fetch_param('file');

Is there a way to process $file to replace any tags, i.e. global variables and snippets, so that I could do something like:

{exp:my_plugin file='{global_path}/css.js'}

And have {global_path} be replaced with the value of global path?


回答1:


In your plugin, you can parse the parameter to match global variables:

$value = $this->_ee->TMPL->fetch_param('value', '');
$value = $this->_ee->TMPL->parse_globals($value);

You can find an example in https://github.com/pvledoux/Pvl_checkif/zipball/master



来源:https://stackoverflow.com/questions/7734738/process-tags-in-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!