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.

Weblog search parameter operator

May 11, 2009 6:33pm

Subscribe [3]
  • #1 / May 11, 2009 6:33pm

    jorgepinon

    11 posts

    Can the search: parameter in a weblog entries tag have an operator?

    I’m trying to make sure my bloggers have included a teaser image for the entry to show up in the “featured item” section, so I’m using:

    {exp:weblog:entries weblog="weblog1|weblog2" search:teaser-image="not IS_EMPTY"}

    Client now needs to add another weblog to the mix that has a different custom field for the teaser image - “ts-teaser-image” let’s say.

    Is there a way to get an OR in there?

    {exp:weblog:entries weblog="weblog1|weblog2|newWeblog" search:teaser-image="not IS_EMPTY" OR ts-teaser-image="not IS_EMPTY"}
  • #2 / May 12, 2009 7:28am

    e-man

    1816 posts

    Have you tried this?:

    {exp:weblog:entries weblog="weblog1|weblog2|newWeblog" search:teaser-image="not IS_EMPTY"  search:ts-teaser-image="not IS_EMPTY"}
  • #3 / May 12, 2009 11:01am

    jorgepinon

    11 posts

    Looks like that blocks anything at all from displaying. Makes sense, since no weblog has both of those custom fields.

  • #4 / May 12, 2009 11:07am

    e-man

    1816 posts

    Damn, I was kind of hoping it would be able to tell the difference.
    You may have to go with a custom query then.

  • #5 / May 12, 2009 11:08am

    jorgepinon

    11 posts

    OK, I think I got it. This seems to be working:

    {exp:weblog:entries weblog="weblog1|weblog2|newWeblog" search:teaser-image|ts-teaser-image="not IS_EMPTY"}
  • #6 / May 12, 2009 11:09am

    jorgepinon

    11 posts

    Oops, no sorry.  I was wrong. It’s allowing entries from the blogs, but not requiring the custom fields.

  • #7 / May 12, 2009 11:10am

    Mark Bowen

    12637 posts

    Whilst the documentation does say that you can use more than one search parameter at a time (although they do have to be on different fields) that does also mean that it is an AND instead of an OR or at least I’m pretty sure it is. Judging by what you’ve posted it seems to indicate this too.

    Might make a nice feature request though 😉

    The only other way to do this would probably be a SQL query although that could possibly get complex depending on the exact needs.

    Best wishes,

    Mark

  • #8 / May 12, 2009 11:12am

    e-man

    1816 posts

    Really? Cool, that syntax isn’t even in the docs.

  • #9 / May 12, 2009 11:13am

    Mark Bowen

    12637 posts

    OK, I think I got it. This seems to be working:

    {exp:weblog:entries weblog="weblog1|weblog2|newWeblog" search:teaser-image|ts-teaser-image="not IS_EMPTY"}

    Yep unfortunately that’s not allowed to be done using the current search parameter. You can split up more than one condition to test for but not the actual search field unfortunately.

    Definitely might be worth a feature request this one.

  • #10 / May 12, 2009 11:19am

    e-man

    1816 posts

    What if you try this:

    {exp:weblog:entries weblog="weblog1|weblog2|newWeblog"} 
    {if teaser-image != "IS_EMPTY" OR ts-teaser-image != "IS_EMPTY"}
    
    output here….
    
    {/if}
    {/exp:weblog:entries}
  • #11 / May 12, 2009 11:28am

    Mark Bowen

    12637 posts

    Good idea that e-man.

    Only thing I see with that is that you are really just hiding content that you don’t want. The query could still effectively (depending on the site) be pulling back hundreds and hundreds of entries. Would be nice if this was a feature of the search parameter just for those reasons really. I know I could have used it a few times before now as I’ve had to write quite lengthy queries in the past to do these sorts of things.

  • #12 / May 12, 2009 11:29am

    jorgepinon

    11 posts

    Nope. Looks like IS_EMPTY only works on the search parameter. 

    {if teaser-image !="" OR ts-teaser-image != ""}

    works but doesn’t do what the search parameter is good for, meaning it doesn’t skip to the next post in line if the most recent doesn’t have the image. We still need *something* to show up.


    I added the feature request in the meantime.

  • #13 / May 12, 2009 11:33am

    jorgepinon

    11 posts

    and by the way e-man, I got really excited when I read your comment. Good idea.

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

ExpressionEngine News!

#eecms, #events, #releases