Process Tags in Plugin

2019-08-10 11:24发布

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条回答
来,给爷笑一个
2楼-- · 2019-08-10 12:09

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

查看更多
登录 后发表回答