All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Conditionally overriding preload replace variables

Heiko 19 Jul 2012 12:58 question, complete

I'm trying to swap the value of a replacement variable based on the current URI being http://mysite.com/ or e.g. http://mysite.com/P2.

{exp:ifelse parse="inward"}
{if segment_1 == '' OR segment_1 == '#^P(\d+)/$#'}
{preload_replace:channel="{par_site_channels}"}
{if:else}
{preload_replace:channel="{segment_1}"}
{/if}
{/exp:ifelse}

{par_site_channels} is an early parsed low variable containing just an array of |-separated channel names.

Can you please tell me, why this doesn't work? Is this a limitation of preload_replace?

Thank you!

Replies

  1. Low 19 Jul 2012 13:05

    Parse order says preload replace vars are set and replaced before tags (including the {exp:ifelse} tag). This means you can only use simple conditionals to change their values.

    So yeah, a combination of preload_replace and parse order.

  2. Heiko 19 Jul 2012 13:09

    Hmm, thanks for your fast answer, I already tried it the simple way, but it seems that even using OR already makes the conditional advanced.

    I'm going to look for another solution then. Thanks anyway! :)

  3. Low 19 Jul 2012 13:13

    Yep, check my Parse Order Pro slides to see what makes a conditional simple: http://www.slideshare.net/lodewijksch...

  4. Heiko 19 Jul 2012 13:17

    I'd stumbled across this already, but it's a little hard to comprehend without listening to the speech.

    I couldn't find a recording of it anywhere, does one exist?

    Thanks a bunch!

  5. Low 19 Jul 2012 13:18

    Don't think they recorded it, no. Sorry.