DotNetNuke TextEditor Tips

I’ve started a new Visual Studio 2010 DotNetNuke Module project recently. After spending weeks on the SQL and Data Access Layer I began working on the User Controls.

The first control was the DNNTabStrip and it worked flawlessly. Next I added a TextEditor control and then strange things happened.

  1. There was no intellisence in the HTML or in the Code Behind.
  2. Everytime I changed the HTML the *.designer.cs file would change my TextEditor declaration to a “System.*.*” name space which breaks the Control until I put it back.

The solution to #1 was EASY… I had forgotten to setup the project properties. (Under Properties -> Web -> Servers, set it to use Local IIS and set the Project URL to the full URL of your project (*/DesktopModules/Project) and then override the applocation root to be the DNN Install.

Once I had done this, intellisense worked nicely =D

For #2, I surfed the web searching and found temporary solutions and then I just tried another…

Both the Code.ascx.designer.cs and Code.ascx.cs both implement the same class so why not just move the control from the designer file to the code behind.

After I have done this, it quit attempting to change it since it was already declared.

I doubt it’s the proper fix but it beats changing it on EVERY edit of the HTML.

QEMU PPC and slackware – part 2

Now I have Slackintosh 12.1 installed… I reboot to find it can’t boot. It just has the OpenFirmware header and stalls. I have no clue if yaboot even works on QEMU for PPC… =/

In the meantime I am using this to boot the Slackintosh image:

qemu-system-ppc.exe -cpu G4 -M mac99 -m 512M
 
-hda IMAGEslack.qcow2
  -cdrom ISOslackintosh-12.1-dvd-install.iso
  -kernel KERNELSLACKKERN
  -initrd KERNELSLACKINITRD
  -append "root=/dev/hda3 ro video=ofonly"
  -net nic,vlan=0,macaddr=52-54-00-EA-B0-9A,model=pcnet
  -net user,vlan=0,restrict=no,hostfwd=tcp:127.0.0.1:2222-:22

This lets me boot with no problems and I can ssh into 127.0.0.1:2222 and get access to the emulated Slackintosh. (Using -net user... doesn't allow internal network access, but allows internet access which is what I need at the moment. With SSH being open on the local box I can move files in an out with no issues.)

Next: recompile Slackware 13.1 sources...
Todo: attempt to use QUIK instead of YABOOT for booting the image

QEMU PPC and slackware – part 1

So, I got bored one weekend and got my PowerPC 1GHz custom built Mac out… It currently has Gentoo installed and I prefer Slackware so I got the idea: “Let’s port Slackware over to PowerPC!”… Of course it’s been done before with the Slackintosh project but it hasn’t been updated in a year and I want Slackware 13.1 to have my linux pcs to be in sync.

Idea 0: Install Slackintosh 12.1 then update the sources… I can’t get the CD to boot =/ no go…

Idea 1: Compile Slackware 13.1 Sources on Gentoo (this does require manually installing pkgtools.) — Well this is NOT straight forward as Gentoo does some things differently. (ex. GNAT, LTO, and other packages can’t be found when comipiling GCC… They do exist on Gentoo though.) – That is put aside for the moment…

Idea 3: Install Slackintosh in QEMU and copy packages via SSH to the PowerPC box and then upgrade (after recompiling the upgrades…) — This is in progress…

QEMU and Slackintosh: Well, the CD doesn’t boot here either BUT I extracted vmlinux and initrd from the ISO and I can boot QEMU that way so I can install Slackintosh in QEMU.

QEMU Command:

qemu-system-ppc -cpu G4 -M mac99 -m 512M
  -kernel KERNELVMLINUX
  -initrd KERNELINITRD
  -append "cdroot root=/dev/ram0 ramdisk_size=25600 rw"
  -net nic,model=pcnet,macaddr=52:54:00:12:34:58
  -net user,restrict=no,hostfwd=tcp:127.0.0.1:2222-:22
  -boot order=ncd -hda IMAGEslack.qcow2
  -cdrom ISOslackintosh-12.1-dvd-install.iso

This forces QEMU to run as a NewWorld PowerMac – not my exact model, but close enough.

PS – the normal command with a good CD Image is this:
qemu-system-ppc -boot order=d -cdrom ./iso/image.iso

This is slow to install but o-well… It is emulated =D

Updated: 2/19/2011 – removed -net tap… as -net user… is all i need for network access currently.

Compiling TrinityCore on Slackware 13

I was trying to compile trinity core on Slackware the other day and found that I needed to add linking flags for the ncurses library. This project uses “cmake” and I’m not that familiar with it so after a bit of research I found this is how you build it:

cmake ../trinitycore
-DCMAKE_EXE_LINKER_FLAGS=-lncurses
-DCMAKE_SHARED_LINKER_FLAGS=-lncurses

These two switches allow it to be built correctly on a Slackware 13 machine. (32bit and 64 bit)

This page has more details: How-to: Trinity Core on Slackware

DNN Clear Search Tables

SQL

delete SearchItemWordPosition where SearchItemWordId in (select SearchItemWordId from SearchItemWord where SearchItemID in (select SearchItemId from SearchItem))
delete SearchWord where SearchWordsId in (select SearchWordsId from SearchItemWord where SearchItemID in (select SearchItemId from SearchItem))
delete SearchItemWord where SearchItemId in (select SearchItemId from SearchItem) delete SearchItem 

DNN SQL

delete {objectQualifier}SearchItemWordPosition where SearchItemWordId in (select SearchItemWordId from {objectQualifier}SearchItemWord where SearchItemID in (select SearchItemId from {objectQualifier}SearchItem))
delete {objectQualifier}SearchWord where SearchWordsId in (select SearchWordsId from {objectQualifier}SearchItemWord where SearchItemID in (select SearchItemId from {objectQualifier}SearchItem))
delete {objectQualifier}SearchItemWord where SearchItemId in (select SearchItemId from {objectQualifier}SearchItem) delete {objectQualifier}SearchItem 

Copied from: DotNetNuke Developer Chris Hammon

Test Harness for DNN ISearchable – Updated

I found a script written back in 2006 that tested the iSearchable interface to see what the module is supplying to the DNN Search Provider. Unfortunately this script didn’t work for me so I spent a few days trying to find out why it worked and how to make it work again.

Here is an updated version (in C#) that works with DNN 5.x – Tested with Community Edition.

File: DNNSearch.aspx

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”DNNSearch.aspx.cs” Inherits=”DNNSearch2″ %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml”>
<head id=”Head1″ runat=”server”>
      <title>Speerio ISearchable Test</title>
     <style>
            
body, p {font-family: Verdana; font-size: 9pt}
     </style>
</head>
<body>
<p><font size=”4″>DNNSearch Script – by <a href=”http://www.speerio.net”>Speerio, Inc.</a>, Updated by Info66.net</p>

<p><font color=”red” size=”4″>WARNING: Do not leave this script installed on a production system.</font></p>

<form id=”Form2″ method=”post” runat=”server”>
  <p>Tab ID: <asp:TextBox ID=”TabId” Runat=”server”></asp:TextBox></p>
  <p>Module ID: <asp:TextBox ID=”ModuleId” Runat=”server”></asp:TextBox></p>

  <asp:Button ID=”Results” Runat=”server” Text=”Get Search Results” /></p>  

  <p>To test for user-specific results, add code to GetSearchItems() to check for userid=N in querystring.</p>
  <p><b>Search Results:</b></p>
  <asp:Label ID=”SearchResults” Runat=”server” />

</form>
</body>
</html>

File: DNNSearch.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using DotNetNuke;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Services.Search;
using DotNetNuke.Common;
using DotNetNuke.Framework.Providers;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Services.Exceptions;

using System.Text;

 

public partial class DNNSearch2 : System.Web.UI.Page
{

   void Results_Click(object sender, EventArgs e)
   {
       int moduleId = -1;
       try
       {
           moduleId = Convert.ToInt32(ModuleId.Text);
       }
       catch
       {   
       }

       int tabId = -1;
       try
       {
           tabId = Convert.ToInt32(TabId.Text);
       }
       catch
       {

      }

       if ((moduleId > -1) && (tabId > -1))
           GetSearchResults(moduleId, tabId);
       else           
           SearchResults.Text = “Both Module ID and Tab ID are required”;

   }

   void GetSearchResults(int moduleId, int tabId)
   {
       ModuleController moduleController = new ModuleController();
       ModuleInfo moduleInfo = moduleController.GetModule(moduleId, tabId);

       StringBuilder sb = new StringBuilder();
       if (moduleInfo == null)
       {
           SearchResults.Text = “No module found with ModuleID=” + moduleId.ToString() + ” and TabID=” + tabId.ToString();
           return;
       }

 

       if (moduleInfo.BusinessControllerClass == “”)
       {
           SearchResults.Text = “The Business Controller Class in the database is blank.”;
       }
       else
       {
           try
           {
               object bizController = DotNetNuke.Framework.Reflection.CreateObject(moduleInfo.BusinessControllerClass, moduleInfo.BusinessControllerClass);
               if (bizController == null)
               {
                   SearchResults.Text = “The Business Controller Class <b>” + moduleInfo.BusinessControllerClass + “</b> could not be instantiated.”;
               }
               else
               {
                   ISearchable iS = (ISearchable)bizController;
                   SearchItemInfoCollection results = iS.GetSearchItems(moduleInfo);

                   if (results != null)
                   {
                       int counter = 0;
                       foreach (SearchItemInfo searchItem in results)
                       {
                           if (moduleInfo.ModuleID == searchItem.ModuleId)
                           {
                               sb.Append(“<p>Title: “ + searchItem.Title);
                               sb.Append(“<br>GUID: “ + searchItem.GUID);
                               sb.Append(“<br>Date: “ + searchItem.PubDate.ToLongDateString());
                               sb.Append(“<br>Description: ” + searchItem.Description + “</p>”);
                           }
                           else
                           {  // If SearchModuleId == 0, no worky worky… =( — Added because of this
                               sb.Append(“<p>ModuleId = “ + moduleInfo.ModuleID.ToString());
                               sb.Append(“<br />SearchModuleId = ” + searchItem.ModuleId.ToString());
                               sb.Append(“<br />Title: “ + searchItem.Title);
                               sb.Append(“<br />GUID: “ + searchItem.GUID);
                               sb.Append(“<br />Date: “ + searchItem.PubDate.ToLongDateString());
                               sb.Append(“<br />Description: ” + searchItem.Description + “</p>”);
                           }
                           counter++;
                       }
                       SearchResults.Text = counter.ToString() + ” results found.<br>” + sb.ToString();
                   }
                   else
                   {
                       SearchResults.Text = “No search results.”;
                   }
               }
           }
           catch (Exception e)
           {
               SearchResults.Text = “Error: “ + e.Message + “<br><br>” + e.StackTrace;
           }
       }
   }

   override protected void OnInit(EventArgs e)
   {
       Results.Click += new EventHandler(Results_Click);
       base.OnInit(e);
   }

 
   protected void Page_Load(object sender, EventArgs e)
   {
   }
}

Original Article and Script is located at the DotNetNuke Community Blogs and posted by Nik Kalyani - (I just modified it to work with DotNetNuke 5. I still don’t know why the original didn’t work as the object that failed is in the source code still.)

Download Files: ASPX, CS

DotNetNuke Source Install System.NullReferenceException

Error Message:

Server Error in ‘/DotNetNuke_2′ Application.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:

 

Line 930:  ' first call GetProviderPath - this insures that the Database is Initialised correctly
Line 931:  'and also generates the appropriate error message if it cannot be initialised correctly
Line 932:  strMessage = DataProvider.Instance().GetProviderPath() 
Line 933:
Line 934:  ' get current database version from DB

Luckily this is a quick fix… Rename the ‘release.config’ to ‘web.config’ and all is good!