Labels

accessibility (2) ADF (1) archiver (3) cmu (1) contributor (13) cookie (1) DAM (3) date (3) download (3) dynamic list (4) ephox (5) fatwire (1) fck (1) filters (1) folders (4) headers (2) IBR (3) ImageAlchemy (3) java (4) javascript (2) layout/template (4) link (6) locale (2) multilingual (1) rendition (3) replicator (4) rules (1) schema (1) search (11) sites (1) sitestudio (24) ssp/sspu (5) SSUrlFieldName (2) stellent (4) timezone (1) urm (1) weblogic (1) workflow (2)

Thursday 6 December 2007

How I got H1 Headings into Site Studio pages

One of the biggest frustrations of our users in the inability to insert a standard HTML heading.

"I beg your pardon" you say, "no headings?"

Yep, the Site Studio Contributor application window allows you to only write paragraphs. You can insert tables, horizontal rules, bold text and even classes*, but not headings.

To get around this deficiency, I started by modifying the HTML Object Properties Forms. Being the logical programmer that I am, I tried to create a function that allowed me to replace a <p> tag with a <h1> tag, using the standard HTML replaceChild() method. Unfortunately this throws an error.

It turns out that any attempt to insert a new node in the HTML DOM will be rejected... oddly enough it didn't mind me deleting nodes though. After a while I gave up and forgot about it.

Then the other night as I was trying to sleep I thought "instead of being a nice boy and respecting the DOM, why not just treat code as dirty text and do a simple string replace?" and vola! it works.

I simply grab the node I want to work with and replace its outerHTML with its innerHTML , wrapped in my heading tags. Like this:

g_obj.outerHTML='<h1>'+g_obj.innerHTML+'</h1>';

Now if only I'd thought of that last year...

Oh there's one final twist... you can't use outerHTML on table cells, which sucks when you need to change a TD into TH. To get around this problem you need to replace the entire table!

* When applying a class it uses a FONT tag!? Crazy.

2 comments:

  1. Can you please explain this a little bit, what what portion of the properties form did you cahnge? Can you please copy - paste the entire code that you used.. long time, don't know you can see this..

    ReplyDelete
  2. Sure, download all the code from here: http://webmonkeymagic.blogspot.com/2007/12/get-enhanced-contributor-editing.html

    ReplyDelete