CakePHP framework comes with the default PagesController which is an awesome out of the box way to build a website of mostly static pages. There is one rather annoying limitation though – no search option. If you need a website of mostly static pages with search functionality, you are out of luck. I spent a good chunk of time Googling (searching, eh?) for a solution and even talking to people in #cakephp IRC channel. The best alternatives, it turned out are listed in this StackOverflow answer:
There is no built in way to search static pages as they are just files on disk.
You have three options
- Build a model to hold the data somewhat like a CMS so you can use mysql search.
- google search for sites
- the more hacky approach of reading the contents of all the pages and using preg_match() or similar on the contents to find matches.
The first option is probably the best depending on your use case. The second option is the easiest if its public facing content. The third option is a horrible idea
Since I need the solution for a public facing website, it looks like I’m gonna go with Google Custom Search Engine option.