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.

Search parameter and conditionals?

November 18, 2010 11:34am

Subscribe [3]
  • #1 / Nov 18, 2010 11:34am

    Mike Mella

    178 posts

    What’s the difference between using a search: parameter to limit my results:

    search:region="canada"

    ..and using a conditional instead?:

    {if region == 'canada'}
  • #2 / Nov 18, 2010 12:43pm

    Ingmar

    29245 posts

    Consider this:

    {exp:weblog:entries weblog="foo" limit="10" search:region="canada" ...}

    vs.

    {exp:weblog:entries weblog="foo" limit="10"}
    {if region == 'canada'} ... {/if}
    {/exp:weblog:entries}

    In the first case you’re getting 10 entries where region=canada, in the latter 10 entries, throwing away the ones that don’t match.

  • #3 / Nov 18, 2010 12:48pm

    Mike Mella

    178 posts

    I see.  So if I don’t have a limit set, there’s no difference?

  • #4 / Nov 18, 2010 12:54pm

    Ingmar

    29245 posts

    Actually, there are. If it’s part of the initial tag EE will modify the query and only pull appropriate entries. Otherwise all entries are pulled, with the conditional determining which ones to show resulting in a heavier load than strictly necessary.

  • #5 / Nov 18, 2010 1:00pm

    Mike Mella

    178 posts

    Okay, that’s what I figured. 
    Thanks Ingmar.

  • #6 / Nov 19, 2010 2:50am

    John Henry Donovan

    12339 posts

    Glad Ingmar was able to help. Feel free to start a new thread if you have any more questions.

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

ExpressionEngine News!

#eecms, #events, #releases