Mijo Posted January 19, 2018 Posted January 19, 2018 Hello, I'm having a problem with search form on my website, it throw me an error "Error: Exception: Field does not exist: body (in C:\xampp\htdocs\testweb\wire\core\PageFinder.php line 993)" My search.php (template) is: <?php $q = $sanitizer->text($input->get->q); if($q) { $q = $sanitizer->selectorValue($q); $selector = "title|body~=$q, limit=50"; if($user->isLoggedin()) $selector .= ", has_parent!=2"; $matches = $pages->find($selector); if($matches->count) { echo "<h2>Found $matches->count page(s) matching your query:</h2>"; echo "<ul class='nav'>"; foreach($matches as $match) { echo "<li><a href='$match->url'>$match->title</a>"; echo "<div class='summary'>$match->summary</div></li>"; } echo "</ul>"; } else { echo "<h2>Sorry, no results were found.</h2>"; } } else { echo "<h2>Please enter a search term in the search box (upper right corner)</h2>"; } ?> My form is: <form class='search' action='<?php echo $pages->get('template=search')->url; ?>' method='get'> <label for='search' class='visually-hidden'>Search:</label> <input type='text' name='q' id='search' placeholder='Search' value='' /> <button type='submit' name='submit' class='visually-hidden'>Search</button> </form> This is example from Minimal Site Profile, but I can not make it work, can you please give me some advice,. thank you very much.
DaveP Posted January 19, 2018 Posted January 19, 2018 Hmmm, there's nothing obvious. What happens if you echo $selector?
Mijo Posted January 19, 2018 Author Posted January 19, 2018 10 minutes ago, Roberts R said: Does body field exists? Ohh thank you, my mistake I did not have a body field, now everything works properly,
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now