Dnn search functions

Source: Internet
Author: User
Tags dnn dotnetnuke
Dotnetnuke (dnn) search, index indexing provider, search input, search results, moduleindexer

Submitted by admin on Saturday

Based on the searchinput module, the searchinput module can specify the search range and search for additional fields, such as searching by book number or author.

Although the module created by dotnetnuke implements the isearchable interface on the controller, the content of the module may not be searched by the dnn search module, after tracking and investigation, we found that we should change the supportfeatures field value recorded in the topmodules les table of this module in the database to 2 or 3, and then re-index it, then the content (data) in the new module can be searched by dnn.

 

Each search input module in dnn must specify a search result module to display the search results. If you create your own searchinput or searchresults module, You need:
1. Create a new page (Tab) and put a searchresult module in it.
2. Go to settings of the searchinput module and specify to use this page (Tab) to display the search results.

Later, I want to add a mode to dnn's searchinput, that is, a simple search mode (two search condition boxes) and an advanced mode (eight Search Condition boxes ), you also need to add a control option on the settings page to control whether the display mode is simple or advanced.

 

In simple mode, there is a link to jump to advanced mode. if multiple pages of a website (portal) contain a searchinput module in advanced mode, you can set the page to jump to on the settings page.

Then, the customer needs to combine two search results into one, that is, the default searchresults of dnn, and the product search result generated by searching the customer's proprietary product database, this job also took me a lot of time. Because we need to merge the two paging mechanisms, that is, by default, the two search results lists each have a paging navigation button (Link), and the number of results returned by the two lists is different, therefore, we need to combine the largest set of the two into a paging navigation button (link ).
2006-07-17:
Some fields (such as product numbers and keywords) in a module created for the customer must be searched by the default search function of dnn. The public function getsearchitems (byval modinfo as entities. modules. moduleinfo) as services. search. searchiteminfocollection implements entities. modules. isearchable. the getsearchitems is modified so that special fields such as the product number in the customer module can also be searched. it is found that the default dnn search is separated by spaces, so you need to convert the comma into spaces, and then go to host> Search admin> re-index content, if the content of the module has not changed, re-index content does not work. Therefore, you must update the content of the module and re-index content, if the product number is a number, remember to include numbers. to check why your content cannot be found, go to the searchword table.
2006-07-17:
Then, the customer needs to index the META keywords on each page so that they can be searched by the default search function of dnn. Dnn's default moduleindexer is based on modules. It indexes, stores, and searches keywords as the content of a module, and a page contains multiple modules, it is impossible to simply implement the isearchable interface on the module. Therefore, you can only create an indexprovider by yourself, based on the moduleindexer code.

 

Modify web. config to use the newly created moduleindexprovider, as shown below:

<providers><clear /><!--<add name="ModuleIndexProvider" type="DotNetNuke.Services.Search.ModuleIndexer, DotNetNuke.Search.Index" providerPath="~\Providers\SearchProviders\ModuleIndexer\" />--><add name="XXX_ModuleIndexProvider" type="DotNetNuke.Services.Search.XXX.ModuleIndexer, XXX.Search.Index" providerPath="~\Providers\SearchProviders\XXX_ModuleIndexer\" /></providers>

Modify the getsearchindexitems method. The modified code is as follows:

Public Overrides Function GetSearchIndexItems(ByVal PortalID As Integer) As SearchItemInfoCollectionDim SearchItems As New SearchItemInfoCollectionDim SearchCollection As SearchContentModuleInfoCollection = GetModuleList(PortalID)For Each ScModInfo As SearchContentModuleInfo In SearchCollectionTryDim myCollection As SearchItemInfoCollectionmyCollection = ScModInfo.ModControllerType.GetSearchItems(ScModInfo.ModInfo)If Not myCollection Is Nothing ThenSearchItems.AddRange(myCollection)End IfCatch ex As ExceptionLogException(ex)End TryNext'*************************************************'  add page meta keywords to search index resultDim arrTabs As ArrayListDim objTabController As New TabControllerarrTabs = objTabController.GetAllTabsDim i As IntegerFor i = 0 To arrTabs.Count - 1Dim objTab As TabInfo = CType(arrTabs(i), TabInfo)Dim aModuleIdOnThisTab As Integer'get a module id on this tabDim objModuleController As New ModuleControllerDim objModule As New ModuleInfoDim intIndex As IntegerDim arrModules As ArrayList = objModuleController.GetPortalTabModules(objTab.PortalID, objTab.TabID)For intIndex = 0 To arrModules.Count - 1objModule = CType(arrModules(intIndex), ModuleInfo)'get a dedicated module on this pageIf objModule.AllTabs = False ThenaModuleIdOnThisTab = objModule.ModuleIDExit ForEnd IfNextDim SearchItem As SearchItemInfo = New SearchItemInfo(objTab.Title, objTab.Description, 9999, Now, aModuleIdOnThisTab, "", objTab.KeyWords.Replace(","c, " "c), "", Null.NullInteger)SearchItems.Add(SearchItem)Next'*************************************************Return SearchItemsEnd Function

In fact, the module on a tab (PAGE) is used to store searchitem, because the default dnn method is to search based on modules. If there is no module on a page, then its meta keyword cannot be searched.

The above Code also excluded the modules that will be displayed on all pages, because such modules will mistakenly bring the meta keyword on a page to other pages, this is because the modules are displayed on all pages. I thought this was the case after a rough test.

2006-07-25:
Modified to exclude the possibility of selecting the deleted module to store the searchitem. some problems are found: In a sense, this is already in hacking dnn, because this task is beyond the inherent structure and existing structure of dnn. if a page contains some invisible junk structure data generated by disorderly operations, the page META keywords index and the search for the page may fail. for example, data in tabmodules and modules tables is messy. For example, a module exists in a deleted pane, or data in tabmodules and modules tables is messy anyway, I will delete all tabmodules and modules tables, or delete out-of-the-box module records, and re-index them again. I can index and search for the page meta key words on the problematic page.

There is also a way to ensure that the selected module is absolutely no problem: in the upper part of the same method, the IDs of the modules with the same Tabid in the generated sew. EMS default dnn.

Of course, there is another way of thinking to achieve it. The general idea is similar to implementing banner ads indexing and searching. See below.

The customer needs text in the banner module, and the script should also be indexed to be searchable.
Banner is used to put advertisements on the website. The hyperlink URL of the advertisement bar that the customer wants to search on the search results page directs to the target URL of the advertising customer, instead of containing the banner page on the dnn website.
Finally, I added the following code to moduleindexer. VB:

 

'##########################################' index Text, Script AdsDim objBannerController As New Services.Vendors.BannerController'get all searchable bannersDim bannerAryList As ArrayList = objBannerController.GetBanners(-1)For Each bi As BannerInfo In bannerAryListDim sii As SearchItemInfo = New SearchItemInfo(bi.BannerName, bi.Description, 65535, Now, moduleIdPicked, "", bi.BannerName & " - " & bi.Description)SearchItems.Add(sii)Next'##########################################

Run the following SQL script:

set ANSI_NULLS ONset QUOTED_IDENTIFIER ONgoALTER procedure [dbo].[GetBanners]@VendorId intasselect BannerId,BannerName,URL,Impressions,CPM,Views,ClickThroughs,StartDate,EndDate,BannerTypeId,Description,GroupName,Criteria,Width,Heightfrom   Bannerswhere(VendorId = @VendorId)OR((@VendorId = -1) AND ((BannerTypeId = 6)OR(BannerTypeId = 7)))order  by CreatedDate desc

And made some modifications on searchresults. ascx, and finally succeeded.

2006-07-24:
After deploying the moduleindexer to the test server for testing, the system found that nothing could be found. No new words were added to the searchword table, so I thought something went wrong and I called it for a long time.

 

In fact, I found that I made two mistakes:
1. When modifying web. config

    <searchIndex defaultProvider="OSV_ModuleIndexProvider"><providers><clear /><add name="OSV_ModuleIndexProvider" type="DotNetNuke.Services.Search.OSV.ModuleIndexer, OSV.Search.Index" providerPath="~\Providers\SearchProviders\OSV_ModuleIndexer\" /></providers></searchIndex>

The place where Add name... is changed below, and the above defaprovider provider forgot to change.

2.
Host> the maximum word length and Minimum word length fields in search admin are reversed. At that time, I did not pay attention to them. I filled in a small number and entered a large number below. the results can be imagined. Of course, no index (Search) is available. only numbers can be indexed (searched.

2006-07-24:

 

In getsearchitems of the controller of the module
Dim searchitem as searchiteminfo = new searchiteminfo (...
The date (pubdate) in this line of code is very important. I set it to now to keep the index and search results up-to-date. if it is not now, you need to update the text intentionally so that you can find the latest changes on other additional customer fields.

Moduleindexer found. try in the getsearchindexitems method in VB is very important. If it is not properly configured, re-index will cause an error. Therefore, after re-configuring try, other searchitems can be output even if an error occurs in a line. The Code is as follows:

        Public Overrides Function GetSearchIndexItems(ByVal PortalID As Integer) As SearchItemInfoCollectionDim moduleIdPicked As IntegerDim SearchItems As New SearchItemInfoCollectionDim SearchCollection As SearchContentModuleInfoCollection = GetModuleList(PortalID)TryFor Each ScModInfo As SearchContentModuleInfo In SearchCollectionTryDim myCollection As SearchItemInfoCollectionmyCollection = ScModInfo.ModControllerType.GetSearchItems(ScModInfo.ModInfo)If Not myCollection Is Nothing ThenSearchItems.AddRange(myCollection)moduleIdPicked = ScModInfo.ModInfo.ModuleIDEnd IfCatch ex As ExceptionLogException(ex)End TryNext'##########################################' index Text, Script AdsDim objBannerController As New Services.Vendors.BannerController'get all searchable bannersDim bannerAryList As ArrayList = objBannerController.GetBanners(-1)For Each bi As BannerInfo In bannerAryListTryDim sii As SearchItemInfo = New SearchItemInfo(bi.BannerName, bi.Description, 65535, Now, moduleIdPicked, bi.URL, bi.BannerName & " - " & bi.Description, "OsvAdsBanner")SearchItems.Add(sii)Catch ex As ExceptionLogException(ex)End TryNext'##########################################'*************************************************'  add page meta keywords to search index resultDim arrTabs As ArrayListDim objTabController As New TabControllerarrTabs = objTabController.GetAllTabsDim i As IntegerFor i = 0 To arrTabs.Count - 1Dim objTab As TabInfo = CType(arrTabs(i), TabInfo)Dim aModuleIdOnThisTab As Integer'get a module id on this tabDim objModuleController As New ModuleControllerDim objModule As New ModuleInfoDim intIndex As IntegerDim arrModules As ArrayList = objModuleController.GetPortalTabModules(objTab.PortalID, objTab.TabID)For intIndex = 0 To arrModules.Count - 1TryobjModule = CType(arrModules(intIndex), ModuleInfo)'get a dedicated module on this pageIf objModule.AllTabs = False ThenaModuleIdOnThisTab = objModule.ModuleIDExit ForEnd IfCatch ex As ExceptionLogException(ex)End TryNextDim SearchItem As SearchItemInfo = New SearchItemInfo(objTab.Title, objTab.Description, 9999, Now, aModuleIdOnThisTab, "", objTab.KeyWords.Replace(","c, " "c), "", Null.NullInteger)SearchItems.Add(SearchItem)Next'*************************************************Catch ex As ExceptionLogException(ex)End TryReturn SearchItemsEnd Function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.