Thursday, September 30, 2010

Quick Switch to Edit Mode in SPS 2010

Problem: No easy way to switch to Edit Mode to add a web part.  Current Steps of going to Site Actions and Selecting Edit Page to get to edit mode where you can then click 'Add a Web Part' is not intuitive.

Solution: We can at least make it easier to switch to edit mode by throwing a button on the page only visible to Site Owners.  There is a standard JavaScript function (ChangeLayoutMode()) which can be associated to button.


Achieved this result via a minimal code method as follows:

  • Using SharePoint JavaScript functions to make this work (you can discover other JavaScript functions available by viewing source on the SharePoint page).
  • Added below source HTML with minimal styling to file called editModeWP.txt and uploaded file to a document library on my SharePoint site. 
  • HTML source:

<style type=text/css>
input.xyzBlue {background-color: #51b5e0; font-weight: bold; font-size: 12px; color: white;}
<input class="xyzBlue" type=BUTTON value="Switch to Edit Mode" name="wpMode" onClick="window.location = 'javascript:ChangeLayoutMode(false);';">

  • Added "Content Editor" web part to home page and set it's "Content Link" to the location of the txt file saved above.  Set "Chrome Type" to none.  Set "Target Audience" to "Owners" (owners should be the only ones that see this on page, if all users see it, it will be useless to them when they click because they don't have correct permissions to edit).


  • I approached this using minimal development path, however, if this is something you want consistent throughout you environments, it will require adding the updated code to many of your page layouts.  You could also add logic to this current method switch the button name and onclick event to the JavaScript which stops editing the page.

No comments:

Post a Comment