Forum

Thread tagged as: Question, Installation, Addons

adding search app

Hello,

Up and above the documentation, are there any tutorials or downloads available that show how Perch Search App can be included in a site?

Thanks Mmc

Martin McKenzie

Martin McKenzie 0 points

  • 6 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

There should be an example search page in your Perch download, there isn't a lot more to it than that shows. If you are having a specific problem then show us where you have got to so we can help.

Thank you

MMc

I can't figure out how to include the search on multiple pages of a site?

At the moment the search box is included on the pages but then the results are displayed on the same page not a separate page of results by themselves.

I don't know wether I should be editing the php or the result/form html pages in the template?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Where are you posting your search form to? Which URL? It should be your SRP.

I've just copied the following code from your example into a div on my website.

It presents a search box on pages but then the search results come out on the same page? I can't see a url in the example search page?

Copied in code below:

<div class="wrapper cols2-nav-right">
    <div class="primary-content">
        <?php 
            $query = perch_get('q');  // 'q' query string argument e.g. search.php?q=apples
            perch_content_search($query);
        ?>
    </div>
    <nav class="sidebar">
       <?php perch_search_form(); ?>
    </nav>
</div>
<?php perch_get_javascript(); ?>
Drew McLellan

Drew McLellan 2638 points
Perch Support

perch_search_form() displays the search form. You're just using the default template. You can edit it in the templates/search folder.

Okay, I'll try that - so it's just a case of adding <?php perch_search_form(); ?> to each page and then editing the html documents in the search folder.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is that not working? What have you tried and how does it fail?

Hi Martin,

At the moment the search box is included on the pages but then the results are displayed on the same page not a separate page of results by themselves.

If you want the results to appear on a dedicated page (e.g. my-search-results.php), you need to set the action in the search-form.html template (in templates/search folder):

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

You'll also need to create the my-search-results.php page and include the search-result.html template.

Hello,

Thanks for all your help - last two comments helped get it working