ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Parsing of embed:variables with adv conditionals inside a weblog:entries loop is broken

March 03, 2011 11:30am

Subscribe [4]
  • #1 / Mar 03, 2011 11:30am

    nathanpitman

    531 posts

    We just did an upgrade on a client site from 1.6 right through to 1.7 and suddenly discovered that all conditional statements which used embedded variables passed from a parent template which were ‘within’ a weblog entries loop no longer work as expected. In fact they no longer work at all.

    We’ve verified that something has changed by executing the some simplified templates that demonstrate this on the upgraded site and then again on another EE1 site we run that’s at v1.6.6.

    Here’s a simple example: (parent template)

    {embed="sandbox/.inc_grains_of_sand" myvar="can you hear me?"}

    And the child embed: (.inc_grains_of_sand)

    {if embed:myvar=="can you hear me?"}Yes! I can hear you!{if:else}Did you say something?{/if}
    {exp:weblog:entries weblog="articles" limit="1"}
    {if embed:myvar=="can you hear me?"}Yes, I can hear you!{/if}
    {if embed:myvar=="can you hear me?"}Yes, I can hear you!{if:else}Did you say something?{/if}
    {/exp:weblog:entries}}

    With our upgraded site running 1.7 the final conditional statement fails and returns ‘Did you say something?’, in 1.6.6 on another site the same template correctly evaluates all the conditional statements and returns ‘Yes, I can hear you!’ for the final statement as expected.

    We’ve engineered a workaround for this using segment variables but it gives us much less flexibility so it’s far from ideal. Is anyone aware of an intentional change to the parsing behaviour for embedded variables when inside a weblog entries loop and if so can you confirm which build this change first manifested itself in?

  • #2 / Mar 03, 2011 11:34am

    Brad Morse

    428 posts

    This is not tested, but try:

    {if "{embed:myvar}"=="can you hear me?"}
  • #3 / Mar 03, 2011 11:37am

    nathanpitman

    531 posts

    Gnah! That works! I wish I’d posted here this morning now - would have saved myself a bunch of work! :!

    Thanks Brad!

    And one for Ellis Lab, any idea why the ‘old method’ no longer works - is this intentional, also was it documented..? I didn’t see it when I perused the change logs before I ran the upgrade.

  • #4 / Mar 03, 2011 11:42am

    Jérôme Coupé

    122 posts

    What Brad says. We had issues with conditionals like these in the past, we generally tend to quote everything now and revert to the old way if that doesn’t work. Can be quite confusing indeed when you never came across it.

    That being said the order of conditionals also affects how they are rendered in some edge cases.

  • #5 / Mar 03, 2011 5:35pm

    Ingmar

    29245 posts

    It’s a parse order issue, I think there were some changes there. That said, glad you found a solution. Please don’t hesitate to post again as needed.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases