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)

Friday 5 September 2008

Surprise! ssWeblayoutUrl

I put a bit of inline javascript in a content item to do an image rollover. After it published though the script was mangled - my mixed use of single and double quotes were all replaced with double quotes.

My code looked fine in Ephox. I tried a few edit+saves and realised my mixed use of quotes was sometimes failing. I complained to the Ephox folks who quickly checked & assured me it was not their product causing the issue. So I went to Content Server and viewed the content item's XML. Sure enough I found the problem - my image references were rewritten as a new Idoc URL format that inserts its own single quotes.

Observe my original code...
<img src="/serverroot/somepath/contentID1.gif" onmouseover="this.src='/serverroot/somepath/contentID2.gif';" onmouseout="this.src='/serverroot/somepath/contentID1.gif';" />

Now see what XML (unencoded) is stored in my content item...
<img src="[!--$ssWeblayoutUrl('somepath/contentID1.gif')--]" onmouseover="this.src='[!--$ssWeblayoutUrl('somepath/contentID2.gif')--]';" onmouseout="this.src='[!--$ssWeblayoutUrl('somepath/contentID1.gif')--]';" />

Hey wow! My URLs are magically replaced with some new Idoc link format... that screws up my quote groups! Gee, thanks guys.

Anyway I got around the problem by making my javascript first use an empty string and then appending the URL. Here's how it gets stored now..
<img src="[!--$ssWeblayoutUrl('somepath/contentID1.gif')--]" onmouseover="this.src=''+'/serverroot/somepath/contentID2.gif';" onmouseout="this.src=''+'/serverroot/somepath/contentID1.gif';" />

UPDATE:
I was fumbling around metalink when I discovered this gem: ssWeblayoutUrl can be configured to only use dDocName - no path required! Yay! Now we can fiddle with our image security without fear of broken links (except in javascript, of course :)) just put this in your config:

SSWeblayoutUrlUsesDocNames=true

Refer to metalink article 579457.1

UPDATE #2:
I'm playing with the new format, here are my findings...
* apparently it is only used on img tags - not links. Bummer...
* it will redirect to the latest available revision - contributor mode links to revisions in workflow, non-contributor mode gives you the latest released instead. Nice!

here's how it looks:
<img src="[!--$ssWeblayoutUrl('contentID')--]" />

UPDATE #3:
The bad news is that if the contentID is invalid or does not exist, it throws an error... more importantly, the editor will fail to load any content at all! Youch!

The good news is that the latest release of sitestudio(build298) is supposed to resolve the bug and also uses the new URL format on link tags.

UPDATE #4:
Finally got authority to upgrade and yes, ssWebLayoutUrl is a total kickarse auto-replacement for image src URLs but no, it doesn't seem to replace other weblayout links automatically. Maybe I should update my validation script to do it...