Skip Ribbon Commands Skip to main content

SharePoint Happenings

Help (new window)
Sign In
Navigate Up
Get Microsoft Silverlight
Install Silverlight plugin for a richer experience...
Blog Home |  Freeware |  Speaking |  About me

Consume Reusable Content outside of Page Content field Controls



Bookmark and Share

Top Tech Links










Top SharePoint Administrator Links









Top SharePoint Developer Links













NOTE: This blog has been moved to http://blog.philwicklund.com. If you'd like assistance, leave a comment on the copied post in the new location (hint, use search on the right to find the post).


Ever want to use some reusable content, but you don't have one of those handy Page Content field controls to consume it with? Well that was my situation because I was in a publishing site, but I was on a generic web part page with no page content field controls. Dang! However, I knew I didn't want to maintain the same HTML in two places, so I had to come up with a work around. Also, I didn't want to recreate the page with a new template.

 

The solution I came up with involves creating a view on the Reusable content list and using jQuery to hide the toolbar. See below for the steps:

 

Step 1: Create a View on the Reusable Content List

 

On the reusable content list, create a new standard view. Deselect all the columns except the Reusable HTML column:

 

 

Next, set a filter to show ONLY the piece of reusable content you want to consume:

 

 

This will create a view that only shows one piece of reusable content and only one column:

 

 

Step 2: Drop the List View Web Part on the Page

 

Now – drop a List View Web Part on the page where you want the reusable content, and change its view to point to your newly created view:

 

 

 

Also – make sure to turn off the toolbar and set the Chrome Type to be "None":

 

 

Step 3: Leverage jQuery to Hide that Annoying Column Header!!!

 

After you hit Ok you'll see your reusable content on the page and it's not in a Page Content field control:

 

 

The only problem is when you exit edit mode; you'll see that darn column header!! Well, to get rid of that, stick a Content Editor Web Part on the page and drop some jQuery in there to remove it:

 

 

Here's the jQuery I pasted in my Content Editor Web Part:

 


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript">
$(".ms-vh2-nograd").hide();
</script>

 

Neat trick huh? Essentially, all the jQuery is doing is hiding all objects that bare the class of "ms-vh2-nograd". Since that class is only used on reusable content List View Web Part's columns, it's safe to go ahead and hide them.

 

DONE!

 

Phil