Sharepoint tips and tricks

computers are cool - they are the reason you are here right now! Hopefully, JJReason can build one and prove once and for all, Canadians are somewhat intelligent.

Moderators: Batman, Zero, John Madden, Bob Ross, General Zod, Richard Simmons

User avatar
vynsane
master of the universe
Posts: 5903
Joined: Sat Aug 31, 2002 11:16 pm
Location: in my quiet place, punch-dancing out my rage
Contact:

Sharepoint tips and tricks

Postby vynsane » Fri Jun 26, 2009 11:00 am

for lack of a better place to post this kind of stuff, i'm going to do it here. this is more for people searching for this kind of info, not for you guys, though you can check it out if you want to.

INSERTING REUSABLE CONTENT DIRECTLY INTO A PAGE LAYOUT USING A DATA FORM WEB PART

the project: a page layout designed for publishing press releases needs to display a 'boilerplate' and 'contact info' section on each page. to save energy and time, it's desirable to house these as separate items in the site collection's 'reusable content' list and pull it from there, to make it both easily editable in one place and uniform across all press releases.

the problem: generally speaking, the 'reusable content' list is leveraged at the publishing stage, being placed in a content editor placeholder, not the page layout stage. in order to facilitate automatic insertion to the published page, it should be added to the 'press release' page layout directly.

the solution: i searched for a long time for an out-the-box solution, and after a few things that were ALMOST there but not quite, i was able to coble together a solution with the information that i had found.

in sharepoint designer, open the page layout in question (in my case, the 'press release' page layout) and open the 'data source library' pane. under the heading 'SharePoint Lists' find the 'Reusable Content' list. go ahead and drag that list into the page layout where you desire it to be displayed (in this instance, at the bottom of the page, under the content area). this will display the list in its default view, with a header of all the default columns: 'Title', 'Modified By', and 'Modified', with the info for each row below those columns. in my example i have two folders, one titled 'press and news' which holds the two reusable content snippets that i need. the other doesn't matter.

obviously, this isn't the way we want to display this, so we need to modify it by selecting our columns (really, just 'reusable html' only), filtering and ordering the information, and altering the layout. at this point it's a good idea to open a new window or tab in your browser and look at the snippets of reusable content you want to use. find in the url where it says "/DispForm.aspx?ID=X" - this 'X' being the ID number of the reusable content snippet we want. now go back to your page layout, select the data form web part, and click the arrow to the right, which will open the 'Common Data View Tasks' menu. click on 'Filter' - we'll be filtering by ID - mine are ID #4 and ID #5, so in the new pop-up i set up my filters to be:

Fieldname | Comparison | Value | And/Or
ID | Equals | '4' | Or
ID | Equals | '5' | -

i then select both (clicking the arrows to the left while holding 'shift') and click the 'group' button. i don't think this is entirely necessary, but it works. click 'OK' to exit this box.

now click 'sort and group' and add 'ID' to the 'Sort Order' column, and select 'Ascending' under 'Sort Properties', then click 'OK'.

finally, click 'Edit Columns...' to... edit the columns you want displayed. highlight all the column names in the right side ('Title', 'Modified By', and 'Modified') and remove them. Add only 'Reusable HTML' to the 'Displayed Columns' side.

at this point you should have... nothing in the web part box. well, that's not good! we had our folders in there, but now that we've filtered it shows nothing? fear not... we need to set it to search recursively through all folders and items in the list - in the 'Data Source Details' pane, under the heading 'Current Data Source:' it should display a link that says 'Reusable Content...'. click that link. on this pop-up, in the select box next to the label 'Item and folder scope' select 'RecursiveAll'. voila! your item(s) are now displayed. if not, you did something wrong.

at this point we have a header that says 'reusable html' at the top of our web part box. that won't do. back on our layout, select the web part and click the arrow to the right to re-open the 'common data view tasks' menu. here, click on 'Change Layout...' (right below the 'Edit Columns...' link we clicked a bit earlier.) here, scroll down to the bottom and select the last available layout, the 'layout table form', and click 'OK'. the page layout will refresh and the header 'reusable content' will disappear. now, we have our items in a table with a few extraneous table data cells, so we can delete those in the XSL output for this layout. get rid of the first <tr>...</tr> that looks like this:

Code: Select all

         <tr>
            <td>
               <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
                     </td>
            <td>
               <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
                     </td>
            <td>
               <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
                     </td>
         </tr>


we don't need that.

also, get rid of these:

Code: Select all

<td>
               <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
                     </td>


and finally, the bottom row as well:

Code: Select all

<tr>
            <td>
               <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
                     </td>
            <td>
               <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
                     </td>
            <td>
               <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
                     </td>
         </tr>


also, in this line:

Code: Select all

<td XMsCellType="empty" valign="top" width="90%">


just make the width 100%.

that should take care of it. if you have source control enabled, you'll need to check in and approve the page layout to have it display to normal visitors.

now you can edit your reusable content from the list at the top site collection, and it will automatically update all published webpages that utilize this page layout.
Life is short. STUNT IT!

Return to “computers”

Who is online

Users browsing this forum: No registered users and 1 guest