26

It often happens that you need to use a module in a scenario that is not the one it was designed for. The core Blog module is quite flexible, but if you plan to use it for publishing your articles, some changes have to be made. Here we want to update all the references from "Blog" to "Articles".

Capita spesso di dover utilizzare un modulo per una applicazione che non è esattamente quella per cui è stato progettato. Il modulo Blog è molto flessibile, ma se lo vogliamo usare come piattaforma per pubblicare i nostri articoli è necessario fare molte modifiche. In questo articolo vogliamo sostituire ogni riferimento a "Blog" con "Articoli".

First of all we need to fix all the references in the resouce files. Once logged in as host, goto Host > Languages > Language Editor > Local Resources > DesktopModules > Blog > App_LocalResources and update all the keys using the word Blog. From now and over, we'll see only the word Articles displayed on our pages, but whenever we perform a search with the DotNetNuke built in search engine this will happen:

Prima di tutto dobbiamo modificare ogni riferimento nei file di risorse. Una volta loggati come host, andiamo su Host > Languages > Language Editor > Local Resources > DesktopModules > Blog > App_LocalResources e modifichiamo Blog con Articoli in ogni ricorrenza. D'ora in poi vedremo solo la parola Artcoli in ogni pagina anzichè Blog, ma quando verrà efffettuata una ricerca usando il motore di ricerca interno di DotNetNuke si otterrà:

Blog search results

To fix this last occurrence, we need to take a look at the source code of the core Blog module. The clue is in the way the module implements the ISearchable interface: the module's FriendlyName is used.

Per aggiornare quest'ultima ricorrenza, dobbiamo dare un'occhiata al codice del modulo Blog. Il problema sta nel modo in cui viene implementata l'interfaccia ISearchable: viene utilizzato il FriendlyName del modulo.

   1: For Each objEntry In Entries
   2:Try
   3:Dim SearchItem As SearchItemInfo
   4:With CType(objEntry, EntryInfo)
   5: Dim UserId As Integer = .UserID
   6: Dim strContent As String = System.Web.HttpUtility.HtmlDecode(.Title & " " & .Description & " " & .Entry)
   7: Dim strDescription As String = HtmlUtils.Shorten(HtmlUtils.Clean(System.Web.HttpUtility.HtmlDecode(.Entry), False), 100, "...")
   8:             SearchItem = New SearchItemInfo(ModInfo.FriendlyName & " - " & .Title, strDescription, UserId, .AddedDate, ModInfo.ModuleID, .EntryID.ToString, strContent, "EntryId=" & .EntryID.ToString)
   9:             SearchItemCollection.Add(SearchItem)
  10:End With
  11:Catch ex As Exception
  12:         Exceptions.LogException(ex)
  13:End Try
  14: Next

We need then to change the module's FriendlyName logging in as host and going to Host > Module Definitions and click on the blue pencil next to the Blog module. Here we'll update the FriendlyName matching our requirements.

Dobbiamo cambiare il FriendlyName del modulo loggandoci come host e andando su Host > Module Definitions e cliccando sulla matita blu accanto al modulo Blog. Qui modifichiamo il FriendlyName secondo le nostre esigenze.

Blog module definition

Lastly we need to clear all the previously indexed data in the search tables using an SQL script. Being logged as host we'll goto Host > SQL, enter the following, check the Run as Script option and hit the Execute link.

Infine dobbiamo cancellare il contenuto delle tabelle di ricerca precedentemente archiviato utilizzando una serie di comandi SQL. Sembre loggati come host andiamo su Host > SQL, inseriamo il seguente codice, selezioniamo l'opzione Run as Script, e clickiamo sul link Execute.

delete {databaseOwner}{objectQualifier}SearchItemWordPosition
delete {databaseOwner}{objectQualifier}SearchItemWord
delete {databaseOwner}{objectQualifier}SearchWord
delete {databaseOwner}{objectQualifier}SearchItem

Now we need to re-index the website content. To do this, simply goto Host > Search Admin and hit the Re-Index Content link, and you're done.

Ora bisogna re-indicizzare i contenuti del sito. Per fare questo, basta andare su Host > Search Admin e clickare sul link Re-Index Content, e il gioco è fatto.

Posted in: Configurazione

Comments

Kelly Brown
Saturday, June 13, 2009 2:06 AM
Great post! I'll subscribe right now wth my feedreader software!
JaneRadriges
Saturday, June 13, 2009 10:19 PM
I really like your post. Does it copyright protected?

Post Comment

Name (required)

Email (required)

Website


WPC 2008