0

I'm trying to use the PHP String fun plug-in to evaluate whether a current entry belongs to a specific channel and then show/hide a register prompt depending upon that. So I have a snippet:

{sn_content_channels_closed} = "content_guides|content_videos|content_white-papers"

Then the channel in question is "content_white-papers", however the template code below fails to return TRUE 'unless' I place the {channel_name} variable somewhere else in the template in addition to here:

{if '{exp:phpstringfun function="substr_count" par1="{channel_name}"}{sn_content_channels_closed}{/exp:phpstringfun}'=='1'}

Of course I could do that but I'd like to understand why this doesn't work, Parse order... EE WTF... something else?

2
  • Are you using this same tag with the same content and parameter somewhere else on the template?
    – Sobral
    Jun 27, 2014 at 19:37
  • Hi Robson, no it occurs just the once in the template. Jun 29, 2014 at 11:22

1 Answer 1

1

ugh, I came across what looks like the same thing a while ago: plugin value in a template conditional

It's really odd. You could try ifify: http://devot-ee.com/add-ons/ifify

... though these days I think I'd attempt this more cleanly using Stash's get_list with match against parameters.

1
  • Thanks James, as I saw including the variable I'm testing elsewhere in the page causes the conditional to evaluate correctly but it's too fragile for my liking so I will definitely check out Ifify! :) Jun 29, 2014 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.