I have a page that displays a list of a folder of content and I've been asked to write a simple search that purely relates to the content that displayed on this page and I come from a usercontrol/webforms background. Using this approach I would have built a dataset of the content filtered it by what the user is posting in the search field and then returned these results back to the page but I'm trying to get away from the whole webforms area and into MVC/Razor.
Currently there isn't even a search field on the page as I'm unsure of how to even reference a field in Razor code. Could someone point me in the right direction please?
This is how I'm currently rendering the content to the page....
@{var node = Umbraco.TypedContent(1091);} @{ foreach (var child in node.Children) { <h4><a href="@child.Url">@child.GetPropertyValue("courseTitle")</a></h4> <p>@child.GetPropertyValue("courseDescriptionSnippet")</p> if (@child.GetPropertyValue("courseImage") != "" && @child.GetPropertyValue("courseImage") != null) { var link = Umbraco.TypedMedia(@child.GetPropertyValue("courseImage")); <img src="/imagegen.ashx?width=150&[email protected]" /> } } }
Perhaps you should take a look at the ezSearch package, it a seach functionally package for MVC sites, like the good old XSLTsearch with this package you can configure which fields, and document types that should be searchable.
I am currently working on a project where we are using ez Search for search functionality.
The project is running Umbraco 7.2.1. So I think that you can use it for Umbraco 7.2.4 also. But if you decides to give the package a try. Then I would installed it on a test environment, and remember to take a backup before so you can make database rollback in the case something went wrong.
There should be no issues using EZSearch on 7.2.4 - So you should be able to get it working. But as Dennis says make sure to keep a backup to be on the safe side. I think it should be enough to just backup files for this package though - Don't think it installs anything in the database.
Thanks for both your replies, the request has mutated into more of a custom search with filtering checkboxes etc.So I think that I'll have to write some sort of a custom control.....all I've got to work out is how to do it!
Ok...but perhaps you can base it upon EZsearch by just modifying the source to accomodate your needs? I suppose that the checkboxes represents some search keywords somehow?
Anyway...start with figuring out the exact way it should work and then sketch it out and then you can see if EZSearch can be build upon - I think the source is public somewhere.
Rather than use the ezSearch plugin, I'd actually like to try and build something myself to try and learn the MVC way. So what I need to do is the following...
1) Using the MVC 'framework' get a list of all child nodes under a certain node (which I've done in Razor) and display this complete list on a page by default.
2) Somewhere on this page have a search textbox which when something is entered search through the child nodes and finds matches and then display this filtered list to the page
3) The page will also have a series of checkboxes that relate to specific properties in the child nodes that they may or may not contain. Again when selected filter the list again.
Searching in Razor
Hi all,
I'm after some advice really....
I have a page that displays a list of a folder of content and I've been asked to write a simple search that purely relates to the content that displayed on this page and I come from a usercontrol/webforms background. Using this approach I would have built a dataset of the content filtered it by what the user is posting in the search field and then returned these results back to the page but I'm trying to get away from the whole webforms area and into MVC/Razor.
Currently there isn't even a search field on the page as I'm unsure of how to even reference a field in Razor code. Could someone point me in the right direction please?
This is how I'm currently rendering the content to the page....
Any help would be greatly appreciated
Thanks, Craig
Hi Craig,
Perhaps you should take a look at the ezSearch package, it a seach functionally package for MVC sites, like the good old XSLTsearch with this package you can configure which fields, and document types that should be searchable.
https://our.umbraco.org/projects/website-utilities/ezsearch
Hope this can be a solution for you.
/Dennis
Hi Dennis,
Thanks for that but it looks like its not compatible with the version that I'm running 7.2.4 (probably should have put that in the original post!).
Thanks,
Hi Craig,
I am currently working on a project where we are using ez Search for search functionality.
The project is running Umbraco 7.2.1. So I think that you can use it for Umbraco 7.2.4 also. But if you decides to give the package a try. Then I would installed it on a test environment, and remember to take a backup before so you can make database rollback in the case something went wrong.
/Dennis
Hi Craig
There should be no issues using EZSearch on 7.2.4 - So you should be able to get it working. But as Dennis says make sure to keep a backup to be on the safe side. I think it should be enough to just backup files for this package though - Don't think it installs anything in the database.
Let us know how things turn out.
/Jan
Hi gents,
Thanks for both your replies, the request has mutated into more of a custom search with filtering checkboxes etc.So I think that I'll have to write some sort of a custom control.....all I've got to work out is how to do it!
Thanks
Hi Craig
Ok...but perhaps you can base it upon EZsearch by just modifying the source to accomodate your needs? I suppose that the checkboxes represents some search keywords somehow?
Anyway...start with figuring out the exact way it should work and then sketch it out and then you can see if EZSearch can be build upon - I think the source is public somewhere.
Cheers, Jan
Thanks gents,
I'm actually going around in circles on this!
Rather than use the ezSearch plugin, I'd actually like to try and build something myself to try and learn the MVC way. So what I need to do is the following...
1) Using the MVC 'framework' get a list of all child nodes under a certain node (which I've done in Razor) and display this complete list on a page by default.
2) Somewhere on this page have a search textbox which when something is entered search through the child nodes and finds matches and then display this filtered list to the page
3) The page will also have a series of checkboxes that relate to specific properties in the child nodes that they may or may not contain. Again when selected filter the list again.
Could someone give me a starting point please?
Thanks,
Craig
is working on a reply...