Paul's profileAutoSpongePhotosBlogLists Tools Help

Blog


    November 16

    News Site Content Summarized Anywhere

    This week's challenge: make the conent from the News site bubble up to the front page of the site collection.
     
    Sounds easy, right?  Well, the dynamics of the List and Library structure prevents you from selecting another site's data as a web part.  So, you have to get creative (especially when you dislike raw code as much as I do). 
     
    The first option was to use the RSS feed from the News site library.  But, the RSS web part doesn't allow authenticated feeds (my site isn't anonymous).  I figured out a way around that by setting up the RSS feed as a Data Source in SPD, but the data was far from being presentable.
     
    The second option was the search results web part.  This seemed closer but between the XSL translations and a lack of certain data being indexed by Search (like the rollup image) I never felt good about the results.
     
    But today was a big win.  So far, I'm very happy with the solution and it's a model I can replicate elsewhere in the site.  I created a "blank" page with a DataForm web part and used an iframe on my homepage to see the results of the DataForm's query.
    1. First, open SPD and open the News site's Pages library.
    2. Create a new ASPX page.
    3. Insert a web part zone.
    4. Insert a DataForm web part.
    5. View the library's data source.
    6. Drag the data elements I needed to the page (Title, Rollup Image, Description, URL Path).
    7. Added the site's CSS to the page's HEAD section manually (<link rel="stylesheet" type="text/css" href="/[file name].css" />)

    Here's where you need to configure your design's look and feel.  For me, I wanted 6 items to appear (2 columns of 3).  I selected "Change Layout" from the common tasks menu and found the closest match.  I moved some elements around in the template until I was happy with it.  Then, I limited my paging to 6 results.  I set the filter to "Content Type Equals 'Article Page' or Content Type Equals 'Redirect Page'".  Since my blank page, the archive page, and default page don't have those content types, they won't appear in my new page (or the iframe).

    I added an iframe to the homepage with a content editor web part. 

    <iframe src="/News/Pages/NewArticles.aspx" height="200px" width="100%" frameborder=0 scrolling=no></iframe>

    Because I was using an iframe, I needed to make sure that none of my links would trigger navigation inside the frame.  I went back to SPD and wrapped my titles like this:

    <a href="{@FileRef}" target="_top"><xsl:value-of select="@Title" /></a>

    I noticed that my rollup images were using the URL provided in the rollup image form, so I changed my forms to leave the URL area of the rollup image dialog blank and wrapped the rollup images as well (if you don't blank out the URL, the wrapped href won't work):

    <a href="{@FileRef}" target="_top"><xsl:value-of select="@PublishingRollupImage" disable-output-escaping="yes" /></a>

    I cleaned up my webparts (minimized chroming on the new page and set a nice title on the homepage) and published.  It looks just like a 2-column Summarized Link web part but it's all dynamic.  I can forsee using a lot more Redirect Pages in the News site for quick updates.

    ScreenShot004

    The only thing that doesn't work *exactly* as I'd like is the iframe height.  For some reason, the web part doesn't want to resize appropriately so I had to set the height to 200.  I suppose if I get enough long-winded descriptions in the result set, I may have to poke back into the content editor web part and increase that.  If anyone knows exactly what that's happening, drop me a comment or IM.

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks (1)

    The trackback URL for this entry is:
    http://autosponge.spaces.live.com/blog/cns!D7F85948C20F0293!235.trak
    Weblogs that reference this entry