Thread tagged as: Question

Get search to redirect to search.php


I have a fairly clean install of Perch 2.8.10

My question is regarding the search function of Perch.

When on any page in the website, If I use the standard search form that I have included in the footer, how do I redirect the user to search.php?s=query

Currently the search form simply appends the query onto the current URL.


Adam Menczykowski

Adam Menczykowski 1 points

  • 6 years ago

What does your search form template look like?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you set the action attribute on the form? That controls where it's posted to.

<perch:form id="search" method="get">
        <perch:label for="q">Search</perch:label>
        <perch:input type="search" id="q" />
        <perch:input type="submit" value="Go" />

No I haven't set the action attribute, I simply used the default code that ships with perch. Thanks

Okay so try

<perch:form id="search" method="get" action="/search.php">

That did it, thanks Dexter!

Thanks Dexter. This helped me too.

As an addition to the question above: I have a pop up search box on my navigation bar and by using the method you discribe above it is working beautifully for all the pages in the top level. But the pages in a sub folders ( eg blogs) can't found page when I add the following to the header.

<?php perch_search_form(); ?>

where can I include ../search.php as the path without messing up the top level headers? :-/

Kind regards

Julie :-)

Hi Julie,

As long as you use a root relative path you will be fine.

e.g. /directory/file

different path types are described here:

Of course! :->

Thank you Dexter. :-D

Hi Dexter, another small problem you may be able to solve for me.

My search box has an icon button for submit but over it is the 'Submit Query' text from the original search sample page.

Screenshot of popup search box

Where do I go to remove this text, so only the icon is visable. This is the code I am use for the search-form.html:

        <!-- Search --> 
                        <div class="search-include">
                            <div class="search-button">
                                <a href="#"><i class="icon-search"></i></a>
                            <div class="popup-search">
                                <perch:form id="search" method="get" action="/search.php" role="search" >
                                    <perch:input type="search" value="Search." onblur="if(this.value=='') this.value='Search.';" onfocus="if(this.value=='Search.') this.value='';" class="ft" id="q" />
                                    <perch:input type="submit" value="" class="fs" />
                        <!-- /Search -->

Kind regards

Julie :-)