Search In Navigation Bar

How guys, how do i make a search field in the navigation bar, that searches through two to three columns of different tables? Kind of like the one yii have.

I would prefer not to use any extensions unless it is the last option.

What do you mean with navigation bar?

The navigation menu at the top of the page next to the logo

– EDIT –

I’ve always just thought of it as “navigation bar” since that’s what they call it at w3schools.com

http://www.w3schools.com/css/css_navbar.asp

Ok. You can launch, for example, actionNavigationBarSearch,

passing parameters as this: /controller/navigationBarSearch?ArrFields[attr1]=1&ArrFields[attr2]=ok

where you can write:




function actionNavigationBarSearch()

{

      $obj = new ClassTest('search');

      $obj->unsetAttributes();

   

      if (isset($_GET['ArrFields']))

      {

           $obj->attributes = $_GET['ArrFields'];

      }


      $this->render('navigation_bar_search', array('model' => $obj);

}



Then in your navigation_bar_search.php view you have:




<?php $this->widget('GridViewServizi', array(

    'id'=>'navbarsearch-grid',

    'dataProvider'=>$model->search(),

    'filter'=>$model,

    'columns'=>array(

       array(

         .....

         ....



search() is template method in your model class.

Thanks :)

Is there a way not to do this with using the gridview? I mean, i want the search bar integrated in my navigation-menu at all pages of the site, and i can’t see why one should use gridview in such a situation?

Sure! You do not necessarily have to use a grid.

You can display results as you want (list, grid, ec…)

How can i display it as just a label in the navigation menu, and redirect to a page with the search results in a list view?

If i put something like this in my layouts/main.php file, how should the /product/admin.php view file and the productController look like?


<?php echo CHtml::form(Yii::app()->createUrl('product/admin'), 'get') ?>

            <?php echo CHtml::textField('search') ?>

            <?php echo CHtml::submitButton('search'); ?>

    <?php echo CHtml::endForm() ?>

Or should the form in the main.php file look different somehow?