tags:

views:

24

answers:

2

Given a the URL of a sharepoint page (eg: http://localhost/Pages/somepage.aspx), how can I visit that page and automatically go into authoring mode? I'm hoping there's a way by seting a query string variable (eg: http://localhost/pages/somepage.aspx?mode=authoring).

I'm okay with modifying the code-behind of the page if necessary.

A: 

http://localhost/pages/somepage.aspx?ToolPaneView=2

Kit Menke
This doesn't switch the page to authoring mode. thanks!
burnt1ce
I guess you're talking about Publishing pages then. :) I'm not sure what you mean by "authoring mode".
Kit Menke
A: 

I don't think you can do it based on a URL. The Edit Page menu command for both Publishing and non-publishing pages relies on a post back.

Publishing page:

if (document.forms['aspnetForm']['MSOLayout_InDesignMode'] != null) document.forms['aspnetForm']['MSOLayout_InDesignMode'].value = 1;
if (document.forms['aspnetForm']['MSOAuthoringConsole_FormContext'] != null) document.forms['aspnetForm']['MSOAuthoringConsole_FormContext'].value = 1;
if (document.forms['aspnetForm']['MSOSPWebPartManager_DisplayModeName'] != null) document.forms['aspnetForm']['MSOSPWebPartManager_DisplayModeName'].value = 'Design';
__doPostBack('ctl00$PlaceHolderTopNavBar$SiteActionsMenuMain$ctl00$wsaEditPage_CmsActionControl','switchToAuthoring')

non-publishing page:

window.location = 'javascript:MSOLayout_ChangeLayoutMode(false);';

For IE, MSOLayout_ChangeLayoutMode is in ie55up.js:

function MSOLayout_ChangeLayoutMode(bPersonalView, bExitDesignMode)
{
    if(bPersonalView !=null)
    {
                MSOLayout_SaveChanges();
        var url=document.forms[MSOWebPartPageFormName].action;
        url=RemoveQueryParameterFromUrl(url, "[p|P][a|A][g|G][e|E][v|V][i|I][e|E][w|W]");
        url=RemoveQueryParameterFromUrl(url, "[tT][oO][[oO][lL][pP][aA][nN][eE][vV][iE][eE][wW]");
        url=RemoveQueryParameterFromUrl(url, "[dD][iI][sS][pP][lL][aA][yY][mM][oO][dD][eE]");
        if (url.indexOf("?") < 0)
            url+="?";
        else
            url+="&";
        if(bPersonalView==true)
        {
            document.forms[MSOWebPartPageFormName].MSOLayout_InDesignMode.value=1;
            document.forms[MSOWebPartPageFormName].MSOSPWebPartManager_DisplayModeName.value='Design';
            url+="PageView=Personal";
            document.forms[MSOWebPartPageFormName].action=url;
        }
        else
        {
            document.forms[MSOWebPartPageFormName].MSOLayout_InDesignMode.value=1;
            document.forms[MSOWebPartPageFormName].MSOSPWebPartManager_DisplayModeName.value='Design';
            url+="PageView=Shared";
            document.forms[MSOWebPartPageFormName].action=url;
        }
    } else if (bExitDesignMode !=null && bExitDesignMode)
    {
        var url=document.forms[MSOWebPartPageFormName].action;
        url=RemoveQueryParameterFromUrl(url, "[tT][oO][[oO][lL][pP][aA][nN][eE][vV][iE][eE][wW]");
        url=RemoveQueryParameterFromUrl(url, "[dD][iI][sS][pP][lL][aA][yY][mM][oO][dD][eE]");
        document.forms[MSOWebPartPageFormName].MSOWebPartPage_Shared.value="";
        document.forms[MSOWebPartPageFormName].MSOLayout_InDesignMode.value=0;
        document.forms[MSOWebPartPageFormName].MSOSPWebPartManager_DisplayModeName.value='Browse';
        document.forms[MSOWebPartPageFormName].action=url;
    }
    __doPostBack(MSOWebPartPageFormName, '');
}
Rich Bennema