Jump to content

Enhancing search with additional functions in a custom page class?


gornycreative
 Share

Recommended Posts

I noticed the search template and search page do not seem to be alterable by defining a custom page class.

If I try creating a page class file where

class SearchPage extends Page {

it does not appear to effect the Search page class at all - the page still appears as ProcessWire/Page and none of the public functions I define can be used.

Is this a feature of having a page that uses a Process or is it because it is a system file, or is there a different class it should extend?

  • Like 1
Link to comment
Share on other sites

Looking into it more, I have come to the conclusion that the Search page uses the admin template and as a result falls outside the public facing page class framework. Even though the output from the controller/view is a ProcessWire/Page class, there is no way to extend the pageclass because it is the Process that dominates the function of the page.

If I wanted to modify the Search workflow I could hook into it, but because I actually want to grab url segments and run some query magic to convert them into a complex query to pass to search, I think I will need to set up a unique page and pageclass to do that.

Hopefully someone with more knowledge of the admin side can chime in.

  • Like 1
Link to comment
Share on other sites

I didn't realize there are technically two pages created in the back end for search and both of them are hidden and have system ids - 300 and 1000,

There's a search page under root '/' that's id 1000 and a search page under /*adminhome*/page/ that is id 300 - for admin search.

When I used the name selector by itself in the Tracy console before it grabbed the admin search page but later when I used the template selector it grabbed the public search page.

The public facing search page applied the custom SearchPage page class. I'm in business.

id=300, name=search, template=admin, = the backend search page/process

id=1000, name=search, template=search = the frontend search page/process - and the custom page class gets applied to this page.

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...