Tuesday, December 8, 2009

My Links SharePoint list web part mods using HtmlFilter

  • Modify the standard Links List web part properties using HtmlFilter as follows

    • Remove column header
    • Clear empty group by selector
    • Offer open link in new window option

  • Add an OpenInNewWindow yes/no column to the Links List
  • Add a Group column to the Links List

    • This can be any type that supports Grouping

  • Add an OpenInNewWindowReplace calculated column to the Links list

    • Calculation:   =OpenInNewWindow&"OpenInNewWindowReplace"

  • Create a view 

    • Group on the Group column
    • Groups should be Expanded
    • Include the OpenInNewWindowReplace calculated column

  • Add the default Links List web part to a page on the site

    • Set the web part view to the newly created view from the previous step
    • Append the following to the Web Part description (under advanced)

      • RemoveColumnHeadersAndBlankGroup

  • Add the following HtmlFilters to the page, masterpage, or to a SmartPart on the page (VB.Net syntax).  For C#, change the "" to \"  and ' to // and don't forget your ;'s
'Remove Blank Grouping from Web Parts with "RemoveColumnHeadersAndBlankGroup" at the end of the Web Part description. Updated to ignore expanded group, due to ajax population resulting in hiding the entire section.
FilterReplaceValues.Add("(?is:(?<first>RemoveColumnHeadersAndBlankGroup""(.(?!class=""ms-gb""))*?titl(?<title>\d+)-1_"")(?<second>(.(?!MSOZoneCell_WebPart))*?Group</a> :&nbsp; <span(.(?!TBODY id=""foot))+?isLoaded=""true""))", "${first} style=""display:none"" ${second}")
'Remove Column Headers from Web Parts with "RemoveColumnHeadersAndBlankGroup" at the end of the Web Part description
FilterReplaceValues.Add("(?is:RemoveColumnHeadersAndBlankGroup(?<first>"".*?<TR class=""ms-viewheadertr""))", "${first} style=""display:none""")

'Links with preceding "TRUEOpenInNewWindowReplace" calculated column values should open in a new window
'Hide the OpenInNewWindowReplace Calculated Column Header
FilterReplaceValues.Add("(?is:<TH (?<first>(.(?!</TH>))*?OpenInNewWindowReplace.*?</TH>))", "<TH style=""display:none"" ${first}")
'TRUE (yes)
FilterReplaceValues.Add("(?is:<TD (?<first>(.(?!</TD>))*?"">TRUEOpenInNewWindowReplace</TD>.*?<A .*?) HREF)", "<TD style=""display:none"" ${first} target=""_blank"" HREF")
'FALSE (no) or nothing (blank)
FilterReplaceValues.Add("(?is:<TD (?<first>(.(?!</TD>))*?"">(FALSE)?OpenInNewWindowReplace</TD>))", "<TD style=""display:none"" ${first}")

1 comment:

  1. I changed the syntax slightly to use the Web Part's Description field instead of the Title field. I did this because the Title is used in a few other places for MouseOver (alt) text.