Thread

call plugin within a plugin in a template

February 27, 2018 4:25pm

Subscribe [2]
  • #1 / Feb 27, 2018 4:25pm

    chris thacker

    102 posts

    This works:

    <description>{exp:char_limit total="150"}{article_body}{/exp:char_limit}</description>

    I have a plugin that grabs the query string which contains the same desired char_limit integer. When I try to use it in place of the integer above, in order to make this more dynamic, it doesn’t seem to be working.

    Is this doable?

    <description>{exp:char_limit total="{exp:myPlugIn:charLimit}"}{article_body}{/exp:char_limit}</description>

    or

    <description>{exp:char_limit total={exp:myPlugIn:charLimit}}{article_body}{/exp:char_limit}</description>

    Thanks!

  • #2 / Mar 10, 2018 8:21pm

    Derek Jones's avatar

    Derek Jones

    7391 posts

    Nested plugins work the way you’d expect most of the time: from the inside out. A plugin as a parameter of another plugin’s opening tag is rather rare though, and a little different. For all it knows, you’re wanting to pass that tag name along to your plugin to use or modify it in some way. If ExpressionEngine tried to guess, it might get it right sometimes, but would result in inconsistent behavior from one context to the next.

    So rather than try to track what has already happened and guess what the site builder’s intent is, the parser has a strict and reliable behavior of treating all parameters as normal strings. {variables} are more likely to be used in parameters and would have already been parsed by earlier tags. To be explicit as to your intent that it’s a tag you want executed first, you can give a cue to the outer plugin with parse='inward':

    <description>{exp:char_limit total='{exp:myPlugIn:charLimit}' parse='inward'}{article_body}{/exp:char_limit}</description>
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases