Andrew Connell [MVP SharePoint]
1579 Posts |  42 Articles |  4864 Comments
.NET  |  MCMS  |  SharePoint  |  Office System
SharePoint Quick Links
Article Categories
Archives
Post Categories


Add to Technorati Favorites

[via Stefan Gossner & Maxime Bombardier]

The Content Editor Web Part, as many people have realized who've tried to use it in Publishing sites and then extend multiple Web apps or leverage content deployment, stores links as absolute references rather than relative ones. For instance, if you have a link to http://staging.adventureworkstravel.com/pages/contactus.aspx in a CEWP on a page and then do content deployment to http://www.adventureworkstravel.com, the link will be pointing back to the staging site (which will... or should... be inaccessible).

Sidebar: In my opinion, you shouldn't using the CEWP in Publishing sites. In fact, for most if not all my deployments, we remove that Web Part from the Web Part gallery and add a <SafeControl /> entry in the site's web.config to flag is as NOT a safe control. You should be using field controls instead (see my blog post detailing this here which is also on the ECM team blog and also discussed in my MSDN article Prescriptive Guidance for MOSS 2007 WCM Sites).

Maxime Bombardier has come up with an interesting workaround to fixing this for all WSS 3.0 based sites, including Publishing sites. This approach uses a custom ASP.NET Control Adapter to do some link fixup. In his post he references Waldek's similar process.

» Maxime Bombardier: Fixing absolute URLs for all Alternate Access Mappings (AAM) of Content Editor Web Part with a Control Adapter

Technorati Tags: ,,,
posted on Wednesday, December 24, 2008 9:21 AM

Feedback

# re: Working around the CEWP's absolute links... 1/3/2009 4:17 PM arjun
Gravatar Hi Andrew!,

I have been following your blog for quite sometime. Read your book on wcm. I have a question regarding accessibility. I am not sure if this is the right place to ask this question, apologies if it is not.
I had looked at few sites which were done using MOSS 2007. Ex www.ocps.net.
When you open the site in IE 7 and go to page -> text size -> largest. It does not change the text size. OCPS is just an example, there are many more sites which don't support this sort of functionality.
Does this mean that those sites do not support accessibility? I am asking this question as we are building a publishing site. Would appreciate any advice in this regard.

Arjun

# re: Working around the CEWP's absolute links... 1/4/2009 8:54 AM AC [MVP MOSS]
Gravatar Arjun-
That isn't an accessibility requirement... it's just a bit of functionality people have added to their sites. Has zero to do with accessibility.

# re: Working around the CEWP's absolute links... 1/5/2009 9:24 PM Craig
Gravatar Arjun, if you're curious, here is W3C's new accessibility standards and guidelines: http://www.w3.org/WAI/

# re: Working around the CEWP's absolute links... 1/15/2009 8:39 AM Raj
Gravatar Hi AC,

I read your book WCM and follow your blog. You suggest not to use CEWP in Publishing sites. We have a requirement in which we need to embed flash inside publishing rich html field. However this can't be achieved using Publishing rich html field. The other way is to use CEWP - Do you have any suggestion for custom solutions.

Thanks,
Raj

# re: Working around the CEWP's absolute links... 1/16/2009 12:55 AM AC [MVP MOSS]
Gravatar Raj-
Yup... http://www.codeplex.com/SPWCMFieldControls

# re: Working around the CEWP's absolute links... 1/27/2009 7:28 PM MOossBuddy
Gravatar Hey Andrew,
This is really great stuff but what do we do for the "content links" property of the CEWP? I mean if we have a site-collection at the root of the web-app i.e. something like:
http://abcd.com/ and the content link points to say Pages/someContentHtmlPage.htm

Now when we move the web part to a managed site path something like http://abcd.com/sites/myNewSitecollection the Path that Ihad given for "content link" doesnt find that link on it root at all (ofcourse the page is deployed to Page library). Do you know if this is a bug or there is something that i am doing wrong or if there is a work around for this?

# re: Working around the CEWP's absolute links... 1/28/2009 7:01 AM AC [MVP MOSS]
Gravatar MossBuddy-
No bug... the CEWP stores URLs as absolute... not relative. Yet another reason why not to use this Web Part in Publishing sites.

# re: Working around the CEWP's absolute links... 1/28/2009 11:11 AM MossBuddy
Gravatar Thank you Andrew, but I am talking about the CONTENT link property which is really not stored as absolute URL when I deploy from one box to other. Basically it shows me the same relative path. My problem is it wants the path from the root, so for e.g.: if you have a site collection at http://myRootSiteCollection.com/ and we have a Pages library containing the content html, I would give the link for CONTENT LINK property as: "/Pages/MyContentPage.html". Now when I export and save the web part on a different site-collection with a managed path, so for e.g. http://myRootSiteCollection/sites/myOtherSiteCollection the Content link path still shows in the Content Link property as “/Pages/MyContentPage.html” and it doesn’t work and if now I change it to “/sites/myOtherSiteCollection/Pages/MyContentPage.html” and it works. So as you mentioned CEWP maintains the paths as absolute paths do you also mean that it maintains the web-part properties also as absolute path as CONTENT LINK is a web part property?

thanks


# re: Working around the CEWP's absolute links... 1/28/2009 11:17 AM AC [MVP MOSS]
Gravatar MossBuddy-
The details don't matter... *everyting* about the CEWP stores stuff as absolute links.

# re: Working around the CEWP's absolute links... 1/28/2009 11:18 AM MossBuddy
Gravatar Ohh that means the Adaptor that is mentioned above will also take care of the CONTENT LINK property and convert it and then everything should work fine?

# re: Working around the CEWP's absolute links... 1/28/2009 11:21 AM AC [MVP MOSS]
Gravatar Mossbuddy-
Dunno... you'll have to test.

# re: Working around the CEWP's absolute links... 1/29/2009 6:37 AM Praggers
Gravatar Embedding Flash / Media in CEWP.

You can get round this by putting the required markup in as Reusable Text (not HTML!).


# re: Working around the CEWP's absolute links... 4/8/2009 5:33 AM Anupama
Gravatar We observed that if we give relative image URL in html (without using Rich Text Editor) and run Content deployment then the image URL on production server get also changed.

Can you validate that? We have been using Content Editor web part wth Content Deployment successfully like that.

# re: Working around the CEWP's absolute links... 4/9/2009 3:51 AM AC [MVP MOSS]
Gravatar Anupama-
The absolute links are only generated by the RTE... not if you modify the HTML source as it sounds you did.

# re: Working around the CEWP's absolute links... 10/22/2009 4:40 PM GuyInRedmond
Gravatar Hi Andrew,

When I use Publishing HTML field controls on pages, they seem to convert relative URLs to absolute ones. Do you know if there is some specific configuration of the field controls in order to keep the relative URLs, or is this something that was recently changed, possibly by the latest service pack? Thanks!

Post Feedback

Title:
Name:
Email:
(email will not be displayed)
Url:
Comments: 
Please add 1 and 1 and type the answer here:    
All Comments Are Filtered & Moderated
Unfortunately comment spammers are just too effecient and are constantly dirtying up blogs with irrelevant and unwanted comments trying to improve their standing on search engines. All comments on this blog are moderated. I do not censor comments, but I don't approve comments with vulger language or those soliciting products. Most of the time comments are approved within a few hours of being submitted with the only exception when I'm traveling.

Why are you asking for my email address?
The only reason I'm asking for your email address, which isn't required to submit a comment, is to provide a gravatar if you've created an account for yourself and associated your email address with a small image. If you have a gravatar created for the email address you submit, it will appear next to your comment. Otherwise nothing will appear.

What is a gravatar?
A gravatar is a "globally recognized avatar." You can get more information about gravatars, as well as create your own for free, at www.gravatar.com. You can also view my gravatar here.


Copyright © 2003 - 2010 Andrew Connell
Creative Commons License 
This work is licensed under a Creative Commons License
Site design by Heather Solomon.

 
 
MOSS WCM Training
Looking for MOSS 2007 WCM developer training? Look no further! I teach my 5-day hands-on and online WCM classes for developers I offer through my company: Critical Path Training.

Get more information on the WCM courses!