Page 1 of 1

CMS 2.0+ Search Form Template [solved]

Posted: Thu Oct 29, 2015 4:12 pm
by howey
Hi, at the risk of being shot down for using Bootstrap, I would like to be able to change the css class that is used on the Search submit form. I can't find anywhere to change this I looked at the template but all the form class detail seems to be generated with the $startform tag.

Code: Select all

{$startform}
<label for="{$search_actionid}searchinput">{$searchprompt}:&nbsp;</label><input type="text" class="search-input" id="{$search_actionid}searchinput" name="{$search_actionid}searchinput" size="20" maxlength="50" placeholder="{$searchtext}"/>
{*
<br/>
<input type="checkbox" name="{$search_actionid}use_or" value="1"/>
*}
<input class="search-button" name="submit" value="{$submittext}" type="submit" />
{if isset($hidden)}{$hidden}{/if}
{$endform}
I have used this template

Code: Select all

{$startform}
<div class="form-group headSearch">
<input type="text" class="search-input" id="{$search_actionid}searchinput" name="{$search_actionid}searchinput" size="20" maxlength="50" placeholder="{$searchtext}"/>
</div>
<button name="submit" value="{$submittext}" type="submit" class="btn btn-default headSearch">Submit</button>
{if isset($hidden)}{$hidden}{/if}
{$endform}
with this tag

Code: Select all

{search inline="false" resultpage="search" submit="Search" formtemplate="search_top"}
Which outputs

Code: Select all

<form id="cntnt01moduleform_1" method="get" action="http://localhost:8888/foundation/" class="cms_form">
<div class="hidden">
<input type="hidden" name="mact" value="Search,cntnt01,dosearch,0" />
<input type="hidden" name="cntnt01returnid" value="34" />
</div>

<div class="form-group headSearch">
<input type="text" class="search-input" id="cntnt01searchinput" name="cntnt01searchinput" size="20" maxlength="50" placeholder="Enter Search..."/>
</div>
<button name="submit" value="Search" type="submit" class="btn btn-default headSearch">Submit</button>
</form>
Therefore I don't get the css class on the form.

Any help pointers would be much appreciated. I can hack my way around this, but I would prefer to be able to tackle it at the root code generation.

Thanks

Re: CMS 2.0+ Search Form Template

Posted: Thu Oct 29, 2015 4:36 pm
by calguy1000
Okay... as an oversight, we forgot to modify the default search form in 2.0.
But... this should still be possible.

Instead of using {$startform} and {$endform}
try using {form_start action=dosearch class="foo"} and {form_end} respectively.

and check out the help for the {form_start} plugin.

Re: CMS 2.0+ Search Form Template

Posted: Thu Oct 29, 2015 5:33 pm
by howey
Hi, thanks for such a quick reply.

I added the tag as suggested and then fiddled with the parameters/tag. Just had to figure out that I had to add the returnid parameter, to make sure the results appeared on the search results page, rather than replacing the content tag on the originating page.

Code: Select all

{form_start action=dosearch class="navbar-form navbar-left" method=get returnid="51"}
<div class="form-group headSearch">
<input type="text" class="search-input" id="{$search_actionid}searchinput" name="{$search_actionid}searchinput" size="20" maxlength="50" placeholder="{$searchtext}"/>
</div>
<button name="submit" value="{$submittext}" type="submit" class="btn btn-default headSearch">Submit</button>
{if isset($hidden)}{$hidden}{/if}
{form_end}
SUCCESS, it seems to work fine. Many thanks, I would never have got there without your help.

NB: I am working in a development environment using MAMP, so I haven't got pretty urls at the moment. Although I wouldn't have thought that would make to much of a difference.

Re: CMS 2.0+ Search Form Template [solved]

Posted: Thu Oct 29, 2015 5:35 pm
by calguy1000
I don't think you technically need to specify the returnid, it should be automatic.