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.

Searching entries via dynamic parameters

September 22, 2010 6:45pm

Subscribe [3]
  • #1 / Sep 22, 2010 6:45pm

    tinyv

    11 posts

    Hey

    Got a wee query was looking for some help on.

    I’ve got a load of structured data stored in custom fields in weblog/channel entries (EE1.6.9). The data corresponds to publications from a channel with a search form for each of four distinct categories.

    Rather than use the built-in EE search I wanted to create my own, structured search form and use this in conjunction with EEs dynamic parameters to perform my own search queries using the {exp:weblog:entries} tag.

    The aim here is really to be able to search against specific custom fields (eg author or publication year) rather than lump them into a single search input. All works fine and get some pretty nice results from this.

    However the one unfavourable outcome of this approach is that to search against custom fields I end up with a HTML input like this:

    <input name="search:title" />

    This is not very nice for two reasons:

    * it invalidates the HTML on my page, and
    * i can’t pair the search field with an associated label

    Can anyone advise on an alternative approach?

    Cheers

    Cole

  • #2 / Sep 22, 2010 7:11pm

    Hydra Solutions

    1 posts

    nm

  • #3 / Sep 22, 2010 7:13pm

    Wes Rice

    103 posts

    Can you use hyphens instead of colons, and enable php parsing on input in your search template to replace hyphens with colons, and then add the dynamic parameters?

  • #4 / Apr 01, 2011 10:40am

    Brian M.

    529 posts

    Curious how you ended up tinyv - I’m in the process of doing basically the same thing.  I’m also wondering how best to get the equivalent of this for the channel entry title with a text input field.  Currently it seems like I can filter with one form but have to use a separate search form if the user is to enter text against the titles.

  • #5 / Apr 01, 2011 10:48am

    tinyv

    11 posts

    Hi Brian

    Afraid I just rooted for the (invalid) approach outlined above.
    The label/input relationship was relatively easy to resolve though - the colon search separator only has to be in the input field name and of course the label is related to the field id, so following works fine:

    <label for="publication-year">Year</label>
    <input name="search:publication-year" id="publication-year" size="4" value=""></p>

    Hope that helps, sorry couldn’t be more helpful.

    Cheers,

    Cole

  • #6 / Apr 01, 2011 10:53am

    Brian M.

    529 posts

    It’s mostly under control here I think 😊


    I believe it’s valid to wrap the label around the input and not use a for parameter at all?

    
    <label>Year<input name="search:publication-year" size="4" value=""></label>
    

    It is for checkboxes/radio (and then the whole label acts as the trigger which is better for accessibility).

  • #7 / Apr 01, 2011 11:05am

    tinyv

    11 posts

    Hi Brian

    I tend to keep the label and input/field separate but both contained within a single block-level element. This gives greater control for styling and is advised as being more suitable (certainly for accessibility purposes) than using the implicit association you posted.

    Interesting discussion at http://www.accessifyforum.com/viewtopic.php?t=6738

    Cole

  • #8 / Apr 01, 2011 11:11am

    Brian M.

    529 posts

    I’m heading down roads I guess I shouldn’t go down 😉 Can you get clickable labels for checkboxes that way?

    If you’re curious or for anyone else looking to do the same thing, I think I’m going to end up using Solspace’s SuperSearch module.  I’ve used it before and I think it will end up saving me time/money and with some added benefits (same type of filtering with titles) rather than continuing to build this out myself.

  • #9 / Apr 01, 2011 11:15am

    tinyv

    11 posts

    Given that radio and checkbox inputs should always have a textual equivalent then yes, just ensure that the “for” and “id"s correspond. Also above does not mean the label has to be first in the sequence. You can have input then label.

    Was giving SuperSearch some serious thought on the above project but at $100 was too expensive to use within the project budgets.

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

ExpressionEngine News!

#eecms, #events, #releases