How do I change the layout of the search results page?

Topics: Customizing Orchard
Sep 9, 2015 at 9:22 PM

I'm trying to figure out how to modify the way the search results page is rendered. It appears it is just rendering the content title, metadata, and the actual content. Ideally I want to have a list of titles with a link to the item instead.
Sep 9, 2015 at 9:57 PM
Search results are rendered using a Razor view, which you can override in your theme. Looking at the Orchard.Search module, you'll need to create the following folder structure in your Theme's Views folder:

/Views/Orchard.Search/Search and copy in Index.cshtml from \src\Orchard.Web\Modules\Orchard.Search\Views\Search.

Now you can override the rendering of the page as well as each individual content item in anyway you like.
Ideally we would be able to control the DisplayType of the content items being rendered as well so we could use an alternate view for each content item other than Summary, but maybe some day someone will open an issue for that. :)
Sep 9, 2015 at 10:46 PM
Sep 9, 2015 at 11:07 PM
Sep 10, 2015 at 2:12 PM
That is great, thank you guys!
Sep 10, 2015 at 6:34 PM
So working on customizing this, I am trying to group the content items by type.
I know there is a Linq option to write a where clause, but i can't seem to get the right references to linq to have access to the functionality. Anyone have any insight into this?
I have System.Data.Linq but that doesn't work.
In my views in my actual module, i can include System.Linq, but not in my themes project. ALso i try to add the reference manually through themes and cannot find it.
Sep 11, 2015 at 7:07 AM
Edited Sep 11, 2015 at 7:09 AM
Linq should be available without a reference to anything. Note that Linq can only work with strongly typed objects, no dynamics, so you might have to cast your results first to an IEnumerable<IContent> or something. Resharper is really handy when using Linq.