Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExpressionEngine templates: pass a plugin/module's output as parameter to another plugin/module

Here's basically what I want to accomplish:

{exp:plugin1:method arg="{exp:plugin2:method}"}

I’ve tried a number of different approaches.

Approach 1:

{exp:plugin1:method arg="{exp:plugin2:method}"}

Result: Plugin1->method’s arg parameter value is the string, {exp:plugin2:method}, and it’s never parsed.

Approach 2:

My understanding of the parsing order suggests that this might have different results, but apparently it does not.

{preload_replace:replaced="{exp:plugin2:method}"}
{exp:plugin1:method arg="{replaced}"}

Result: The arg parameter has the same value as approach 1.

Approach 3:

First I define a snippet (snip), whose content is:

{exp:plugin2:method}

Then in the template:

{exp:plugin1:method arg="{snip}"}

Result: Same as approaches 1 and 2.

Approach 4:

Noting that plugins are processed in the order they appear, I have even tested simply placing an instance of {exp:plugin2:method} before the {exp:plugin1:method} call. My thinking is that I could wrap this first call in a regex replacement plugin in order to suppress output, but that it would trigger Plugin2’s parsing first.

{exp:plugin2:method}
{exp:plugin1:method arg="{exp:plugin2:method}"}

Result: Plugin1->method’s arg parameter value is the temporary hash placeholder for Plugin2->method’s output (MD5 I believe) that the Template class reserves until later.

like image 606
eyelidlessness Avatar asked Jun 15 '26 14:06

eyelidlessness


1 Answers

Interesting approach. However, this can be achieved more simply like this:

{exp:plugin1:method arg="{exp:plugin2:method}" parse="inward"}
like image 185
Mark Avatar answered Jun 18 '26 03:06

Mark



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!