Thursday, June 11, 2009

The Case of Server Side Includes in Sharepoint Continued

So here's the deal in my first article, "The Curious Case of Server Side Includes in Sharepoint", I described how to use XML Web Parts to include HTML pages into Sharepoint. These pages only contained HTML Tags and Javascript, soon after that I had to figure out a way to include Server Side Scripts ie. classic ASP or PHP.

Sharepoint is built on .NET and all you hear is how superior it is to classic scripting techniques but personally its been very hard to retrain my brain not to follow my scripting talents. So here's a crutch for you other script junkies out there that need to add there existing work into Sharepoint today.

So for this you'll need a Sharepoint site, and IIS or Apache server (to host your scripts). I've done some testing and if you own your Sharepoint Server then you can install other Sites under IIS that are ASP supported sites. If you don't own the Sharepoint server then this will also work for Web Servers on another machine.

  1. Write your script as you need it to run (test/debug).
  2. Build your tables, divs, spans or whatever format stuctures as if they were linked to the CSS that the Sharepoint page is linked to (this will maintain the look and feel).
  3. Once you've tested the script wrap the following XML tags around it:
    <?xml version="1.0" encoding="utf-8"?>
    <HTML><![CDATA[
    YOUR SOURCE CODE HERE
    </HTML>

  4. Insert the XML Web Part where you want the script content to appear.

  5. In the Web Part Properties set:
    XML Link = http://<URL>/<Filename>.asp
    Appearance
    Chrome Type = None

  6. Save/Close your file and you now have a Server Side Script include.

I know I'm supposed to be promoting growth into the newer technology but I'm an old dog and sometimes you just need to get stuff done, minus the learning curve. His a bone for the dogs to get by one more day until the light switch of .NET comes on.

No comments:

Post a Comment