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.

Conditionals before exp:weblog:entries

February 21, 2008 1:28pm

Subscribe [1]
  • #1 / Feb 21, 2008 1:28pm

    Kristof Rutten

    83 posts

    I’m creating a code snippet to be used troughout several pages - if, however, it’s called from a specific URL it should show only specific entries.

    {if "{segment_1}" == "ladies" || "{segment_1}" == "basic" || "{segment_1}" == "all-inclusive"}
    {exp:weblog:entries weblog="clubs" limit="1" orderby="random"  category="not 72" search:club_type="{segment_1}"}
    {if:else}
    {exp:weblog:entries weblog="clubs" limit="1" orderby="random" dynamic="off" category="not 72"}
    {/if}

    This code however is working in the specified directories - but it seems the :else rule isn’t working.

    Any ideas? Has this something to do with the order of parsing?

  • #2 / Feb 21, 2008 1:59pm

    allgood2

    427 posts

    That’s because the {exp:weblog:entries} statement needs to be complete, before the {if:else}

  • #3 / Feb 21, 2008 1:59pm

    allgood2

    427 posts

    That’s because the {exp:weblog:entries} statement needs to be complete, before the {if:else}

  • #4 / Feb 21, 2008 2:32pm

    Kristof Rutten

    83 posts

    It there a solution for something like this?

  • #5 / Feb 21, 2008 2:48pm

    Lisa Wess

    20502 posts

    You absolutely should not be quoting your variables in there.  Please see this kb entry.

    Also, you can not break up weblog entries tags like that. You would need to encompass your entire weblog entries tag pair inside the conditional, then do your if:else on a second weblog entries tag pair.

  • #6 / Feb 22, 2008 4:04am

    Kristof Rutten

    83 posts

    You absolutely should not be quoting your variables in there.  Please see this kb entry.

    @Lisa: I know 😉 It was just a try to get things working with the {if}‘ed entries. Call it a Picaso moment.

    Also, you can not break up weblog entries tags like that. You would need to encompass your entire weblog entries tag pair inside the conditional, then do your if:else on a second weblog entries tag pair.

    OK - but this means you have a lot of “double” code for something rather simple.
    Anyway, I solved it the way you proposed and it’s working now. But I’ll continue my quest on simplifying code 😉

  • #7 / Feb 22, 2008 2:29pm

    Lisa Wess

    20502 posts

    Glad to hear you got it working!

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

ExpressionEngine News!

#eecms, #events, #releases