RSS feed icon BTB Shadow Man BiteTheBullet.co.uk logo

DotNetNuke NetSpell Tutorial - Part 3

Page 1 2 3

PART 3

Changes to DotNetNuke Files

Lets make three to the web.config file first.

  1. Find the htmlEditor config section this should be somewhere down on line 223. Inside the config section we are looking for the add element. I’m going to set the property spellCheck to NetSpell as shown below.
<add name="Ftb3HtmlEditorProvider" 
type="DotNetNuke.HtmlEditor.Ftb3HtmlEditorProvider, 
    DotNetNuke.Ftb3HtmlEditorProvider" 
providerPath="~\Providers\HtmlEditorProviders\Ftb3HtmlEditorProvider\" 
toolbarStyle="Office2003" 
enableProFeatures="false" spellCheck="NetSpell" />
  1. The dictionary file that NetSpell uses is set from the globalization element using the culture attribute, so I’m going to change this to en_GB so that I’ll get the correct spelling for the UK.
<globalization culture="en-GB" uiCulture="en" requestEncoding="UTF-8" 
responseEncoding="UTF-8" fileEncoding="UTF-8" />
  1. Final change is for NetSpell, we need to add a key to tell it where the dictionary files are stored. So in the appSetting element add the following key.
<add key="DictionaryFolder" value="Dictionary" />

 

Right next fire up Visual Studio and open the solution file for your version of DotNetNuke.

In the solution find the project called Provider.Ftb3HtmlEditorProvider, we need to make a couple of changes here in order to get NetSpell to work.

First lets add a new class called FreeTextBoxBTB to the project. I’m going to sub class the FreeTextBox control in this class. The reason, simple I need to output some content on the page to get the NetSpell application to work, but FTB doesn’t expose any method that will let me do this so I just have to sub class in order to do it.

Here is the complete code for my class FreeTextBoxBTB, its really simple and should be straight forward to understand.

Namespace DotNetNuke.HtmlEditor

Public Class FreeTextBoxBTB
  Inherits FreeTextBoxControls.FreeTextBox   Dim _useNetSpell As Boolean = False   Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)       If _useNetSpell Then         'add the spell.js file to the page
        writer.Write("<script language=""JavaScript"" src="/Portals/0/"")
        writer.Write( Me.Page.ResolveUrl("spell.js"))
        writer.Write(""" type=""text/javascript""></script>")         'add a function to allow us to set the focus to the FTB
        'when we return from the spell checking.
        'this is fix the issue with the corrected words "not taking"        writer.WriteLine("<script language=""JavaScript"" type=""text/javascript"">")
         writer.Write("function FTBFocus(){ FTB_API['")
         writer.Write(Me.ClientID + "'].Focus();}")
         writer.Write("</script>")       End If       MyBase.Render(writer)   End Sub  Public Property UseNetSpell() As Boolean          Get
                Return _useNetSpell
         End Get

         Set(ByVal Value As Boolean)
                _useNetSpell = Value
         End Set  End Property End Class End Namespace

 

Now I just need to modify the code in the Ftb3HtmlEditorProvider to use my new sub class above.

I need to change the declaration of the variable cntlFtb to be the new sub class we just created, this should be the first line of the class after the inherits statement

Dim cntlFtb As New FreeTextBoxBTB

Find the Initialize method, we need to change the type that we assign to the variable to this.

cntlFtb = New FreeTextBoxBTB

Finally let’s change the read only property HtmlEditorControl to the one shown below.

Public Overrides ReadOnly Property HtmlEditorControl() As System.Web.UI.Control

    Get
       If _spellCheck = "NetSpell" Then
          cntlFtb.UseNetSpell = True
       End If
       Return cntlFtb
    End Get End Property

Then the last change we need to make is to the SiteUrl.config  file to tell DotNetNuke how to handle the URL for the spell checker.

Add this to the Rules element

<RewriterRule>
     <LookFor>.*/SpellCheck.aspx</LookFor>
     <SendTo>~/SpellCheck.aspx</SendTo>
</RewriterRule>

Make sure that this rule is before the rule for Default.aspx, since it’s the first rule that matches the “lookfor” regular expression value that is evaluated.

Build the solution and test it out your development environment. You should now a fully functioning spell checker build into DotNetNuke.

Deploying To Production Server

To deploy this to your production server, first make a backup of the current files and database. Then follow the steps below.

  1. Copy over the newly build assemblyDotNetNuke.Ftb3HtmlEditorProvider.dll, this needs to go into the bin folder.
  2. Copy the file NetSpell.SpellChecker.dll again into the bin folder.
  3. Copy the spell.js and SpellCheck.aspx into the root of your DNN install.
  4. Create the folder called dictionary in the root of the site and copy over the correct directionary for your locale.
  5. Modify the SiteUrls.config as detailed above
  6. Modify the web.config file as detailed above

That’s it you’re done, remember you will have a small delay after uploading the dll while the application reloads for the first time, this is normal and happens to all ASP.net websites.

<< Previous Page

Privacy PolicyTerms and ConditionsCopyright © 2005 - 2008 BiteTheBullet.co.uk