We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

call plugin within a plugin in a template

Development and Programming

chris thacker's avatar
chris thacker
112 posts
7 years ago
chris thacker's avatar chris thacker

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!

       
Derek Jones's avatar
Derek Jones
7,561 posts
7 years ago
Derek Jones's avatar Derek Jones

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>
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.