Forum

Thread tagged as: Question

Search behaviour

Hi Drew,

I'm in the process of adding search to a site. I've added the search form to the navigation so that its accessible from every page, and I've added the code that returns the results at the top of the main content area of each page.

The 4 main areas of the site are different blog sections, each has listing page with the content pulled using

        <?php perch_blog_section(perch_get('s')); ?>
        <?php perch_blog_custom([
        'section'=>'news',
        'template' => 'post_in_list.html',
    ]); ?>

Where "news" is the section name

Each listing then links to the post displayed in post.php - both the listing pages and the post pages have the same standard search results code in them.

The problem I'm having is that when you do a search from the listing page it displays the search results and then subsequently displays the listings. Where as if you do a search on the post page the search results seemly replace all the post content.

I think this is my prefered behaviour, so how can I get the search results to replace the contnent on thel istings page.

Or have I misunderstood how search works and should I have a dedicated search results page? If so how do I point the search form to display the results on that page?

Nick Loat

Nick Loat 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

I would definitely use a dedicated SERP. Set the action attribute on the form tag to point to that page.

Makes sense. Cheers Drew.