This project is read-only.

Custom search page that only returns results from specific content type

Topics: Customizing Orchard, General, Writing modules
Jul 4, 2013 at 12:27 PM
First off, please excuse me because I am relatively new to Orchard and brand new to any type of .NET programming. I have a website project that I am working on in Orchard. The site features a main search bar located in the Aside on each page. Indexing on the site has been activated for multiple content types/fields/data as to provide the most complete search results for general users of the site.

My problem is, I do not know how to create a custom search page that would allow specific users to search only specific content types. In this particular example, I am developing a site for a special type of automotive dealership. I have a content type defined as "Vehicle" that contains all of the necessary fields/data that we are looking to collect about each vehicle that is entered. I also have a content type defined as "Vehicle Part." I need to provide some of the users a quick way to search only the Vehicle Part content type. Any suggestions on what would be the easiest way to go about doing this? If there are any tutorials on such a process, the help would be greatly appreciated. Looking forward to hearing any feedback!
Jul 5, 2013 at 7:22 PM
Have you looked into the default search controller which is currently used ?

You should do your own controller which will take any parameter you need, then you can use the ISearchBuilder service to create your custom search query, and then render the results in your own view. It should be pretty straightforward if you have done some modules and MVC before.
Jul 11, 2013 at 2:02 PM
@sebastienros: I am also facing same problem as bwolken has discussed. Will you please explain me how can I create my own custom search query using ISearchBuilder ?
Jul 11, 2013 at 3:59 PM
you create Yours.Search Module first, then copy the whole code from Orchard.Search module, modified the codes as you need ,such as ISearchBuilder
Jul 11, 2013 at 4:09 PM
or if possible , you use supress attribute
Jul 11, 2013 at 5:34 PM
ISearchBuilder is a service to do any full text based query, which means if you can create a module containing a view and a controller, then inject this service into your controller's constructor and you can use it to query your content.

I'd be happy to write a tutorial on how to use the search module, but it has to wait until 1.7 is released.
Feb 20, 2014 at 11:44 AM
@sebros thanx for your help
Orchard1.7.2 is up & running please do this tutorial it will be very usefull