Search code examples
expressionengine

Inner tags not parsing with Expression Engine 2 custom plugin


I've written a simple plugin that basically loops through a bunch of entries. The plugin is used to only display entries that contain a feature image, amongst some other minor logical conditions. The use of my tag looks something like this:

{exp:myentries:withimages channel="mychannel"}
    <!-- This works fine -->
    <h1>{title}</h1>
    <!-- But nested exp:... tags don't seem to parse? -->
    <p>{exp:ce_img:single src="feature_image"}</p> 
{/exp:myentries:withimages}

I am calling

return $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $data);

from my custom EE plugin, the data is there, but only the nested {exp:... tags don't want to parse.

I've followed the online User Guide for creating plugins as close as I possibly could, but I need some help getting the other tags to parse? If I simply output {feature_image}, the field renders the src value for the image as expected.

Can anyone possibly shed some light on what I'm doing wrong?


Solution

  • You want to put parse="inward" parameter in your {exp:myentries:withimages tag, otherwise the template will try to parse the exp:ce_img call before {feature_image} is set.

    {exp:myentries:withimages parse="inward" channel="mychannel"}
    

    The parse="inward" will tell EE to run this tag first before parsing any other tags within the tag pair.