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.

Display based on a custom field value...

October 10, 2007 9:59am

Subscribe [2]
  • #1 / Oct 10, 2007 9:59am

    mdgross

    7 posts

    Lets say I have weblog named news and a custom field named special. Some portion of the entries are marked as special, how do I show only the most recent entry marked as special?

    {exp:weblog:entries weblog="news" orderby="date" offset="1"}


    something like…... special=“yes” ??

  • #2 / Oct 10, 2007 11:34am

    PXLated

    1800 posts

    You’d use a conditional…something like this probably…

    {exp:weblog:entries weblog="news" orderby="date limit=“1” }
    {if special == "yes"}
    your weblog fields go here
    {/if}
    {/exp:weblog:entries}

  • #3 / Oct 10, 2007 11:40am

    mdgross

    7 posts

    That code is not working.

    I’m assuming this is because the first entry is not special, the if returns false and it displays nothing. However, limit=1 is satisfied and expression engine moves on.

  • #4 / Oct 10, 2007 12:07pm

    PXLated

    1800 posts

    Ahhh yes, that’s a problem…Off the top of my head…how bout this…

    {exp:weblog:entries weblog="news" orderby="date"}
    {if special == "yes" AND count == 1}
    your weblog fields go here
    {/if}
    {/exp:weblog:entries}

    Took the limit out. Should get one with a yes I would think (hope) 😊
    (May need quotes around that 1 - not sure)

  • #5 / Oct 10, 2007 12:14pm

    mdgross

    7 posts

    count will increase by one even when the if returns false…  so this doesnt work

  • #6 / Oct 10, 2007 12:39pm

    mdgross

    7 posts

    {exp:weblog:entries weblog="news" orderby="date"}
    {assign_variable:found="no"}
    {if found == "no" && special == "yes"}
    {importance} {found} {title}

    {/if}
    {/exp:weblog:entries}


    ... this would work but I can’t get found to work correctly in the if statement

  • #7 / Oct 10, 2007 12:50pm

    PXLated

    1800 posts

    Ok, how bout sorting by the custom field “special” so they get listed first, then limiting to 1? This would depend on the values in the special field I would guess though.
    Or instead of using a custom field you could probably use a custom status and limit your weblog:entries tag to those and limit as 1.
    Many ways to skin the cat.

  • #8 / Oct 10, 2007 1:50pm

    mdgross

    7 posts

    I simplified the problem as much as possible… in actuality special yes/no is importance and rated on a scale of 1-10…. So its not that easy, like if I wanted the most recent article with importance of 6.

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

ExpressionEngine News!

#eecms, #events, #releases