Overview
During the course of building out custom modules and extensions for a DNN instance, a developer may want the ability to call a function from the Persona Bar via an external source (i.e. clicking into the persona bar from outside of it.) The following JavaScript code snippet will allow them to do this for the Page Settings and will populate the settings automatically with those of the page a user is currently on.
Details
Because this is a JavaScript snippet, it can be placed anywhere in the custom module. Developers will want to point the function of their custom "Page Settings" button to this code, which will call EditPage() and open that section of the Persona Bar.
Script
var editPage = function(pageId) {
var personaBar = window.parent.dnn ? window.parent.dnn.PersonaBar : null;
if (personaBar) {
personaBar.openPanel('Dnn.Pages',
{
viewParams:
{
pageId,
viewTab: "details"
}
}
);
var doc = window.top.$('#personaBar-iframe').get(0).contentWindow.document;
var event = doc.createEvent("Event");
event.initEvent("viewPageSettings", true, true);
event.pageId = pageId;
event.viewTab = "details";
doc.dispatchEvent(event);
}
}
editPage(100);
Once implemented, the script can be validated by clicking on the target button within the custom module. If successful, the page settings will expand from the persona bar with the relevant page details already populated.
Comments
0 comments
Please sign in to leave a comment.