gemini6609
gemini6609

Reputation: 332

Redirect Page into Edit Mode in DNN 7

I am attempting to work around an undesirable functionality in the Ventrian News Articles module. The issue is that the module allows authenticated users to load the options to edit an article, but the rich text editor is not enabled unless the page is in edit mode. I can modify the edit link the user clicks to edit an article, so I looking for a way to set the edit link to load the article edit page in edit mode by default. Any suggestions? Thanks in advance.

Upvotes: 1

Views: 474

Answers (1)

Chris Hammond
Chris Hammond

Reputation: 8943

You are likely going to need to recreate the calls to put the user in Edit mode that happen in /resources/shared/scripts/dnn.controlBar.js

That code looks to do something along the lines of the following when clicking the Edit button

$('a#ControlBar_EditPage').click(function () {
    var service = dnn.controlBar.getService();
    var serviceUrl = dnn.controlBar.getServiceUrl(service);
    var mode = currentUserMode === 'EDIT' ? 'VIEW' : 'EDIT';
    $.ajax({
        url: serviceUrl + 'ToggleUserMode',
        type: 'POST',
        data: { UserMode: mode },
        beforeSend: service.setModuleHeaders,
        success: function () {
            if( mode === 'VIEW') dnn.dom.setCookie('StayInEditMode', 'NO', '', dnn.controlBar.getSiteRoot());
            window.location.href = window.location.href.split('#')[0];
        },
        error: function (xhr) {
            dnn.controlBar.responseError(xhr);
        }
    });
    return false;
});

How best to go about doing that? I am not sure. Possibly putting a module on the page that intercepts a querystring parameter (something like ?editMode=true). If the module sees that parameter, fire off a client side event that will do what the javascript sample does, make a post to the serviceUrl/ToggleUserMode and set the mode there.

Chris

Upvotes: 0

Related Questions