1

I'm trying to arrange it so that the output order of a Playa field can be controlled by a global variable or radio button channel field (to make it able to be toggled from the listed order to random) but having no success.

When I try using a global variable (carousel-order) with the value set to "random" like this:

{exp:playa:children field="home_carousel" orderby="{carousel-order}"}

It doesn't seem to recognize the global variable. I've also tried using radio buttons to make the switch, like so:

{if carousel_order && carousel_order == "Random"}
    {exp:playa:children field="home_carousel" orderby="random"}
{if:else}
    {exp:playa:children field="home_carousel"}
{/if}

Which actually gives me a parse/syntax error:
Parse error: syntax error, unexpected T_ENDIF in /data/home/rsitka/projects/rsdevwww/system/expressionengine/libraries/Functions.php(679) : eval()'d code on line 241

I've read things like there may be an issue with the order things are parsed but surely someone has needed to do this at some point and run into this issue? Anyone found any workarounds or maybe I'm just missing something obvious?

Thanks!

4
  • Have you tried using a snippet instead? Snippets parse before global variables. – Mark Busnelli Jr Mar 25 '14 at 23:07
  • You are awesome! That works. The only problem is that I don't know what to enter in the snippet when I want to display the entries in order (the option OTHER than random). From the documentation it suggests that if you use the shortcode of the field you want in the orderby attribute, it should order it that way, but that doesn't appear to work for me even if I hardcode the shortcode in the attribute. Snippets don't seem to allow you to leave the variable field blank so something has to go there to allow the other state to work... – Russ Mar 26 '14 at 14:07
  • It looks like I needed to add quotes around the value for the shortcode... but not for when I set it to random. Confusing. Oh well, this gives me what I need. – Russ Mar 26 '14 at 15:12
  • Awesome I'll just copy my comment into an answer and if you wouldn't mind marking it as the answer that would be great for my online rep :) – Mark Busnelli Jr Mar 26 '14 at 18:24
0

Have you tried using a snippet instead? Snippets parse before global variables.

You might also want to download this PDF from Low about the parsing order as I always find it handy when dealing with those issues:

http://loweblog.com/downloads/ee-parse-order.pdf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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