SharePoint Online- Enable New Modern experience on root site collection

UPDATE 9/27/2019- Microsoft this month is releasing a way to “Swap” sites. So create a new modern site collection, then swap it with the root. Invoke-SPOSiteSwap https://docs.microsoft.com/en-us/powershell/module/sharepoint-online/invoke-spositeswap?view=sharepoint-ps#description

If the target is the root site at https://tenant-name.sharepoint.com, then the following preparation activities should be performed prior to performing the swap:

  1. Any Featured links defined in SharePoint Start Page at https://tenant-name.sharepoint.com/_layouts/15/sharepoint.aspx will not be displayed after performing the swap. If required, the Featured links should be documented so they can be manually recreated after the swap.
  2. Functionality such as external sharing and application interfaces are dependent on the policies and permissions defined at the root site. Review the source site to ensure that it has the required policies and permissions as per the existing root site. This includes external sharing settings as well as site permissions.

UPDATE 1/30/2019- Still waiting for the below MS Ignite command. While we wait we can try Jeff Jone’s approach of forcing creation of a modern communication site using the classic site wizard with a client side developer trick: https://www.spjeff.com/2018/12/31/video-create-modern-communication-for-root-site-in-tenant/

UPDATE 9/27/2018- At #MsIgnite, Microsoft just announced a way to convert the root site into a modern communication site using PowerShell!
https://twitter.com/jeffteper/status/1045159986291200000?s=20

Enable-CommSite -url https://yourtenant.sharepoint.com $username [email protected] $password puppies123

Note: this might be the tenant admin url? https://yourtenant-admin.sharepoint.com

This new PS command is not yet publicly available. We just demo’ed it at this session in Ignite. (link: https://myignite.techcommunity.microsoft.com/sessions/65744) myignite.techcommunity.microsoft.com/sessions/65744. We hope to start rolling this out to customers by the end of 2018. Thank you for the enthusiasm and interest.

My old post-

I really enjoy the new Modern experience of SharePoint Online communication sites; however, this requires creating a new SharePoint Online site collection at /sites/new site for the path. The client requested to have the root site branded with the Modern experience. However, while I was able to get the page to appear as the modern experience, I could not match it to the new modern communication sites template 100%. Please post any comments if you have any suggestions to convert the root site to match the communication site look and feel.

SharePoint Online Admin center settings

In the SharePoint Online Admin Center, make sure these settings are all default:

SharePoint Lists and Libraries experience New experience (auto detect)

SharePoint Online root site settings

Next, navigate to your root site, yourcompany.sharepoint.com.

Note how the Modern Experiences is only enabled on lists and libraries by default now days:

To create your first modern page, go to your Pages library. From here, you can create a new “Site Page” which contains all of the new modern page experiences:

Now you can add modern web parts, edit layouts, etc.:

Once finished, publish the page.

Setting modern page as homepage

Go to the pages library, then set the new modern page you published as the homepage by clicking “Make homepage”:

Removing left Quick Launch navigation, attempting to match a classic site to a modern communication site (fail)

The page is now modern, but the quick launch is showing. Modern communication sites do not have this.

This is not easy, unless you want to cheat with CSS. But my goal is to replicate the OOTB new Modern communication site experience on classic pages.

I compared the Site Features between a Classic site and a New Modern Communication Site:

The classic site has the following Site Features activated:

Classic Feature Status
Getting Started Active
Mobile Browser View Active
SharePoint Server Enterprise Site features Active
SharePoint Server Publishing Active
SharePoint Server Standard Site features Active
Site Feed Active
Site Notebook Active
Team Collaboration Lists Active
Wiki Page Home Page Active

Maybe some of these features are the culprit, but nothing stood out.

When I compared the navigation, I found that the Communication sites use Current navigation across the top.

I thought this can be set by swapping the masterpage from “Seattle” to “Oslo” on the Classic site, but it did not affect the modern page I created on the classic site. Crazy.

I also noticed there is no Full Width web part on the modern experience:

So as close as you can get it OOTB is:

Update- how to add a full width web part

If you want to add full width content, you can insert a full-width layout/section to your modern page:

Once you add the full width section, you can add a Hero or Image web part. I dont like these, so I created a custom SPFx jQuery Bootstrap carousel and found a hack to allow the custom web part to appear in this special full width region:

SPFx web part full width hack:
https://blog.velingeorgiev.com/how-add-spfx-webpart-full-width-column

Then, I can add custom HTML/CSS/jQuery to the full width region.

I sometimes copy the home.aspx over and over for subpages so I don’t get the big ugly image banner like I would get OOTB on subpages.

Here is an example of something our team has worked very hard on. I have 1 SPFx web part for the carousel (full width hack) and a SPFx extension for the footer. I sanitized it a lot and excluded a lot of the other web parts due to the data:

SPFx SharePoint full width web part carousel slider

Closing thoughts

If anyone knows how to move the left Quick Launch to under the Site title to match the Communication site template, let me know. Also post any comments about other differences you find between the Modern page on a classic site vs the new Modern communication sites (aside from the O365 group).

SharePoint Online global navigation across site collections, with highlighting and security trimming

One common request when working with SharePoint sites is having a consistent navigation across multiple site collections. If you are using a Publishing Portal site template, you can use the Managed Navigation for your Global Navigation (or top navigation). This also supports drop downs. I did a quick test and it appears to support highlighting of the current element, which is nice considering the URLs are hard coded rather than dynamically added.

As for security, MS indicates the term store navigation supports security trimming as follows: “Note that if users don’t have access to the physical .aspx page (read permissions at least), the link won’t appear in menus even if these options are checked. By this way you can also control links displayed to users according to permissions. It follows the same behavior as the default SharePoint navigation menus.”

The drawback: You have to create a term set in each site collections Managed Navigation, pin EACH of your parent term navigation items (but it includes child terms at least). Its a lot of work, but the only way without custom code. Other options I have seen discussed are using Search web parts or CSOM, etc. Possibly 3rd party solutions. This does not work on new modern team sites (at least at the time of writing this), I get “access denied” when trying to enable Managed Navigation, even after turning on Publishing for the site/web.

Managed Navigation:

Under the target site collection(s), configure your navigation from Site Settings

Ensure Managed Navigation is checked under Global Navigation:

Uncheck:

Next, rather than creating a new term set from the site collection, do it in SharePoint Admin Center.

Go to the Admin tile:

Go to SharePoint under Admin Centers:

Select Term Store on left navigation:

Add your organizational tenant email to Term Store Administrators, save and reload the page.

Then, select the root term store for your O365 tenant, and select New Group:

Type in the orange input box, call it Navigation or something unique:

Select your new term group, and add yourself as a Group Manager and Contributor:

Create new Term Set under the group:

I just called mine Sites, but this is the actual element you will be selecting for your navigation. All child terms will appear in the actual navigation menu.

Then, select the sites element and add yourself as Owner, Contact and Stakeholder and SAVE:

Go to the Intended Use tab at the top, and enable “Use this Term Set for Site Navigation”:

Note: I also see faceted navigation, which IF the product catalog is now possible in SharePoint Online I will do another post soon, as I have been waiting years for this. I remember the roadblock was something with search managed properties…

Then under your term set, add your terms by selecting Create Term:

Go to Navigation tab and add your custom link:

You can create sub terms under terms as well to enable a drop-down navigation.

You can re-order terms in a group by selecting the group and going to Custom Sort:

Now just repeat the first step of selecting Managed Navigation and the Term Group on each of your site collections you want to inherit this navigation.

Update: Selecting this term set is limited to 1 per site collection. So the workaround acording to MS is to “Pin” each of your primary terms (with children) to the new site collections term set. https://support.microsoft.com/en-us/help/3144166/implement-global-navigation-across-multiple-site-collections-through-managed-navigation-in-sharepoint-server-2013 see steps 5-7 One note, it doesn’t seem to preserve custom sorting from the parent term set.

Uncheck:

Done!

Note: if you see any errors (such as Error loading navigation: The Managed Navigation term set is improperly attached to the site), switch the navigation to Structural on BOTH Global and Current, SAVE the changes, then change it back to Managed (and uncheck Add new pages to navigation automatically and Create friendly URLs for new pages automatically) and the error should go away.

Uncheck:

Search Result preview images in SharePoint Online

SharePoint search results OOTB do not display image previews until you hover. We wanted to have a baseball card type approach to display certain items.

Here is an unfinished example of the results displayed as cards with image previews and the OOTB hover panel:

  1. Make sure the site is a publishing portal and publishing features are enabled at the site collection and site level. In order to get the Search Display templates to display the *.html files in the masterpage gallery, some of these features have to be on. Otherwise you just have *.JS files which can limit you. Just ask me under comments if you have any questions.
  2. Modify your Search display template for result items:
    1. /_catalogs/masterpage/Forms/Display%20Templates.aspx
    2. I modified Item_CommonItem_Body.html.
  3. Edit Item_CommonItem_Body.html properties and add the following property:
    1. ServerRedirectedPreviewURL
    2. (properties are separated by a comma, and surrounded by single quotes. So the exact text I added to the end was ,’ ServerRedirectedPreviewURL’ (but replace my blog posts fancy quotes)
  4. Edit the Item_CommonItem_Body.html file (I open with Explorer and edit the file in notepad++)
    1. Verify the property was added:

    2. Next, add a JavaScript tag to store the Preview Image URL as a web safe string:

      imageurlpreview = $htmlEncode(ctx.CurrentItem.ServerRedirectedPreviewURL)

    3. Now, let’s add in our custom HTML. This is kinda “hacky” since I am using this site for a proof of concept and I don’t care if these customizations exist everywhere in my test site collection. Ask me below in comments if you want to know how to copy this file and isolate the results to use this custom template using result types or a custom search results page.
        1. I scrolled down to the first HTML div I found, “ms-srch-item-body”. Right above this, I added my custom Baseball Card HTML. Then I moved the rest of this stuff in except for the closing div tag.
        2. The main thing was this line to add the new JavaScript for the image:

          <img src=”_#= imageurlpreview =#_” alt=”Preview” />

          Here is my baseball card HTML (including the preview image)

          [code language=”html” highlight=”7,30″]
          <div class="cbs-PictureCardsContainer">
          <div class="cbs-PictureCardsImageContainer">
          <a title="Title here" class="cbs-pictureImgLink" href="#">
          <div class="cbs-PictureCardsImage">
          <img src="_#= imageurlpreview =#_" alt="Preview" /></div>
          <div class="sts-cardtype sts-cardtypeidea">
          Type</div>
          </a></div>
          <div title="" class="cbs-pictureCardsCategory ms-noWrap">
          Category</div>
          <div class="cbs-PictureCardsDataContainer">
          <a title="Title here" class="cbs-PictureCardsLine1Link" href="#">
          <div class="cbs-PictureCardsTitle ms-noWrap">
          Pic title</div>
          </a>

          Move all of the OOTB stuff here, starting with the div ms-srch-item-body
          <div title="" class="cbs-PictureCardsDesc">
          Description of image</div>
          </div>
          </div>
          [/code]

        3. Now Save the display template HTML file and publish ONLY the HTML file from the browser (the JS file gets automatically updated instantly):

      Add the baseball card CSS to your result page and you should be good. Again, the element selector (ms-srch-item) for floating these elements is a bit hokey, I could have modified the Control_SearchResults and individual Item templates but this is just a POC.

      [code language=”css” highlight=”2″]
      /* Cards */
      .ms-srch-item {
      width:240px;
      display:inline;
      float:left;
      margin:11px;
      border: 1px solid #DDD;
      clear:none;
      }
      .cbs-PictureCardsImageContainer{
      height:240px;
      border-top-left-radius: 9px;
      border-top-right-radius: 9px;
      width:240px;

      }
      .cbs-PictureCardsImage {
      height:240px;
      overflow:hidden;
      width:240px;

      }
      .cbs-noImageContainer-ContentWrapperLarge {
      display:none;
      }
      .cbs-PictureCardsDataContainer {
      padding: 8px 22px 0px 22px;
      background-color: #f8f8f8;
      color: #212121;
      }
      .cbs-PictureCardsDataContainer a, .cbs-PictureCardsDataContainer a:active, .cbs-PictureCardsDataContainer a:hover, .cbs-PictureCardsDataContainer a:visited {
      color: #212121;
      }
      .cbs-pictureCardsCategory {
      background-color:#666;
      color: #FFF;
      font-weight: bold;
      font-size: 12px;
      padding: 8px 22px 8px 22px;
      border-top:1px solid #FFF;
      }
      .cbs-PictureCardsTitle {
      font-weight: bold;
      }
      .cbs-PictureCardsDesc {
      height: 75px;
      overflow:hidden;

      }

      .sts-cardtype {
      position:relative;
      top:-18px;
      left:120px;
      text-align:center;
      height: 18px;
      width: 120px;
      color:#000;
      font-weight:bold;
      }

      .sts-cardtypeidea {
      background-color:#a8da69;

      }

      .cbs-PictureCardsIconSection {
      float:left;
      margin-top:8px;
      margin-bottom:8px;
      }
      [/code]

    4. Check in and publish your custom result page (the custom ASPX page with all of your search refiners, result web part, search box, above CSS, etc.) and you should be good.

SharePoint 2010 – Themes and CoreV4.css comparison technique for Developers

Ever wonder how SharePoint 2010 uses CoreV4.css and Themes together to style your site? In this blog post, I hope to grab this bull by the horns and make empower you to decode this large file and create your own themes.

Basically, I took CoreV4.css located in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\1033\STYLES\Themable and copied it locally, then attached it to my SharePoint page.

Figure 1- Copy the original CoreV4 from the backend to a local temporary drive to modify. Lcoation: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\1033\STYLES\Themable

Save the copy to your SharePoint site in the Style Library or where you desire.

Open V4.master and add your CSS reference:

Find in V4.master at top:

<SharePoint:CssLink runat=”server” Version=”4″/>

<SharePoint:Theme runat=”server”/>

Add the following AFTER the above tags:

<!–custom add themes and css –>

<SharePoint:CssRegistration runat=”server” name=”<% $SPUrl:~sitecollection/Style Library/ClientName/CSS/style1.css %>” After=”corev4.css”/>

<SharePoint:CssRegistration name=”/Style Library/en-us/Themable/style.css” After=”corev4.css” runat=”server”/>

Change your paths to match. I have two tags, the first is for CSS, and the second is for Themable CSS files using themable comments.

Once your file (copy of Corev4.css named Style or Style1.css) is in place, we can begin modifying it.

Themes:

Themes in SharePoint 2010 are pretty tough. There are about 60 permutations, and you can only define about 10 of those colors.

Heres the table:

Figure 2- You have seen this grid before from the Site Settings > Look and Feel > Themes page. The OOTB one has colors applied to each square. This image maps to the Themes page so you get an idea of what each color is called.

The colors you can define in themes are:

  1. Dark 1
  2. Light 2
  3. Dark 2
  4. Accent 1
  5. Accent 2
  6. Accent 3
  7. Accent 4
  8. Accent 5
  9. Accent 6
  10. non visited link
  11. visited link

The rest are generated from those that you define. This includes gradient images (they use transparent PNG overlays, big plus in my book) and a lot of other images used in SharePoint.

I put together an Excel of OOTB CoreV4.css

This Excel shows all the Theme Permutations, what CSS selector in CoreV4.css uses that Theme permutation, the CSS Selector and code itself, and a guide to whether it’s a Background attribute, Color attribute, or Border attribute defined in that selector.

Download from blog: https://eschrader.com/wp-content/uploads/2011/08/corev4-styles-calculated-no-errors_blog-export.xlsx

This is not used to modify the code (but it could be, just copy the PARSED CSS columns and paste it to a CSS file), but more as a guide to how CoreV4.css works.

The Green shows a match, eg. Which theme color matches to what CoreV4.css selector, and even a possible attribute. If its red, that theme or attribute was not a match in that selector. So if a theme permutation is red, then that theme color is not in that CSS tag. Pretty handy to get an idea whats in this file.

The numbers inside the green are just what position the theme permutation is found, eg. Hyperlink = 88 green just means that the word Hyperlink is found in that particular CSS selector at character 88. They can be ignored, but my Excel skills are lacking in that department 🙂

Each row is a selector from CoreV4.css.

Each of the first 60 columns is a theme permutation, and each cell that is green is a match of that theme permutation in that selectors CSS attributes value.

The column after that, I totalled how many theme permutations in that row are for that selector (some have up to I think 5 theme permutations in a single selector!)

Then the next few columns are the CSS selector, bracket, attributes/values, then closing CSS bracket. This can be copied and pasted into a CSS file if you want, just like CoreV4.css. NOTE: I may have mis-formatted some of the CoreV4.css, so just let me know if you find a typo/bad replacement and I will recheck it).  Note also that I parsed out all themable selectors only for this Excel. My rule to parse was any selector with a comment in the attributes section. CoreV4.css is not the only file, SharePoint has a few more, but this is the big momma of CSS files.

The next columns are some rough CSS attibutes, Background (image or Color), Color (for fonts, etc), and Border (color, size, width, etc)

Thats pretty much the Excel. Just a visual display of this bad boy. Notice how line 469 of my Excel has 0 number of times for a theme found. This is because they did not replace a token in their CSS, /* [ReplaceColor(V4_THEMING_COLOR_DAR2)] */;color: #3b4f65; So I figure if this Excel can catch this, it must be pretty useful.

This gives you an idea for how much themes are used in SharePoint, and how you can modify pretty much everything using your own theme.

I ended up breaking out CoreV4.css into to parts:

  1. Uses themable CSS comments
  2. Does not use themable CSS comments

The themable CSS I moved to a file in the Style Library/en-us/themable directory.

The Non-themable CSS I keep just in the Style Library a few folders down.

When a theme is applied, my themable CSS is applied. When my Non-themable CSS is modified, the changes are reflected instantly on the site.

This allows me to make changes to normal CSS without have to re-apply my theme to the entire site for my changes to show.

Here is a recent project I did, here is the Themable CSS: (must have file checked in, published, and apply another theme, then the theme for the changes to be seen, its pretty crazy… Good luck, once you get it, its easy)

My Themable CSS: (Style Library\en-us\Themable\Style.css)

.pageTitle {

    /* [ReplaceColor(themeColor:”Accent2″)] */    color: #8A2A1C;

    /* [ReplaceColor(themeColor:”Accent1″)] */    border-bottom: 1px #343434 dashed;

}

.bottomFooter, .bottomFooter a, .bottomFooter a:active, .bottomFooter a:hover, .bottomFooter a:visited {

    /* [ReplaceColor(themeColor:”Accent6″)] */    color: #FFFFFF;

}

.rightsidefixed {

    /* [ReplaceColor(themeColor:”Accent5″)] */    background-color:#e5dbc2

}

.s4-toplinks a.dynamic, .s4-toplinks a.dynamic:active, .s4-toplinks a.dynamic:hover, .s4-toplinks a.dynamic:link, .s4-toplinks a.dynamic:visited {

    /* [ReplaceColor(themeColor:”Accent2″)] */    color: #8A2A1C;

}

.ms-navitem A {

    /* [ReplaceColor(themeColor:”Accent6″)] */    color: #FFFFFF !important;

}

#s4-mainarea {

    /* [ReplaceColor(themeColor:”Light2″)] */    border: 6px #EDE8E2 solid;

    /* [ReplaceColor(themeColor:”Light2″)] */    background-color: #EDE8E2;

}

.containerBackground {

    /* [ReplaceColor(themeColor:”Light2″)] */    background-color: #EDE8E2;

}

body #s4-workspace {

    /* [ReplaceColor(themeColor:”Accent2″)] */    background-color: #8A281C;

}

body .s4-toplinks {

    /* [RecolorImage(themeColor:”Accent2″)] */    background: url(“/_layouts/images/selbg.png”) repeat-x left top;

    /* [ReplaceColor(themeColor:”Accent2″)] */    background-color: #f6f6f6;

    /* [ReplaceColor(themeColor:”Light2″)] */    border: 5px solid #ede8e2;

}

.s4-tn li.static > .menu-item, .s4-tn li.static > .menu-item:active, .s4-tn li.static > .menu-item:hover, .s4-tn li.static > .menu-item:link, .s4-tn li.static > .menu-item:visited {

    /* [ReplaceColor(themeColor:”Light1″)] */    color: #3b4f65;

}

.s4-toplinks .s4-tn a.selected, .s4-toplinks .s4-tn a.selected:active, .s4-toplinks .s4-tn a.selected:hover, .s4-toplinks .s4-tn a.selected:link, .s4-toplinks .s4-tn a.selected:visited {

    /* [ReplaceColor(themeColor:”Light2″)] */    border-color: #91cdf2;

    /* [RecolorImage(themeColor:”Light2″)] */    background: url(“/_layouts/images/selbg.png”) repeat-x left top;

    /* [ReplaceColor(themeColor:”Light2″)] */    background-color: #ccebff;

    /* [ReplaceColor(themeColor:”Accent2″)] */    color: #003759;

}

#s4-leftpanel, #s4-leftpanel a, #s4-leftpanel a:active, #s4-leftpanel a:hover, #s4-leftpanel a:link, #s4-leftpanel a:visited, #s4-leftpanel .ms-vb {

    /* [ReplaceColor(themeColor:”Light1″)] */    color:#FFFFFF

}

#s4-leftpanel #DatePickerDiv, #s4-leftpanel #DatePickerDiv a, #s4-leftpanel #DatePickerDiv a:active, #s4-leftpanel #DatePickerDiv a:hover, #s4-leftpanel #DatePickerDiv a:link, #s4-leftpanel #DatePickerDiv a:visited, #s4-leftpanel #DatePickerDiv .ms-vb {

    /* [ReplaceColor(themeColor:”Dark1″)] */    color:#343434

}

body #s4-leftpanel {

    /* [ReplaceColor(themeColor:”Accent3″)] */    background-color: #567F1A;

    /* [ReplaceColor(themeColor:”Light1″)] */    color:#FFFFFF

}

body #s4-leftpanel-content {

    /* [ReplaceColor(themeColor:”Light2-Lightest”)] */    border: 1px solid #dbddde;

}

.s4-ql ul.root > li > .menu-item, .s4-qlheader, .s4-qlheader:visited {

    /* [ReplaceColor(themeColor:”Light1″)] */    color: #FFFFFF;

}

.s4-ql ul.root ul > li > a {

    /* [ReplaceColor(themeColor:”Light1″)] */    color: #FFFFFF;

}

.s4-ql ul.root ul > li > a:hover {

    /* [ReplaceColor(themeColor:”Light1″)] */    color: #FFFFFF;

}

.s4-ql a.selected {

    /* [ReplaceColor(themeColor:”Accent4″)] */    background-color: #345208;

    /* [ReplaceColor(themeColor:”Light2-Lighter”)] */    border-top-color: #c6e5f8 !important;

    /* [ReplaceColor(themeColor:”Light2″)] */    color: #FFFFFF !important;

}

.s4-specialNavLinkList a {

    display: block;

    padding: 3px 4px 3px 10px;

}

.s4-specialNavLinkList a {

    /* [ReplaceColor(themeColor:”Light2″)] */    color: #3b4f65;

}

.ms-rteStyle-ContentHeader {

-ms-name:”Content Header”;

    /* [ReplaceColor(themeColor:”Accent2″)] */    background-color: #841019;

    /* [ReplaceColor(themeColor:”Light1″)] */    color: #FFFFFF;

    font-size:10pt;

    font-weight:bold;

    padding:4px 4px 5px 5px;

    border-top:5px #EDE8E2 solid;

    margin:0px;

    border-bottom:5px #FFFFFF solid;


}

.ms-rteStyle-ContentBackground {

    -ms-name:”Content Background”;

    background-color:#fff;

    margin:0px;

    padding:6px 10px;

}

.ms-WPHeader {

    /* [ReplaceColor(themeColor:”Accent2″)] */    background-color: #841019;

    /* [ReplaceColor(themeColor:”Light1″)] */    color: #FFFFFF;

}

.ms-WPTitle, .ms-WPTitle a, .ms-WPTitle a:active, .ms-WPTitle a:hover, .ms-WPTitle a:link, .ms-WPTitle a:visited {

    /* [ReplaceColor(themeColor:”Light1″)] */ color: #FFFFFF;

}

.s4-wpActive .ms-WPTitle, .s4-wpActive .ms-WPTitle a {

    /* [ReplaceColor(themeColor:”Light1″)] */ color: #FFFFFF;

}

My recent adjacent Style1.css file (Style Library\ClientName\CSS\Style1.css)

/*shell- under construction*/

body #s4-bodyContainer {

    margin: 0 3%;

    min-width: 935px;

/*no height in ie7, ie8, for firefox set height to 100%*/

}

body #s4-titlerow {

    border-left: 13px transparent solid;

}

/*modal shell – after shell*/

.ms-dialog body #s4-bodyContainer {

    margin: 0;/*remove red background margin from popup*/

    min-width: inherit;

}

.ms-dialog #s4-mainarea {

    border: 0px transparent solid; /* remove borders around content of popup*/

}

.ms-dialog .bottomFooter {

    display:none /* hide footer*/

}

/*shell*/

div.s4-pr {

    border-right: 0px transparent none;

}

/*BG Logos*/

#s4-workspace > div {

    background-image: url(‘../Images/bg_gradient.png’);

    background-repeat: repeat-y;

    background-position: -20px top;

}

#s4-workspace {

    background-image: url(‘../Images/PowayBuilding.png’);

    background-repeat: no-repeat;

    background-position: -20px top;

    background-attachment: scroll;

}

/*Header styling*/

.ms-siteactionsmenu > SPAN > SPAN > A {

    color:#FFFFFF

}

.s4-titletext {

    padding-bottom: 0px;

}

.s4-titletext {

    vertical-align: bottom;

}

table.s4-wpTopTable {

    margin-right: 4px;

}

.s4-help {

    margin-left: 4px;

}

/* Top Nav */

.s4-title {

    overflow: visible;

}

body #s4-topheader2 {

    border: 0px transparent none;

}

.s4-tn LI.dynamic > .menu-item:visited {

    font-weight: bold;

}

.s4-tn LI.dynamic > .menu-item:hover {

    font-weight: bold;

}

.s4-tn LI.dynamic > .menu-item:active {

    font-weight: bold;

}

.s4-tn LI.dynamic > .menu-item:link {

    font-weight: bold;

}

.s4-tn LI.dynamic > .menu-item {

    font-weight: bold;

}

.s4-tn ul.dynamic {

    padding: 5px;

    border-bottom: 1px #CFAEA4 solid;

}

.s4-tn a:visited {

    font-weight: bold;

}

.s4-tn a:link {

    font-weight: bold;

}

.s4-tn a:hover {

    font-weight: bold;

}

.s4-tn a:active {

    font-weight: bold;

}

.s4-tn a {

    font-weight: bold;

}

.menu-horizontal {

    padding: 0px;

    border: 0px;

    margin: 0px;

    border-spacing: 0px;

}

body .s4-toplinks {

    border-bottom: 0px solid transparent;

}

.s4-toplinks .s4-tn a.selected, .s4-toplinks .s4-tn a.selected:active, .s4-toplinks .s4-tn a.selected:hover, .s4-toplinks .s4-tn a.selected:link, .s4-toplinks .s4-tn a.selected:visited {

    padding: 4px 10px 6px 10px;

    margin: 0px 10px;

    border: 0;

}

/*breadcrumbs*/

.s4-title H1 A, .s4-title H2 A {

    display: inline;

}

.breadcrumbs {

    min-height: inherit;

    min-height: 10px;

}

.breadcrumbs h2 {

    font-size: 10px;

    text-decoration: none;

    padding-bottom: 1px;

}

.breadcrumbs a:link {

    font-size: 10px;

    text-decoration: none;

    padding-bottom: 1px;

}

.breadcrumbs a:visited {

    font-size: 10px;

    text-decoration: none;

    padding-bottom: 1px;

}

.breadcrumbs a:hover {

    font-size: 10px;

    text-decoration: none;

    padding-bottom: 1px;

}

.breadcrumbs a:active {

    font-size: 10px;

    text-decoration: none;

    padding-bottom: 1px;

}

.breadcrumbs a {

    font-size: 10px;

    text-decoration: none;

    padding-bottom: 1px;

}

.breadcrumbs {

    font-size: 10px;

    text-decoration: none;

    padding-bottom: 1px;

}

/*Left nav */

.ms-quicklaunchouter {

    width:100% /* Fixes minimum width in quick launch */

}

.leftnavtop, .ms-quicklaunchouter {

    float: left;

}

body #s4-leftpanel {

    width: 170px; /* make sure you set the margin-left on MSO_ContentTable to this number*/

}

/*left navigation indent first level */

#s4-leftpanel-content ul.root > li.static > a.static {

    border-bottom: 1px solid #ffffff;

    font-weight: bold;

}

/* left navigation indent second level*/

#s4-leftpanel-content ul.root > li.static > ul.static {

    padding-left: 20px;

    margin-left: -10px;

}

/* left navigation indent third level */

#s4-leftpanel-content ul.root > li.static > ul.static > li.static > ul.static {

    padding-left: 20px;

    margin-left: -10px;

/* left navigation indent fourth level*/

}

#s4-leftpanel-content ul.root > li.static > ul.static > li.static > ul.static > li.static > ul.static {

    padding-left: 30px;

    margin-left: -10px;

}

.s4-ql UL.root UL {

    margin: 0px;

}

.ms-quickLaunch {

    padding: 0px;

}

body #s4-leftpanel-content {

    padding: 0px 0px 5px;

    background-color: transparent;

    border-top-width: 0px;

    border-right-width: 0px;

    border-bottom-width: 0px;

    border-left-width: 0px;

}

.s4-ql ul.root > li > .menu-item, .s4-qlheader, .s4-qlheader:visited {

    font-size: 1.2em;

    margin: 0px;

    padding: 3px 4px 3px 10px;

    border-width: 1px 0px;

    border-style: solid;

    border-color: transparent;

    word-wrap: break-word;

    overflow-x: hidden;

}

.s4-ql ul.root ul > li > a {

    padding: 3px 4px 4px 10px;

    border-width: 1px 0px;

    border-style: solid;

    border-color: transparent;

    overflow-x: hidden;

    display: block;

    zoom: 1;

}

.s4-ql ul.root ul > li > a:hover {

    text-decoration: underline;

}

.s4-ql a.selected {

    background: url(“/_layouts/images/selbg.png”) repeat-x left top;

    border-width: 0px !important;

    padding-left: 9px !important;

}

/*content styling*/

#MSO_ContentTable {

    margin-left: 175px; /* Set s4-leftpanel width to equal or less than this*/;

    background-color: #EDE8E2; /*sets main area background color */

}

.contentCenterRegion {

    vertical-align: top;

}

ul.ms-rteStyle-ContentBackground, ol.ms-rteStyle-ContentBackground {

    list-style-position: inside; /*fix for rtf bullet points being to far to the left, also ordered lists */

}

.rightsidefixed {

    width: 250px; /* sets right layout zone width*/;

    vertical-align: top;

}

div.s4-title {

    background: transparent;

    background-color: transparent;

}

.ms-WPHeader {

    border-bottom: 5px #FFFFFF solid;

}

.ms-WPHeader TD {

    border-bottom: transparent 0px none !important;

    border-right: transparent 0px none !important;

    border-top: transparent 0px none !important;

    border-left: transparent 0px none !important;

}

.s4-wpTopTable, .s4-wpActive, .ms-settingsframe {

    background-color: #FFFFFF; /*make web part backgrounds white, even in edit mode*/;

}

.ms-rte-wpbox {

    margin-bottom: 8px; /*add spacing below each webpart*/

}

.floatleft {

    float: left;

}

.floatright {

    float: right;

}

.pageTitle {

    font-size: 20px;

    font-weight: bold;

    margin: 0px;

    padding: 0px;

    width: 80%;

    padding-top: 0px;

    margin-left: 10px;

    letter-spacing: 1px;

}

.ms-WPTitle {

    font-weight: bold;

}

/* Style right side web parts */

.rightSide #MSOZoneCell_WebPartWPQ20 {

    background-color: #fff;

    border: 5px #EDE8E2 solid;

}

.rightSide #MSOZoneCell_WebPartWPQ19 {

    background-color: #fff;

    border: 5px #EDE8E2 solid;

}

.rightSide #MSOZoneCell_WebPartWPQ18 {

    background-color: #fff;

    border: 5px #EDE8E2 solid;

}

.rightSide #MSOZoneCell_WebPartWPQ17 {

    background-color: #fff;

    border: 5px #EDE8E2 solid;

}

.rightSide #MSOZoneCell_WebPartWPQ16 {

    background-color: #fff;

    border: 5px #EDE8E2 solid;

}

.rightSide #MSOZoneCell_WebPartWPQ15 {

    background-color: #fff;

    border: 5px #EDE8E2 solid;

}

.rightSide #MSOZoneCell_WebPartWPQ14 {

    background-color: #fff;

    border: 5px #EDE8E2 solid;

}

.rightSide #MSOZoneCell_WebPartWPQ13 {

    background-color: #fff;

    border: 5px #EDE8E2 solid;

}

.rightSide #MSOZoneCell_WebPartWPQ12 {

    background-color: #fff;

    border: 5px #EDE8E2 solid;

}

.rightSide #MSOZoneCell_WebPartWPQ11 {

    background-color: #fff;

    border: 5px #EDE8E2 solid;

}

.rightSide #MSOZoneCell_WebPartWPQ10 {

    background-color: #fff;

    border: 5px #EDE8E2 solid;

}

.rightSide #MSOZoneCell_WebPartWPQ9 {

    background-color: #fff;

    border: 5px #EDE8E2 solid;

}

.rightSide #MSOZoneCell_WebPartWPQ8 {

    background-color: #fff;

    border: 5px #EDE8E2 solid;

}

.rightSide #MSOZoneCell_WebPartWPQ7 {

    background-color: #fff;

    border: 5px #EDE8E2 solid;

}

.rightSide #MSOZoneCell_WebPartWPQ6 {

    background-color: #fff;

    border: 5px #EDE8E2 solid;

}

.rightSide #MSOZoneCell_WebPartWPQ5 {

    background-color: #fff;

    border: 5px #EDE8E2 solid;

}

.rightSide #MSOZoneCell_WebPartWPQ4 {

    background-color: #fff;

    border: 5px #EDE8E2 solid;

}

.rightSide #MSOZoneCell_WebPartWPQ3 {

    background-color: #fff;

    border: 5px #EDE8E2 solid;

}

.rightSide #MSOZoneCell_WebPartWPQ2 {

    background-color: #fff;

    border: 5px #EDE8E2 solid;

}

.rightSide #MSOZoneCell_WebPartWPQ1 {

    background-color: #fff;

    border: 5px #EDE8E2 solid;

}

.rightSide .ms-WPBody {

    padding: 10px;

}

/*News Webpart*/

.NewsArea {

    padding: 5px;

}

.NewsDate {

    padding-bottom: 5px;

}

/*user presence icon*/

.ms-imnlink img {

    border: 0px;

}

/*user description*/

div.description {

    padding-left: 17px;

}

/*footer styling*/

.bottomFooter {

    min-height: 44px;

    padding-top: 16px;

    padding-left: 4px;

    padding-right: 4px;

    clear: both;

}

.footerlinks {

    word-spacing: 4px;

    padding-bottom: 4px;

    line-height: 14px;

}

That’s it, let me know if you have questions and I can get more detail/instructions on any part.

For more on how to work with CoreV4.css and create your own CSS, see my other blog post from today.

A great way to create SharePoint 2010 CSS from original CSS

Working with SharePoint 2010’s CoreV4.css is very difficult. I have developed a technique to allow developers to leverage SharePoints OOTB CoreV4.css selectors, but while not hacking together CSS selectors and dealing with !important and other CSS hacks.

Here is the concept:

Your SharePoint page will have 2 stylesheets on it, CoreV4.css and a new blank file, Custom.css. Custom.css will have the exact contents of CoreV4.css, but be attached AFTER coreV4.css so it overwrites the original. This will allow you to modify Custom.css (a copy of CoreV4.css) directly from the SharePoint Designer or the browser. You can use IE Developer Toolbar or Firebug to get the selectors SharePoint 2010 uses OOTB, search for that selector in Custom.css, modify it, then save and test. Repeat for each change.

Once complete, you will have CoreV4.css (original) and Custom.css, both two very large files.

This next step is optional, but highly recommended for Production. Take CoreV4.css, format the CSS so the selectors are each on their own line, along with their attributes all on the same line. This way you only have each line starting with the selector.

Figure 1- Copy the original CoreV4 from the backend to a local temporary drive to modify. Lcoation: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\1033\STYLES\Themable

Once Copied locally, you can open it in Microsoft Expression Web:

You should see:

From here, we need to Reformat the CSS to have each selector on its own line, eg:

Here is how we do it:

In Expression Web, go to Tools> Page Editor Options

Click on the Code Formatting Tab

We will modify these formatting rules to put each selector on one line.

Under the bottom CSS section, modify the following:

Figure 2- No changes to Selector

Figure 3- Change Lines After from 1 to 0

Figure 4- Property Name- No Changes

Figure 5-Proptery Value change Lines after from 1 to 0

Figure 6- Closing Brace change Lines Before from 1 to 0, HIT OK

Now we can format our CoreV4.css copy to have each selector on its own line:

Figure 7- Right click on CoreV4.css in the Code view and go to Reformat CSS (Note, the file extention is .css)

Your CSS should all be on one line:

Repeat the same steps for Custom.css (figure 7 and 8 above) (the copy of CoreV4.css you have been modifying. Once Custom.css looks like above, but with your changes, we can compare the two files and extract only the changed lines as an overwritter CSS file for Corev4.css )

I use Beyond Compare for this next step to compare the changes. You can use any tool that allows you to compare two text files and ONLY VIEW DIFFERENCES, and ALLOWS YOU TO EXTACT (copy and paste) OUT ONLY THE CHANGED LINES!

In Beyond Compare, do a new TEXT compare:

Figure 8- Click Text Compare from the button

Copy CoreV4.css

Paste on the left of the text compare:

Figure 9- Paste on left

Copy Custom.css, (MAKE SURE ITS FORMATTED THE SAME AS COREv4.css, ALL SELECTORS ON OWN LINE)

Paste on the right side (MAKE SURE YOU ARE ON THE FIRST LINE, SCROLL TO THE TOP BEFORE YOU PASTE!) of the text compare:

Now apply a filter to the comparison to only show changes:

Figure 10-Click Show Differences from the top bar.

Figure 11- Uncheck Show Context (one with the up and down arrows and the red line)

Copy out the code on the right side with Select all, then Copy it.

Now you can paste this code over your Custom.css file to only have the CSS Overwritters

.ms-SPLink {font-family: ‘Arial’,’Lucida Grande’,Verdana,Arial,sans-serif; font-size: 0.8em; /* [ReplaceColor(themeColor:”Accent3-Darker”)] */; color: #1A70B9;}

.ms-SPLink a:link, .ms-SPLink a:visited {/* [ReplaceColor(themeColor:”Accent3-Darker”)] */ color: #000000; text-decoration: none;}

My code, I changed the Font to Arial and the font color to #000000. No need for an entire duplicate of CoreV4.css in my Custom.css, just need the overwriting different CSS.

Note, this file contains Themable CSS comments. For my code changes to be applied, The CSS must be embeded to my masterpage using the following tag in the header, after the other CSS Theme tags.

<SharePoint:CssRegistration name=”/Style Library/en-us/Themable/style.css” After=”corev4.css” runat=”server”/>

 Then make sure you SAVE, Check in and publish/approve this CSS file. THEN apply a different theme, then apply back the desired theme. You CSS will now be visible. NOTE: apply themes to all subsites if you want the CSS to be visible during these steps.

Only do this at Export, as you want to have Custom.css a complete copy of Corev4.css during Development.

Hope this helps!

For more on modifying CoreV4.css, see my other blog post from today.

SharePoint static 2nd level current navigation in MOSS 2007

Summary

Requirements:

  • SharePoint MOSS 2007
  • Must be using a Publishing Site

This post will create the SharePoint Current Navigation control that only shows the 2nd level site when browsing, and supports highlighting. The datasource comes from SharePoint as well, so everything is security trimmed, and editable in the browser.

This post is for users who are using SharePoint MOSS 2007 navigation on their website. If you want your current navigation to display the sites and pages under a subsite, but always keep the second level subsite on top, then this post is for you. It’s hard to explain, so reference the screenshot below:

Figure 1 – Our Firm is a subsite under the root of the website. Even if I navigate to Board of Directors above, Our Firm remains at the top of the Current Navigation.

Sitemap data for my screenshot above:

  • Company
    • Our Firm
      • Leadership
        • Management Team
        • Board of Directors
      • Contact Us
      • Locations
    • Investment Banking
    • Sales & Training
    • Research

Sitemap levels:

  • Top Level (root)
    • Second Level site
      • Third Level Site
        • Fourth Level site
        • Fourth Level site
      • Third Level Site
      • Third Level Site
    • Second Level site
    • Second Level site
    • Second Level site

The key is that I want only each second level navigation block to appear when a user is anywhere on or under that second level site. So in my screenshot, you see Our Firm, even if you navigate to Board of Directors.

This navigation also supports highlighting and pages.

Preparing the subsite (our Firm)

  • Check Show Subsites and Show Pages
  • Under Current Navigation, select Display current, below, and siblings. (the middle radio button)

Now you need to adjust your current navigation code in the MASTERPAGE to only show the site you are under.

Adjusting the masterpage Current Navigation

Find your PlaceHolderLeftNavBar and replace the contents with this, or you can just mimic it. Take note of the highlighted parts. These are important for this post.

Placeholders are content buckets in your masterpages, the content inside them is what is important. Just make sure you don’t have multiple of the same ID’s on the same masterpage.

Here is the code:

<asp:ContentPlaceHolder id=”PlaceHolderLeftNavBar” runat=”server”>

    <!– Current Navigation –>

    <!– Current Navigation –>


    <SharePoint:AspMenu ID=”CurrentNav” runat=”server” datasourceID=”SiteMapDS” orientation=”Vertical”

    StaticDisplayLevels=”4″ MaximumDynamicDisplayLevels=”1″ StaticSubMenuIndent=”1″ ItemWrap=”true”

    AccessKey=”3″ CssClass=”leftNav” SkipLinkText=”<%$Resources:cms,masterpages_skiplinktext%>”>

        <StaticHoverStyle CssClass=”LeftStaticHover” Font-Bold=”False” Font-Italic=”False” Font-Overline=”False” Font-Strikeout=”False” Font-Underline=”False” />

        <StaticSelectedStyle CssClass=”LeftStaticSelected” Font-Bold=”False” Font-Italic=”False” Font-Overline=”False” Font-Strikeout=”False” Font-Underline=”False” />

        <DynamicMenuStyle CssClass=”LeftDynamicMenu” Font-Bold=”False” Font-Italic=”False” Font-Overline=”False” Font-Strikeout=”False” Font-Underline=”False” />

        <DynamicMenuItemStyle CssClass=”LeftDynamicMenuItem” Font-Bold=”False” Font-Italic=”False” Font-Overline=”False” Font-Strikeout=”False” Font-Underline=”False” />

            <LevelMenuItemStyles>

                <asp:menuitemstyle CssClass=”parent” Font-Underline=”False” />

                <asp:menuitemstyle CssClass=”child” Font-Underline=”False” />

                <asp:menuitemstyle CssClass=”leftNav3″ Font-Underline=”False” />

                <asp:menuitemstyle CssClass=”leftNav4″ Font-Underline=”False” />

                <asp:menuitemstyle CssClass=”leftNav5″ Font-Underline=”False” />

            </LevelMenuItemStyles>

        <StaticMenuStyle CssClass=”LeftStaticMenu” Font-Bold=”False” Font-Italic=”False” Font-Overline=”False” Font-Strikeout=”False” Font-Underline=”False” />

        <DynamicSelectedStyle CssClass=”LeftDynamicSelected” Font-Bold=”False” Font-Italic=”False” Font-Overline=”False” Font-Strikeout=”False” Font-Underline=”False” />

        <StaticMenuItemStyle CssClass=”LeftStaticMenuItem” Font-Bold=”False” Font-Italic=”False” Font-Overline=”False” Font-Strikeout=”False” Font-Underline=”False” />

        <DynamicHoverStyle CssClass=”LeftDynamicHover” Font-Bold=”False” Font-Italic=”False” Font-Overline=”False” Font-Strikeout=”False” Font-Underline=”False”/>

    </SharePoint:AspMenu>

    <PublishingNavigation:PortalSiteMapDataSource ID=”SiteMapDS” Runat=”server”

    SiteMapProvider=”CombinedNavSiteMapProvider

    StartFromCurrentNode=”True”

    StartingNodeOffset=”1″ TrimNonCurrentTypes=”Page”/>

</asp:ContentPlaceHolder>

Here is an explanation of the above code:

SharePoint:AspMenu Creates an ASP.Net menu (html) using tables
datasourceID This sets the Datasource to populate the HTML. In this case, it points to the ID of the PublishingNavigation:PortalSiteMapDataSource.
StaticDisplayLevels How many levels to display (non flyouts) starting from the data returned. If your datasource only returns second level sites, the ASP Menu sees these as the first level.
MaximumDynamicDisplayLevels 1 disables flyouts. 2 would have the 5th level links as a flyout.

Datasource properties

PublishingNavigation:PortalSiteMapDataSource Creates a datasource on our page. This control uses the SharePoint Navigation.
ID Sets the ID of this datasource for ASP.Menu or other controls to access the data
SiteMapProvider There are a lot. I really like CombinedNavSiteMapProvider for this blog post. It was the best I found. Here are a few more
StartFromCurrnetNode Not sure why, but I think this controls the highlighting of sub sites. If this is set to false, I think the returned data source does not know what site you are located in. More here
StartingNodeOffset This is the reason why we see the second level page at the top of our left navigation, and not the root. We trim the root, as 0 is default, but we specify 1. This trims one level off our data source. See a full explanation here
TrimNonCurrnetTypes Since we specify pages, this removes all pages from the datasource that are not under the current site, and not below. See here for more info

See this same table (and ALL OTHER PROPERTIES!) here: http://msdn.microsoft.com/en-us/library/bb897657.aspx

Basically, just play around with the code. You can learn a lot just modifying the above properties. I basically wanted this blog post to show a neat configuration of SharePoint navigation 🙂

Good luck!

HTML Hyperlink tags and word-wrap padding fix

Recently, I noticed when I have the following code, my text wraps and ignores my padding for the second line.

<style>

.menuItemLvl2 {

Padding-left: 24px;

}

</style>

I wanted the hyperlink a tag to wrap and respect the padding. I also had highlighting on the A hyperlink tag for :hover state, so I coudnt use Margin-left:24px.

I applied the following CSS to fix my issue: ( I only add the green highlighted text to the above code)

<style>

.menuItemLvl2 {

Padding-left: 24px;

Float:left;

Width:200px; /* Note: you cannot use 100%, as the padding pushes the element out of its container that has a width of 224px. Use container width minus padding of this element*/

}

</style>

And on hover: (note, I did not include the code for a:hover in this example, but just set the background-color: #666666 or whatever color)

Works in Firefox and IE7.

SharePoint 2007 Branding links

  • Real World Branding with SharePoint Server 2007 Publishing Sites

    http://msdn.microsoft.com/en-us/library/ee354191.aspx

  • Heather’s Base Master Page Files
    Base master page files with necessary content placeholders to run a SharePoint site. All branding and added code is stripped out.
  • CSS Reference Chart
    Informative chart of popular CSS classes and IDs.
  • Design Gotcha List
    List of items to watch out for when you are rebranding SharePoint. Includes red flags for problem areas and screenshots.
  • SharePoint Resources
    Blog posts, articles, tools, product information and more. Large resource list focused on customization, but also with many non-customization related resources
  • URL Quick List
    List of links to commonly used administrative functions.
  • SharePoint Tools for Style: How to Start Branding SharePoint

    You have a site design and your trusty copy of SharePoint Designer, but now what? In this session, we cover SharePoint branding concepts and benefits and show step by step how to create a custom master page using Microsoft Office SharePoint Designer.

    Slide Deck Great slides on branding

     

     

XSLT Data View Web Parts in SharePoint Designer- Why changing the layout is can break your template.

My last post offered clues as to why Data View web parts break. All my previous web parts were using custom Layouts to strip out all the surrounding layout tables.

Here is a rough idea how the default Layout is constructed.

Figure 1- The above is a default Multi-item XSLT Data View web part template without paging (Display all items). Notice how there is a Table Row (TR) for each data row.

Normally, in the past, I did not want my data to be separated in its own table row (TR). I wanted my data to be separated with a line break, or all on the same line, or all in the same row. I would change the layout.

The problem with this is, after multiple re-saving of the ASPX page in SharePoint Designer, the page begins to auto insert generated code into the page or DataView web part. This causes the web part to break and you can lose your template.

The workaround:

Instead of changing your layout, try to work with the existing layout. That’s it!

Here is a diagram of what I wanted:

Figure 2- Basically, it’s the same template as above. I removed the TH text, but left the code. For the Green TD above, I used XSL:Text disable-output-escaping=yes to construct all my conditions.

The above is just my example, as there is a lot of formatting. Basically I have Id’s, Classes, and Numbers I sort by and place in their own TD’s, TR’s (Every 5 cells), and headers for every certain number. Each class has its own TD. (specific to my data schema)

The point I am trying to prove is that outside of the For-Each is intact. All my modifications were around this for-each, but not to my TH class, or any other template.

XSLT – Data View wp- Unable to display this Web Part (only for any other user other than yourself.)

I got the following error when developing my web part and having my manager log in to check the page. But the page worked fine for me, and was not checked out, as I was not using Publishing Features.

Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint Services-compatible HTML editor such as Microsoft Office SharePoint Designer. If the problem persists, contact your Web server administrator

The Problem

The page would load fine for me in browser. In SharePoint Designer, I would have an older data set in my data view web part. I would break the web part when I did a Refresh Data Source, so I left it as it was. I had enough data to continue building out my template.

Once I had my manager review my work on his computer, the page gave him the error Unable to display this Web Part. So, I logged in as myself (To make sure the old template was not cached on my computer) and it worked for my user.

The Solution

Follow-up: This is not a solution, but a work around. Upon Re-saving the page in SPD, the error occurred once again. See future post on 10/15/09 about XSLT layouts and why they break your data view web part.

At one point, I did have the page checked out, but it seem to automatically disguard it when I tried to check it back in. Really weird, so I made a copy of the Default.aspx page that contained my web part. I right clicked the copy and said Reset to Site Definition.

I noticed the web part was still on the page. I guess since web parts don’t support versioning, resetting the page only resets the code around web part zones. My web part was still on the copy. I suspected that if I reset the page and that it just might work now. I logged in as another user and it worked.

Here are the steps:

  1. Make a copy of the ASPX page containing your “Broken” web part
  2. Reset the COPY to Site Definition
  3. Try the newly reset page and see if it works for your users.

Summary

I have noticed a lot of XSLT web part errors. I am starting to log them in one place as an archive of solutions, rather than abandoning my web part and starting over each time I get an error.

SharePoint XSLT error – Unable to display this Web Part.

Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint Services-compatible HTML editor such as Microsoft Office SharePoint Designer. If the problem persists, contact your Web server administrator.

This error could be caused by missing double quotes around your HTML markup attributes. For instance, the error below is missing double quotes around the table width=”600″ attribute. Simple change width=600 to width=”600″ and everywhere you have an attribute value (This includes classes, etc.).


Figure 1- Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint Services-compatible HTML editor such as Microsoft Office SharePoint Designer. If the problem persists, contact your Web server administrator.

If you have seen this error, there might be a very simple solution.

The Solution:

Make sure all HTML template attribute values are contained in double quotes (eg. “value” and not just value.).

In my above example, I modified a Table tag inside my body template of the Data View web part. I replaced <table width=”600″> with <table width=600> and got the above error. This happens with classes and all HTML tag attributes (class=”Testing” is valid for an XSLT template in SharePoint, whereas class=testing causes the Unable to display this Web Part error.

This error is really broad, and I’m sure it won’t help everyone, but it’s a good start and easy fix for some situations.

SharePoint designer – How to fix XSL Data View error: “Unable to display this Web Part”

I found an interesting thing about the error message I was getting with SharePoint Designer. The error is:

“Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint Services-compatible HTML editor such as FrontPage. If the problem persists, contact your Web server administrator”

I had a complicated Data view web part that I did not want to recreate.

The Solution:

Open the aspx file in notepad from SharePoint Designer. If you notice a bunch of HTML markup formatted as “&gt;” etc, then open the file normally in SharePoint designer Code View. Copy ALL the code and paste it into Notepad. Copy the code from notepad and replace your code view text. Save and view in browser. No more XSL DATA VIEW ERRORS!

The code view actually contains a rich text type of rendering. When you copy it out and paste it in notepad, it loses all of the special formatting. This allows the page to render correctly.

Page Titles disappear after Ajax event

The Problem:

SharePoint page titles when using Ajax may turn to square icons. This is the rendering of the title tag in the masterpage, or where the page title is specified. A normal SharePoint masterpage specifies the title on 3 lines, the first line is for the opening tag, second line contains the content place holder for page title, and the 3rd line in the masterpage’s title is for the closing title tag. You get something that looks like this:

BlueBand.master
<Title ID=onetidTitle>

<asp:ContentPlaceHolder id=PlaceHolderPageTitle runat=”server”/>

</Title>

Rendered HTML after Ajax panel update:
<title>

Home

</title>

Basically, the tabs indenting “Home” are rendered as nothing in IE7 Page Title, but in the tab title, they are rendered as 3 little squares.

The Solution:

Put the title tag on one line! That’s it! No need for JavaScript or anything else when using Ajax on a page! Just edit the CORRECT masterpage, (For Publishing Portal, the default is BlueBand.master, for Team and Collaboration sites, it’s Default.master) I made the mistake of editing Default.Master for the fix and was using a Publishing Portal, and didn’t see my changes!

Here’s the code fix:

BlueBand.master (or Default.master):
<title id=”onetidTitle”><asp:ContentPlaceHolder id=”PlaceHolderPageTitle” runat=”server”/></title>

Having ANY tabs in your source code will render nothing for your page title. You MAY use spaces, but NOT formatting tabs.

SharePoint Designer – CSS Caching issues with Visual Studio Web Part packages

I have recently ran into an issue with SharePoint Designer and modifying a CSS file. The CSS file would not update my changes.

I waited a 1/2 a day, checked different browsers, cleared my temp/etc, tried virtual machines that havent seen the website in months. Nothing was reflecting my SharePoint Designer CSS changes. I was also logged in as the same user, and I checked to make sure that the CSS file was being referenced, and no others were overwritting it.

What could it be? Well, after confirming that even deleting the file would not change any of the CSS, I worked with my co-worker about server-side caching. These CSS files deployed Via web part are located in the 12 hive. When you edit them in SPD, the file is a ghosted version. After you publish the file, you can Reset to Site Definition. We checked the Blobcache settings via server side and noticed that the caching was set to 24 hours. Another CSS file deployed via web part was ghosted, and the changes would reflect real time as I saved. Really strange behavior.

I will keep looking into this and post a solution.