We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Is this suitable for an Extension?

Development and Programming

stinhambo's avatar
stinhambo
1,268 posts
17 years ago
stinhambo's avatar stinhambo

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!

       
stinhambo's avatar
stinhambo
1,268 posts
17 years ago
stinhambo's avatar stinhambo

Just found out there is no hook for that :(

       
silenz's avatar
silenz
1,648 posts
17 years ago
silenz's avatar silenz

I’m almost inclined to say what you want to achieve should be doable without further programming…

       
stinhambo's avatar
stinhambo
1,268 posts
17 years ago
stinhambo's avatar stinhambo

Really? I couldn’t get it to work without commenting out a line in the mod.search.php that adds the hidden weblog field.

       
silenz's avatar
silenz
1,648 posts
17 years ago
silenz's avatar silenz

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}
       
stinhambo's avatar
stinhambo
1,268 posts
17 years ago
stinhambo's avatar stinhambo

MAinly because I didn’t want the big mess of Javascript that is automatically generated.

       
Derek Jones's avatar
Derek Jones
7,561 posts
17 years ago
Derek Jones's avatar Derek Jones

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.

       
silenz's avatar
silenz
1,648 posts
17 years ago
silenz's avatar silenz

True but he can’t do a multiselect with weblog-shortnames, can he?

       
Derek Jones's avatar
Derek Jones
7,561 posts
17 years ago
Derek Jones's avatar Derek Jones

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>
       
silenz's avatar
silenz
1,648 posts
17 years ago
silenz's avatar silenz
No, and though it looks like that’s not what he wants to do,

I understood this

the ability to choose any number of them then output them as a select or option list.

like that’s what he wanted.

       
Derek Jones's avatar
Derek Jones
7,561 posts
17 years ago
Derek Jones's avatar Derek Jones

touche! Still, either need is manageable entirely with the form markup, without requiring any extensions or hacking.

       
silenz's avatar
silenz
1,648 posts
17 years ago
silenz's avatar silenz

I never doubted that 😉

       
stinhambo's avatar
stinhambo
1,268 posts
17 years ago
stinhambo's avatar stinhambo
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 😊

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.