ExpressionEngine Templates: Pass the plugin / module output as a parameter to another plugin / module

Here basically I want to execute:

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

Ive tried several different approaches.

Approach 1:

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

Result: Plugin1->method s argThe parameter value is a string {exp:plugin2:method}and is never parsed.

Approach 2:

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

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

Result: The parameter arghas the same meaning as approach 1.

Approach 3:

First, I define a fragment ( snip) whose contents are:

{exp:plugin2:method}

Then in the template:

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

Result: Same as approaches 1 and 2.

Approach 4:

, , , {exp:plugin2:method} {exp:plugin1:method}. , , , Plugin2s.

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

: Plugin1->method s arg Plugin2->method s (MD5, ), Template .

+3
2

, , , , . plugin1 plugin2 , tagdata. , plugin2 parse="inward".

:

{exp:plugin2 parse="inward"}
    {exp:plugin1:method arg="{someplugin2method}"}
{/exp:plugin2}

:

static $public_methods;

function __construct() {
    // Actual construction code omitted...

    if(($tagdata = $this->EE->TMPL->tagdata) !== false && trim($tagdata) !== '') {
        if(!isset(self::$public_methods)) {
            self::$public_methods = array();
            $methods = get_class_methods($this);
            foreach($methods as $method) {
                if($method == get_class($this) || $method == '__construct') {
                    continue;
                }
                $reflection = new ReflectionMethod(get_class($this), $method);
                if($reflection->isPublic()) {
                    self::$public_methods[] = $method;
                }
            }

            self::$public_methods = implode('|', self::$public_methods);
        }

        $tagdata = preg_replace_callback('/\{(' . self::$public_methods . ')\}/',
            array($this, 'tagdata_callback'), $tagdata);
        $this->return_data = $tagdata;
    }
}

private function tagdata_callback($matches) {
    $method = $matches[1];
    return $this->$method();
}

:

  • .
  • , -, Reflection, PHP 4. , .
0

. :

{exp:plugin1:method arg="{exp:plugin2:method}" parse="inward"}
+2

Source: https://habr.com/ru/post/1778016/


All Articles