1

I created a drupal custom module for my website, the module functionality is it display list of students who have registered in my site. Now I want to update my custom module with search functionality, the search function should like google search function.

My custom module look like following structure

Current Module Look like

Now I want to implement the search function in my custom module. When I search using the fields of the table like student name, gender, author name, and status, how do I do this?

Expecting result

7
  • 2
    Write more details about the setup - how do you define students: as entities, user profiles, node types or you do manually everything? You could use Views to build the tables on screenshots and it will provide you with filters for searching as well. Commented Oct 1, 2013 at 7:09
  • I do manually everything. can you please explain how to make this in views.
    – vinox
    Commented Oct 1, 2013 at 7:14
  • 1
    In that case check out hook_views_data() as it will allow you to display content in custom tables through views. However, I'd strongly recommend to use views if possible - it will give you caching, paging, filters and much much more out of the box. You may need to reorganize your setup, but it will be worth of it in the long run. Commented Oct 1, 2013 at 7:17
  • See this question for more information. Commented Oct 1, 2013 at 7:20
  • 1
    Just curious - how come you are new to Views yet built a module that has database queries, schema definition and other complex stuff ?
    – AKS
    Commented Oct 1, 2013 at 13:50

1 Answer 1

0

You have few options:

  1. Use hook_views_data() to hook your custom tables with Views.

  2. Use Data module as it features automatic integration with Views.

  3. Reorder your setup to use Drupal's node type/user profile/entity, which has Views support out of the box.

Doing it really manually will be a waste of time, unless you need some very specific functionality that can be hardly achieved by using Views for it.

Views will also provide you with caching, paging and it will be easier to maintain it in the future.

Not the answer you're looking for? Browse other questions tagged or ask your own question.