Hi there,
so, I'm quite new to ProcessWire, I am currently building my first site with it, I'm almost done, everything went smoothly.. up until now.
I've been trying to build a search function for hours now and I did get it to work after a while, but not in a very satisfactory manner. As a starting point I used the code from the "site-classic" templates, but the problem is: API-calls don't seem to work.
It all starts off with
if ($q = $sanitizer->selectorValue($input->get->q)) {
Which gives me the following "Error: Call to a member function selectorValue() on a non-object"
Investigating lead me to finding, that it won't just call selectorValue, but also, that $input->get->q does not exist. Actually $input itself is null and so is $sanitizer. Which also leads me to not being able to whitelist q, as I can't call $input->whitelist()
The only way for me to retrieve the query value is via $_GET["q"], which does work.
So this was my main issue.
Another question would be: in the search template of site-classic it is said:
// Search the title, body and sidebar fields for our query text.
// Limit the results to 50 pages.
// Exclude results that use the 'admin' template.
$matches = $pages->find("title|body|sidebar~=$q, limit=50");
But I don't see any constraint actually excluding admin templates. If I enter the term "template" into my search, I get a nice link in my search results into my backend "/processwire/access/permissions/page-template/". How to prevent this?
I hope you can help me with my issues.
Thanks a lot!
a