SharePoint Products TechCenter >
SharePoint Products and Technologies Forums
>
SharePoint - Enterprise Content Management
>
Display Reusable Content outside Editor control
Display Reusable Content outside Editor control
- Reusable Content is designed for use in Publishing pages in MOSS ECM. While editing pages, users have the ability to create and insert Reusable Content and reference it across the site.But what if you want to use that same content elsewhere? Imagine you wanted to query a section of a publishing page containing RC, or even a ListItem which contains RC, and expose that content either via WebService or just display it in a page. You'll find out very quickly that the Reusable Content stored in that list item contains a link to a publishing fragment which, in conjunction with some client-side script, renders the content into your page.My question is this: How, if at all, can one display the content from a column containing reusable content in a page which does not contain a SharePoint Publishing HTML editor? This solution would need to display, one way or another, the column's content along with reusable content.Any help or insight is greatly appreciated!
Answers
- I don't like replying to my own comments but I've actually found a much better solution, exactly what I was looking for in the first place
Microsoft.SharePoint.Publishing.Internal.WebControls.HtmlEditorInternal.ConvertStorageFormatToViewFormat(page["PublishingPageContent"].ToString());
this returns a string containing the HTML you require i.e. merges all the reusable content fragments- Proposed As Answer byPaul Lucas Tuesday, October 27, 2009 10:39 PM
- Marked As Answer byedlorenz7 Wednesday, October 28, 2009 8:18 PM
All Replies
- You can use the Data View Web Part to pull information from any list including the Reusable Content list. You can then use XSL to output the HTML from the list like this:
<xsl:value-of select="@ReusableHtml" disable-output-escaping="yes"/>
Randy Drisgill - MVP SharePoint Server
SharePoint911 Branding and UI Services
My Blog: http://blog.drisgill.com
Wrox: Professional SharePoint 2007 Design- Unmarked As Answer byedlorenz7 Friday, September 25, 2009 12:59 PM
- Marked As Answer byLambert QinMSFT, ModeratorFriday, September 25, 2009 7:07 AM
- Randy: Thanks for the quick reply.
Unfortunately, I'm not trying to pull information from the Reusable Content list. I'm trying to pull information from a list which contains PublishingHTML. As you're aware, ECM enables users to edit pages using PublishingHTML fields, and inside the field along with other content, they can embed Resuable Content. The unfortunate thing is that the Reusable content is stored as a fragment like so:
<div class=ExternalClassFD385714ECAF4DD8AB498F74B54FF5E2> <div id="__publishingReusableFragmentIdSection"> <a href="/ReusableContent/Credit%20and%20Lending%20Product%20Group/292_.000">a</a> </div> <p>Here is <font face=Algerian>some formatted </font>text.... blah blah blah</p> <p>let's insert some reusable content:</p> <p><span id="__publishingReusableFragment"></span></p> <p></p> <p>more text........</p></div></div> <p><br /></p> </div>
As you can see, it's not rendering the CONTENT of the reusable content, only a LINK TO that reusable content. And in my HTML, all that is rendered is a hyperlink to "a". Normally, the PublishingHTML Editor will render some javascript to update this reference and turn it into text (where you see the __publishingReusableFragment span). The HTML here is exactly what's stored in the column in SharePoint.
One thing I did fail to mention is that I'm implementing this on a _layouts/ page, where I won't be using webparts or PublishingHTML editor controls. What i'd like to happen is to somehow get the actual reusable content WITH the other content, or find a way to render the same javascript which will do this replacement for me.
-Ed - Hi Ed,
I think the key here is that you DO need to pull information from the Reusable Content list, as this is where RC stored. (that is, RC set as "Automatic Update")
Your column that consumes the reusable content will only contain a pointer to that content, as outlined by <a href="/ReusableContent/Credit%20and%20Lending%20Product%20Group/292_.000">
So, if you need to get access to the RC, you would find out which RC item was being used, then query the Reusable content list for the actual content.
hope that makes sense
Paul. - If I'm not mistaken the functionality you speak of actually pulls its information from a list called Reusable Content. I have created DVWP's that pull this information before, it could be a way to do what you are looking for. Because of your _layouts requirment, this sounds like you may need to create some custom code to pull the info from the source list.
Randy Drisgill - MVP SharePoint Server
SharePoint911 Branding and UI Services
My Blog: http://blog.drisgill.com
Wrox: Professional SharePoint 2007 Design- Unmarked As Answer byedlorenz7 Wednesday, September 30, 2009 12:56 PM
- Marked As Answer byLambert QinMSFT, ModeratorWednesday, September 30, 2009 5:07 AM
Randy -- you're right, it does internally pull info from the Reusable Content list... And somehow, this functionality is exposed through the PublishingControls:RichHTMLEditor control. When it's rendered in view-mode, some scripts are executed (I think client-side) to grab the publishing fragment & replace it.
Currently I'm leveraging custom code to run an SPQuery against the /Pages/ library (ECM publishing). This returns the page, whose fields return the HTML from in the form that I posted above. If there's a way, sever- or client-side, to grab the data and insert it, I'd love to hear it (and perhaps see an example).
Thanks for your help so far.
-Ed- Edited byedlorenz7 Friday, September 25, 2009 4:05 PMedit
- The only example I could provide would be how to display the HTML field from XSL that a Data View Web Part would use. Let me know if you want to see that, I can dig it up.
Randy Drisgill - MVP SharePoint Server
SharePoint911 Branding and UI Services
My Blog: http://blog.drisgill.com
Wrox: Professional SharePoint 2007 Design - Note to moderators:
Please stop marking these responses as answers. I have not received an answer yet to my question, I am NOT looking for a solution to pull data from a webpart or from the Reusable Content list directly.
Thank you. - I recently faced the same problem. I have a publishing page layout with some code behind that I was trying to pull the content of a page list item into. My Solution was to add the following control into the layout
And then in my code behind for the layout have the following<PublishingWebControls:RichHtmlField FieldName="PublishingPageContent" id="actualcontent" runat="server"></PublishingWebControls:RichHtmlField>
This did exactly what you're asking for, the page I was getting from the page list contained a reusable content fragment.protected Microsoft.SharePoint.Publishing.WebControls.RichHtmlField actualcontent; protected void Page_Load(object sender, EventArgs e) { SPListItem page = <whatever method you use to get your page item>; actualcontent.ItemFieldValue = page["PublishingPageContent"].ToString(); }
Hope that helps!
- I don't like replying to my own comments but I've actually found a much better solution, exactly what I was looking for in the first place
Microsoft.SharePoint.Publishing.Internal.WebControls.HtmlEditorInternal.ConvertStorageFormatToViewFormat(page["PublishingPageContent"].ToString());
this returns a string containing the HTML you require i.e. merges all the reusable content fragments- Proposed As Answer byPaul Lucas Tuesday, October 27, 2009 10:39 PM
- Marked As Answer byedlorenz7 Wednesday, October 28, 2009 8:18 PM
- That worked PERFECTLY. Thank you!!! I've been looking for that answer for a long time.

