0

Inside an {exp:freeform:entries} tag, I can't do something like {if freeform:count == 1} unless I output {freeform:count} somewhere in the loop. It can be above or below the conditional.

Doesn't work:

{if freeform:count == 1}<h1>Submissions</h1>{/if}

Works:

<p>The count is {freeform:count}</p>
{if freeform:count == 1}<h1>Submissions</h1>{/if}

I'm using EE 2.73 and FreeForm Pro 4.2.0

Thanks for any ideas

3
  • 1
    I know this isn't a good solution but how about just hiding the count? <p style="display: none;">{freeform:count}</p>?
    – jrothafer
    Jun 15, 2015 at 14:13
  • Ha, that's actually what we're doing! (Temporarily, I hope.)
    – jphansen
    Jun 15, 2015 at 14:56
  • Why not <!-- {freeform:count} -->? I know. Sometimes, we forget the simple way. ;-)
    – Sobral
    Jun 15, 2015 at 15:18

2 Answers 2

0

This looks like a custom template parsing function.

Some add-ons do not use the default Template Parsing Class and can run into this kind of error. However, I can't say for sure, since I can't check the code.

My first suggestion is to update EECMS. The changes implemented on the version 2.9 can maybe help you.

The other one is to delay the parsing of the conditional:

{if '{freeform:count}' == 1}<h1>Submissions</h1>{/if}

By this way, the freeform parser will replace the {freeform:count} variable and the conditional will be parsed further.

But try to update EECMS first.

1
  • I can't update EECMS at the moment, but the '{}' notation worked, thanks.
    – jphansen
    Jun 15, 2015 at 15:11
1

That's an odd one, It seems the former is being treated as a simple conditional and ergo executed prior to modules, while the latter is correctly recognised as advanced and so parsed after the module tags?

Can't be sure but I think I'm guessing wildly here! Would you be up for trying a couple of other experiments to see if we can (a) solve and (b) diagnose?

  1. Force Advanced Conditional (is it parse order??)

    {if freeform:count == 1}<h1>Submissions</h1>{if:else}{/if}
    

    Result : Epic FAIL

this will definatly force the parsing of the conditional to after the module tags. This is not the best example of forcing advanced conditionals but it WILL work :)

  1. Try a different syntax

    {if {freeform:count} == 1}<h1>Submissions</h1>{/if}
    
    {if '{freeform:count}' == '1'}<h1>Submissions</h1>{/if}
    

    Result : Winner winner, checken dinner!

Both are a similar principle, first one just sees if the {tags} effect the parsing, the second will parse the count into a string and do a simple string comparison...

  1. Ultimate work around

    <?php //{freeform:count} ?>
    {if freeform:count == 1}<h1>Submissions</h1>{/if}
    

    Result : Plausable

by hiding the {freeform:count} within a PHP tag (remember to turn it on!) it will be excluded from the output, instead of included but hidden. JChrono's answer in a different flavour really.

2
  • Clever ideas, thanks. #1 didn't work, but #2 did (I just applied it from the answer above yours). And yes, #3 is another way to hide it--preferable to outputting to HTML and hiding it via CSS.
    – jphansen
    Jun 15, 2015 at 15:19
  • which version on #2 worked for you? the force to string one (this one I use regularly) or did you just need the squiggly brackets? I'll mark the results with your outcome, please mark as answer if it does resolve your question though!
    – Blatant
    Jun 15, 2015 at 15:20

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.