Tuesday, June 22, 2010

SharePoint Designer 2010 – Quick Tips

Jeremy Williams, Sr. Director, Modern Workplace

For the uninitiated, SharePoint Designer 2010 (SPD) has been revamped alongside the rest of Office 2010.  Not only does SPD get the ribbon interface now, but it is also a much better tool for interacting and managing SharePoint 2010.  Recently, I was using SPD 2010 for authoring some Page Layouts and editing some other supporting pages in SharePoint and I came across a couple of differences between the 2010 and 2007 versions.  More specifically:

  • SPD 2010 tries to protect you from doing dumb things
  • SPD 2010 tries to guess what you’re thinking (with mixed results)

 

SPD 2010 tries to protect you from doing dumb things

Consider the following scenario: You want to edit a page layout that has already been customized by a coworker of yours.  In SPD 2010, this is relatively straight forward.  I click on the ‘Page Layouts’ link on the left-hand toolbox, and then double click on the page layout I’d like to edit.  This takes me to that layout’s “dashboard”, which displays information about the file itself (i.e. permissions, versions, etc.).  Now, if a user were to click on the ‘Edit File’ link, they open the Page Layout in ‘standard editing mode’.  This mode is designed to prevent users from making changes to pages that could cause SharePoint to error out at render time.  It accomplishes this by marking parts of the file as ‘read-only’, indicated by yellow shading.  However, if I want to make any major change, I would need to close out from the standard editing experience, return to the file’s dashboard page, and then navigate to the ribbon and select the Edit File –>Edit File in Advanced Mode.  This would open a fully editable page in SPD 2010. 

Reader Beware: You can easily break things in the Advanced Editor; if you’re not sure if you should be using the Advanced Editor, chances are you shouldn’t.  :-)

image

image

 

So now that I have a file all opened up in my Advanced Editor, I’d like to move a web part that was previously stored in a Web Part Zone and make it so that it’s a part of the page layout (effectively, not within a web part zone).  The advantage of this approach is that I can ensure my content authors can’t edit/delete the web part, so the web part will always display.  However, if I ever need to edit/delete the web part, I’ll have to do so in the page layout (which will change all page layouts based on it) or I’d have to detach a page from it’s layout and delete the code.  Regardless, this scenario bring me to my next point:

SPD 2010 tries to guess what you’re thinking (with mixed results)

Consider this scenario.  I’ve opened up the page layout my coworker started in the Advanced Editor, and I now want to add another web part below the existing web part which is outside of any web part zone.  So I click my cursor in just after the closing tags for the first we web part; navigate to the ‘Insert’ menu, Web Part, and select your web part.  Now, the problem is illustrated below with the before and after shots. As you can see, by inserting a web part outside of a zone, I have (effectively) deleted the existing web part, which is certainly not what I want.  To get around this, you simply need to insert your web part in another area of the document (anywhere will do, just make sure if doesn’t overwrite existing code…This is why I paste in large whitespace areas); then cut the generated code, and paste it right below your existing web part.  You’ll happily notice that SharePoint will now allow both web parts to exist outside of a web part zone!

Before:

 image

After:

 image

 

Stuff-Before:

image

Stuff-After:

image

 

Bonus Tip: If you’re ever in Split View of SPD, and your cursor is in the code view window, and you’re trying to insert a SharePoint Web Part, but the menu item grayed out; here the fix.  Click into the Design (preview) view below your code view, click back to code view, and you’ll see that you can once again insert web parts.