Forum
Perch Runway Search Blank?
I am attempting to add a sitewide search function in the top layout which sends users to a results page (search.php). The following are my layout, master page, and template snippets.
Master Page (search.php)
<?php
perch_layout('global.top', [
'page_title' => perch_page_title(true),
]);
$query = perch_get('q');
perch_content_search($query, array(
'count'=>10,
'excerpt-chars'=>300,
'template'=>'search_result.html',
));
perch_layout('global.footer');
?>
Search Function in global.top Layout
<?php
perch_search_form(array(
'template'=>'search-nav.html'
));
?>
search_nav.html Template
<div id="search">
<perch:form id="search" method="get" action="/search">
<perch:input type="search" placeholder="search by keyword or sku" class="searchfield" /><perch:input type="submit" value="search" class="searchbutton" />
</perch:form>
</div>
What do you mean by "blank"?
I type something into the search field, hit the submit button, and then the browser navigates to the /search page, but the output on that page is empty without an error. One thing I did notice was that the URL lacked the query suffix of "?q=" after the /search.
Your search field has no ID
Aw jeez, silly mistake. facepalm So, now the URL completes properly and appends the field contents to a ?q=query, but the page has no output at all.
Here's my search field template now
Do you have enough content entered for the search to be able to work?
I have some pages in the site and also a test product in the shop. I have been searching directly for a SKU or a keyword from its listing, but it doesn't show up.
You'll need more content before an SKU search returns anything useful. It should start working from around 30 items.
Would page content from other pages result in anything? I haven't filtered the search yet - it seems like the template should return with "0 results" instead of just an empty page without the static template pieces.
Yes, it would return zero results.
Instead of showing the page framing from the template and saying there are no results like in this template here, it's completely blank on the page as if the template was not processed.
Have you turned on debug to see what it outputs?
I couldn't figure out why debug mode was throwing an error because the file path looked nearly the same - the one difference was that the template called used an underscore, but the actual file used a dash. Good grief, thank you for putting up with my ridiculousness!