Retrieving HTML Content from WCM 'blob'

I may have missed the easy way to do this, but our client wants a splash page for each event that they will create and control in WCM. 

We can create a separate content record for each event, but not a separate navigation item for each event as there are many.

Using eCM it would have been easy enough to call the html in a custom page for any content record in the db based on it's name or some other element.

Following some of the posts on this site, I've tried to use an iPart with Asi.Business.ContentManagement dll.  While I can retrieve a list of root folders, pulling out html content for a particular WCM content record seems light years away...

This post seems to suggest a programmatic approach (like I've been trying) is the best approach : http://www.imiscommunity.com/find_wcm_url_based_upon_tags_how_can_this_be_accomplished_in_a_sql_view

Does someone have an example of how to do this, or some low hanging fruit I may have missed?   Any good 'blob blogs' out there?   Or am I stuck with the blob blues? Blah!
 

Update May 2010: I was able to retrieve this html content, feel free to contact me if interested in code.

 

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Here is the general idea...

NOTE: do not use this in production as this is vulnerable to sql injection:   "select Blob from DocumentMain where (DocumentName = '" + thisTitle + "') and documentStatuscode ='40' ";

Here is the general idea... put this .ascx as a simple iPart in a WCM page.  Then pass a query string to it i.e.  ReadBlob.aspx?title=MyStory

This will pulll the html content from the blob with that title.  before delpoying we restricted access to particular folders so no one could pull just any content from the db. This is just sample code to show how to read html from the blob, not necesarily ready for production.   

This is just proof of concept for reading BLOB, no warrenties, etc.

 

<%@ Control Language="C#" ClassName="VA_ReadContent"  Inherits="System.Web.UI.UserControl"  %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System" %>

<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Xml" %>

<script runat="server">
   
   
   
    protected  override  void OnLoad(EventArgs e)
    {
        SqlDataReader rdr = null;
        SqlConnection con = null;
        SqlCommand cmd = null;

        string ConnectionString = System.Configuration.ConfigurationManager.AppSettings["va_WCM_Connection"].ToString();

        con = new SqlConnection(ConnectionString);
        con.Open();

        // Set up a command with the given query and associate
        // this with the current connection.
        string thisTitle = Request.QueryString["title"];

        string CommandText = "  select Blob from DocumentMain where (DocumentName = '" + thisTitle + "') and documentStatuscode ='40' ";
        cmd = new SqlCommand(CommandText);
        cmd.Connection = con;

        rdr = cmd.ExecuteReader();
        rdr.Read();
        int bufferSize = 10000;
        byte[] ByteArray = new byte[bufferSize];
        System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();

        int startIndex = 0;

        string s = "";

        try
        {
            long ReadChars = rdr.GetBytes(0, 0, ByteArray, 0, bufferSize);

            while (ReadChars == bufferSize)
            {
                s += enc.GetString(ByteArray);
                startIndex += bufferSize;
                ReadChars = rdr.GetBytes(0, startIndex, ByteArray, 0, bufferSize);
            }

            s += enc.GetString(ByteArray);

            // Close data reader object and database connection
            if (rdr != null)
                rdr.Close();

            if (con.State == ConnectionState.Open)
                con.Close();

            // FOR NOW, use string manipulation to show the INNER html
            int myStart = s.IndexOf("<b:Body>");
            int myEnd = s.IndexOf("</b:Body>");

            s = s.Substring(myStart + 8, myEnd - myStart - 8);
            s = Server.HtmlDecode(s);

            s = s.Replace("[Root]", ConfigurationSettings.AppSettings["VA_ImagesPath"]);

            ltrMessage.Text = s;
        }
        catch
        {
            ltrMessage.Text = "No content found or other error.";

        }
          
     ltrMessage.Visible = true;

 

    }
</script>

 <asp:Literal ID="ltrMessage" runat="server"></asp:Literal>