Forum

Thread tagged as: Question

Displaying search results the same way as my post_in_list.html template

How would I set my search-result.html template to output the same layout as my post_in_list.html template?

My post_in_list.html template has 6 items per page and displays 6 blog posts with pagination. So I want my search results to mimic the layout so that it is consistent throughout.

I know that I need to edit the search-result.html template in order to in order to edit the way in which the results are displayed, however I'm clueless as to where to start, any guidance or example would be really appreciated..

Many thanks!

David Springate

David Springate 0 points

  • 7 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

Just edit the markup so it matches what you have used for your blog posts including any CSS classes etc.

Perch isn't generating any other markup for you.

So just to clarify, you mean if I copy over the markup in my post_in_list.html template and place it into the search-result.html template it should display the results the same way?

If that is correct it is something I have tried but none of the perch content is displaying only some static html thats included in the template is currently showing..

Is this because the id's duplicated so its not displaying them twice?

Drew McLellan

Drew McLellan 2638 points
Perch Support

You need to change the tag namespace, but it should do.

Does <perch:showall /> show your content?

<perch:showall /> is displaying a table of ID's and Values, should that be the case?

By changing the tag namespace, do you mean changing all <perch:blog /> to <perch:content /> ?? as I've tried that and its still only displaying the static html content within the template.

Thanks for your help!

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, that's what it does. Are the values you're wanting to display listed in that table?

The videos aren't displaying in the list or value columns and the excerpt is showing as an id but the value box is empty. Both are displaying fine on the post_in_list.html template.

Any ideas?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Does this related to the previous question?

Yes it does, its the answer to your question 'Are the values you're wanting to display listed in that table?'

At the moment the excerpt isn't displaying despite there being one on the post_in_list.html and post.html, as I explained before there is the id 'excerpt' but no value in the <perch:showall /> table. Does this mean I've done something wrong in my other templates as I thought the excerpt would be standard for search results?

If the id doesn't display in the table what does that mean, does it mean I can't use it in the results page?

Many thanks.

Drew McLellan

Drew McLellan 2638 points
Perch Support

And you're on the latest version of both Perch and Blog?

I wasn't but I've just updated both and nothing has changed with regards to whats displaying in the <perch:showall /> table.