Hi all,
I’ve never written an Extension before so I will take the time to learn but I wanted to know if this would make an ideal Extension.
Basically I want to change the output of the {exp:search:simple_form} tag.
I want to be able to list the available weblogs, the ability to choose any number of them then output them as a select or option list.
I had to hack the mod.search.php and comment out this line -
'weblog' => $TMPL->fetch_param('weblog'),
So I could create my own select list like this -
{exp:search:simple_form search_in="everywhere" name="archive_search" results="5"}
<input type="text" name="keywords" id="search_input" class=formText value="" maxlength="30" />
<select id="search_select" name="weblog">
<option value="archive_photos">Photos</option>
<option value="archive_written">Written Accounts</option>
</select>
<input type="submit" value="Go" id="search_submit" />
{/exp:search:simple_form}
I’m sure it will take me about 6 months but they say if you have a worthy project, it makes the learning experience better!
How about just using a cut-down version of the advanced search form instead?
{exp:search:advanced_form result_page="search/results"}
<input type="text" class="input" maxlength="100" size="40" name="keywords" />
<input type="hidden" name="search_in" value="everywhere">
<input type="hidden" name="where" value="all">
<select id="weblog_id" name='weblog_id[]' class='multiselect' size='12' multiple='multiple' onchange='changemenu(this.selectedIndex);'>
{weblog_names}
</select>
<input type='submit' value='Search' class='submit' />
{/exp:search:advanced_form}
Forms have an interesting behavior that you can utilize, Steven, that the last form element encountered with a given name= attribute will be the one sent with the request, so placing your own in the form like you show in your original post will work - a quick test confirms. You are override anything that is provided in the hidden form element by adding another on later in the form.
No, and though it looks like that’s not what he wants to do, it’s not hard to build the id’s needed if that’s what one wanted, adding a weblog_id[] array field:
<select id="search_select" name="weblog_id[]" multiple size="1">
{exp:query sql="SELECT weblog_id, blog_title FROM exp_weblogs"}
<option value="{weblog_id}">{blog_title}</option>
{/exp:query}
</select>
Forms have an interesting behavior that you can utilize, Steven, that the last form element encountered with a given name= attribute will be the one sent with the request, so placing your own in the form like you show in your original post will work - a quick test confirms. You are override anything that is provided in the hidden form element by adding another on later in the form.
Strange that this didn’t work for me. I probably got it mixed with the results template problem and assumed it didn’t work.
I’ll give it a go and that will negate any need to hack mod.search.php 😊
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.