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.

Filter by status parameter not working for me?!

June 21, 2010 12:41pm

Subscribe [1]
  • #1 / Jun 21, 2010 12:41pm

    Cue

    98 posts

    So I have a weblog tag searching for entries based on the URL segments and status. {segment_1} is the entry’s URL Title, where {segment_2} is a flag used in a conditional to determine a status to use.

    Very simple. Here’s the code as it would be in the template:

    {exp:weblog:entries weblog="myweblog" url_title="{segment_1}"
    status="{if '{segment_2}' == 'preview'}Awaiting_approval|open{if:else}open{/if}" dynamic="off" limit="1"}

    When that entry is open, works fine. When it’s closed, work’s as expected. When set to Awaiting_approval - it fails like England v Algeria on a sunny day?

    Am I overlooking something here?

  • #2 / Jun 21, 2010 2:04pm

    ender

    1644 posts

    an ‘advanced conditional’ (anything with if:else in it) is probably processed too late for this to work.  try this instead:

    {exp:weblog:entries weblog="myweblog" url_title="{segment_1}"
    {if segment_2 == 'preview'}status="Awaiting_approval|open"{/if} {if segment_2 != 'preview'}status="open"{/if} dynamic="off" limit="1"}
  • #3 / Jun 21, 2010 2:13pm

    lebisol

    2234 posts

    Am I overlooking something here?

    That Algeria has a better team!? LOL

    your condition reads:
    if ...show me A and B otherwise show me B

    I think it should be:
    if ...show me A and B otherwise show me C
    Awaiting_approval|open{if:else}closed{/if}
    but it depends on your workflow logic I guess.

  • #4 / Jun 21, 2010 2:49pm

    ender

    1644 posts

    nah he’s basically wanting to show the pending entries if the person is viewing the preview, otherwise just open entries.

  • #5 / Jun 21, 2010 3:09pm

    lebisol

    2234 posts

    I guess depends on what you consider ‘preview’ since on that page he will see “Awaiting_approval AND open”....why preview something that is considered ‘open’ or published. It is already public and ‘viewed’.
    Semantics LOL.
    So this would make more sense to me:

    {if segment_2 == 'preview'}status="Awaiting_approval"{/if} {if segment_2 != 'preview'}status="open"{/if}

    but then again there is days when I don’t make sense to myself 😊

  • #6 / Jun 22, 2010 6:03am

    Cue

    98 posts

    The aim of the game is to show a preview of entries that are either already open or awaiting approval, pretty straight forward? I’m using the LG Live Look extension - where the Live Look adds the /preview/ suffix to the URL which flags the entry as in preview mode - albeit open or awaiting approval.

    Yes it makes sense to view only Awaiting approval entries, but regardless the latter should work whether the semantics exist or not.

    Putting status=“Awaiting_approval|open” works as it’s intended to, that’s what I want. But the issue is hassled by the conditionals. For some strange reason the conditionals are not being parsed in the query.

    Attempt 1:

    status="{if '{segment_2}' == 'preview'}Awaiting_approval|{/if}open"

    The query output:

    t.status IN ('{if \'preview\' == \'preview\'}Awaiting_approval','{/if}open')

    Attempt 2:

    {if '{segment_2}' == 'preview'}status="Awaiting_approval|open"{if:else}status="open"{/if}

    The query output:

    t.status = 'open'

    The final solution that eventually worked was:

    {if '{segment_2}' == 'preview'}status="Awaiting_approval|open"{/if} {if '{segment_2}' != 'preview'}status="open"{/if}

    Why it couldn’t do an {if:else} beats me. Why I need two conditionals beats me.

    Thanks for having a look at this with me.

  • #7 / Jun 22, 2010 7:57am

    ender

    1644 posts

    http://expressionengine.com/docs/templates/globals/conditionals.html

    NOTE: Advanced Conditionals are evaluated after all EE tags are parsed.

    the {if:else} makes it an advanced conditional and thus parsed too late to feed its output into another tag’s input.

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

ExpressionEngine News!

#eecms, #events, #releases