Yii Framework Forum: Search form on every page - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Search form on every page Rate Topic: -----

#1 User is offline   Equ 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 57
  • Joined: 27-November 09
  • Location:Russia, Moscow

Posted 08 December 2009 - 05:06 PM

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.
0

#2 User is offline   Sander 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 169
  • Joined: 03-November 09
  • Location:Amsterdam, Netherlands

Posted 09 December 2009 - 03:24 AM

Put it in views/layouts/main.php
0

#3 User is offline   Equ 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 57
  • Joined: 27-November 09
  • Location:Russia, Moscow

Posted 09 December 2009 - 02:56 PM

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

#4 User is offline   scythah 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 44
  • Joined: 20-April 09

Posted 09 December 2009 - 03:44 PM

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

#5 User is offline   Equ 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 57
  • Joined: 27-November 09
  • Location:Russia, Moscow

Posted 10 December 2009 - 06:15 AM

View Postscythah, on 09 December 2009 - 03:44 PM, said:

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.
0

#6 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 10 December 2009 - 07:42 AM

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.
0

#7 User is offline   Ricardo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 20-August 09
  • Location:Warsaw, Poland

Posted 11 December 2009 - 07:40 AM

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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users