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.

Simple Search question

September 05, 2012 8:09pm

Subscribe [1]
  • #1 / Sep 05, 2012 8:09pm

    julie p

    282 posts

    I have a simple search form on my legacy site, running EE 1.x. The site is a magazine that publishes editions, and has an archive that quickly filters by two dropdowns (Month and Year). The idea is that you can quickly jump to the January 2012 edition and see all the articles. Here’s the simplified search code (month only):

    {exp:search:simple_form channel="editions" result_page="archives/results" where="exact" weblog="editions"}
    <select name="month" class="month">
     <option value="">-month-</option>
     <option value="January">January</option>
     <option value="February">February</option>
     <option value="March">March</option>
     <option value="April">April</option>
     <option value="May">May</option>
     <option value="June">June</option>
     <option value="July">July</option>
     <option value="August">August</option>
     <option value="September">September</option>
     <option value="October">October</option>
     <option value="November">November</option>
     <option value="December">December</option>
    </select>
    <input type="hidden" name="keywords" id="keywords2" value="" />
    <input type="image" src="/images/btn-go.jpg" name="Go" class="submit" />
    {/exp:search:simple_form}

    ok- all’s well and good. EXCEPT!!! They run one edition per year that spans 2 months, so the edition date is July (this is a custom field, date format), but the edition is called July/August. SOOOOO when the user searches for August, they get nothing… What can I do either in the content or the template to allow for the multiple search? I could just have the value for August be “July”, but would prefer a more elegant solution. Thanks!

  • #2 / Sep 07, 2012 2:41pm

    Dan Decker

    7338 posts

    Hi julie p,

    The template above works except for “August”?

    (this is a custom field, date format)

    What field type is this? Is this the complete template?

    Cheers,

  • #3 / Sep 07, 2012 2:58pm

    julie p

    282 posts

    Hi Dan,

    Yep, the field is a custom date field. This is nearly the complete template. We also have a year select with the following code:

    <select name="year" class="year">
    <option value="">-year-</option>
    {exp:query sql='SELECT DISTINCT year(from_unixtime(field_id_12)) AS year FROM exp_weblog_data WHERE year(from_unixtime(field_id_12))>1970 ORDER BY year(from_unixtime(field_id_12)) DESC'} {!-- weird entry in the system --}
        <option value="{year}">{year}</option>
    {/exp:query}
          </select>

    I’m wondering if I should just spit out “July/August” and call it a day

  • #4 / Sep 10, 2012 2:32pm

    Dan Decker

    7338 posts

    I’m wondering if I should just spit out “July/August” and call it a day

    I would say, what’s printed on the issue? Match that in the list, and have the value be what will actually return the result.

    ~

  • #5 / Sep 10, 2012 2:36pm

    julie p

    282 posts

    Yep, that’s what I’m doing now. It is difficult because the client doesn’t have regular naming conventions and sometimes they don’t have the same editions at it turns out. Not a lot we can do about that!!

  • #6 / Sep 11, 2012 11:57am

    Dan Decker

    7338 posts

    julie p,

    Oh… yeah…

    That can be a bit difficult!

    Perhaps a similar but slightly different approach could use Categories? Then the client could ad-hoc, or they *may* be more consistent if there is a controlled vocabulary to choose from?

    Just some ideas there!

    Is there anything else I can assist you with?

    Cheers,

  • #7 / Sep 11, 2012 12:06pm

    julie p

    282 posts

    Nope. i’m good. The entire site is built off these being dates, so I think I’ll keep well-enough alone! Thanks for checking in.

    Julie

  • #8 / Sep 12, 2012 9:53am

    Dan Decker

    7338 posts

    Hey Julie,

    Fantastic!

    If you need anything else, please let us know.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases