Stéphane Bebrone
New Member Posts:31
|
01/05/2010 11:54 PM |
|
Hi,
I'd like to create a custom UI for the search feature. How can I achieve such a task?
I've seen that there is a SearchController available but I find it weird that the static search method has void as return type.
Any ideas?
That's very important since our customer doesn't like the out-of-the-box search dialog.
Thank you,
Stéphane. |
|
|
|
|
Peter Donker
Veteran Member Posts:4536
|
01/06/2010 10:02 PM |
|
Hi Stéphane,
Search 'pumps' search results into an SQL table. Then you can draw out the data again with the correct permissions. That is the mechanism that is being used. So the search command does not return anything. It deletes the old search and sets the new one.
if you have the partial src version you'll see the process in Search.ascx. It primes the search with an id that starts with the current date (so the module can weed out old searches). It then binds a grid to (New Services.Search.SearchController).GetGridContents to get the search results.
Peter
|
|
|
|
|
Stéphane Bebrone
New Member Posts:31
|
01/07/2010 8:41 AM |
|
Hi Peter,
Thanks for the info. Unfortunately I don't have the partial source. I've seen that there is a "search identifier" expected as parameter (string), what's the pattern to be used?
Thank you, Stéphane. |
|
|
|
|
Stéphane Bebrone
New Member Posts:31
|
01/07/2010 10:16 PM |
|
I think I got it, you're using the SessionId. That's pretty logic when you're dealing with user concurrency.
Gtz,
Stéphane. |
|
|
|
|
Peter Donker
Veteran Member Posts:4536
|
01/12/2010 10:22 AM |
|
Hi Stéphane,
Correct. You need to cater for the possibility of unauthenticated users. The Session ID is the only thing you have then.
Peter |
|
|
|
|
jsumant
New Member Posts:20
|
04/13/2010 6:19 PM |
|
Hi Peter/Stéphane,
I am trying to develop custom search control where I am using tabstrip UI similar to what appears in search pop-up control through Tools menu of ViewCollection.ascx control. But instead of using callback similar to ViewCollection.ascx, I want to bind search results on button click event. Please find the code written in button click event handler as follows:
Protected Sub lnkbtnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkbtnSearch.Click
Select Case TabStrip2.SelectedTab().Value() Case "rawsearch" Dim strRaw As String = txtRawSearch.Text SearchController.Search(Me.PortalId, Session.SessionID, strRaw, Me.Settings.ModuleSettings.BaseRootId, True, True, True) Case "regularsearch" Case Else 'quick search Dim strSearchTerm As String = txtQuickSearch.Text.Trim() Dim iCollectionId As Integer = Me.Settings.ModuleSettings.BaseRootId Dim lstSearchTerms As System.Collections.Generic.List(Of SearchTerm) = New System.Collections.Generic.List(Of SearchTerm)
Select Case rblFields.SelectedValue Case "all"
Case "core" Dim obj As SearchTerm = New SearchTerm() obj.Field = "Title" obj.Inclusion = IncludeType.Include obj.Join = JoinType.Or obj.SearchString = strSearchTerm obj.Tokenize = False lstSearchTerms.Add(obj) Case Else Dim obj As SearchTerm = New SearchTerm() obj.Field = "title" obj.Inclusion = IncludeType.Include obj.Join = JoinType.Or obj.SearchString = strSearchTerm obj.Tokenize = False lstSearchTerms.Add(obj) End Select
Select Case rblScopeQ.SelectedValue Case "folder" Case "all" iCollectionId = Me.Settings.ModuleSettings.BaseRootId Case Else iCollectionId = Me.Settings.ModuleSettings.BaseRootId End Select
SearchController.Search(Me.PortalId, Session.SessionID, lstSearchTerms, iCollectionId, True, True, True)
End Select
Dim objSearchController As Bring2mind.DNN.Modules.DMX.Services.Search.SearchController = New Bring2mind.DNN.Modules.DMX.Services.Search.SearchController() Dim results As Object = objSearchController.GetGridContents(Me.PortalSettings, Me.TabId, Me.ModuleId, Me.Settings.ModuleSettings, Me.UserInfo, Me.UserInfo.IsInRole("Administrator"), Session.SessionID)
If CType(results, System.Data.DataView).Table.Rows.Count > 0 Then dgResults.DataSource = results dgResults.DataBind() End If
End Sub
With this code I am not getting expected results. "results" object doesn't contain any records for the search.
If I put last few lines of code starting from objSearchController declaration in Page_Load of control and before requesting the page where custom search control is placed, I search for the term in DNN+DMX Search,records similar to what are displayed on DMX search page are displayed in custom search control.
Hence I came to a conclusion that either I am missing something in Search() call or not using proper API call for search.
Appreciate your valuable suggestion.
|
|
|
|
|
Peter Donker
Veteran Member Posts:4536
|
04/16/2010 10:14 AM |
|
Hi Sumant,
Try this
Protected Sub lnkbtnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkbtnSearch.Click
Select Case TabStrip2.SelectedTab().Value()
Case "rawsearch"
Dim strRaw As String = txtRawSearch.Text
SearchController.Search(Me.PortalId, Session.SessionID, strRaw, Me.Settings.ModuleSettings.BaseRootId, True, True, True)
Case "regularsearch"
Case Else
'quick search
Dim strSearchTerm As String = txtQuickSearch.Text.Trim()
Dim iCollectionId As Integer = Me.Settings.ModuleSettings.BaseRootId
Dim lstSearchTerms As System.Collections.Generic.List(Of SearchTerm) = New System.Collections.Generic.List(Of SearchTerm)
Select Case rblFields.SelectedValue
Case "all"
Case "core"
Dim obj As SearchTerm = New SearchTerm()
obj.Field = "Title"
obj.Inclusion = IncludeType.Include
obj.Join = JoinType.Or
obj.SearchString = strSearchTerm
obj.Tokenize = False
lstSearchTerms.Add(obj)
Case Else
Dim obj As SearchTerm = New SearchTerm()
obj.Field = "title"
obj.Inclusion = IncludeType.Include
obj.Join = JoinType.Or
obj.SearchString = strSearchTerm
obj.Tokenize = False
lstSearchTerms.Add(obj)
End Select
Select Case rblScopeQ.SelectedValue
Case "folder"
Case "all"
iCollectionId = Me.Settings.ModuleSettings.BaseRootId
Case Else
iCollectionId = Me.Settings.ModuleSettings.BaseRootId
End Select
SearchController.Search(PortalId, DateTime.Now.ToString("yyyyMMdd") & Session.SessionID, lstSearchTerms, iCollectionId, True, True, True)
End Select
Dim objSearchController As Bring2mind.DNN.Modules.DMX.Services.Search.SearchController = New Bring2mind.DNN.Modules.DMX.Services.Search.SearchController()
Dim results As Object = objSearchController.GetGridContents(PortalSettings, TabId, ModuleId, Settings.ModuleSettings, User, User.IsInGodMode, "")
If CType(results, System.Data.DataView).Table.Rows.Count > 0 Then
dgResults.DataSource = results
dgResults.DataBind()
End If
End Sub
|
|
|
|
|
Peter Donker
Veteran Member Posts:4536
|
04/16/2010 10:17 AM |
|
Quick note about the above code: The latest DMX versions expect a DMXUser object instead of UserInfo. This DMXUser object is pervasive throughout the code and upon construction does the "is admin" check (it's ridiculous the regular UserInfo doesn't do this yet, but that's another story).
Also you need to prefix the search results with a date stamp so that cleanup can take place of this table at regular intervals.
Peter |
|
|
|
|
jsumant
New Member Posts:20
|
04/16/2010 12:33 PM |
|
Thanks Peter,
With the help of partial source code, I managed to figure out what I was missing. Previously I was not prefixing date stamp to session id while creating search id.
|
|
|
|
|