Search form on every page

Hi guys!

I have a search form with a php script which queries the database to get search results. How do I integrate it into yii? I need this form to be on every single page of my website and a separate search results page.

Thank you.

Put it in views/layouts/main.php

Is it the right approach just to put everything (including sql queries) in the main.php file?

No, either create a widget for it or put it in a seperate file and include() it.

so, which one is better (performance-wise, etc.)? I’m asking because the search part is one of the main things of my website, if not the main one (it’s an online dictionary).

Thank you.

If you really need it on every page, i’d simply put the form into views/layout/main.php like Sander suggested. That’s the best performance whise, as no other file is required. Then let the form’s action point to some action in your controller that should handle the search and render the search result view.

I agree with Sander and Mike. I didit the same way in my project.