-
-
Save jonihietala/237b0d6ab53bbeef1a66e9f6a24b16cb to your computer and use it in GitHub Desktop.
Adding a "View on website" -button to context menu in navigation tree in Episerver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
"dojo", | |
"dojo/_base/declare", | |
"epi-cms/plugin-area/navigation-tree", | |
// Parent class | |
"epi/_Module", | |
// Commands | |
"alloy/ViewOnWebsite/ViewOnWebsite" | |
], function ( | |
// Dojo | |
dojo, | |
declare, | |
navigationTreePluginArea, | |
// Parent class | |
module, | |
// Commands | |
viewOnWebsite | |
) { | |
return declare([module], { | |
initialize: function () { | |
this.inherited(arguments); | |
navigationTreePluginArea.add(viewOnWebsite); | |
} | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<module> | |
<assemblies> | |
<!-- This adds the Alloy template assembly to the "default module" --> | |
<add assembly="AlloyDemoKit" /> | |
</assemblies> | |
<clientResources> | |
<add name="epi-cms.widgets.base" path="Styles/Styles.css" resourceType="Style"/> | |
</clientResources> | |
<dojo> | |
<!-- Add a mapping from alloy to ~/ClientResources/Scripts to the dojo loader configuration --> | |
<paths> | |
<add name="alloy" path="Scripts" /> | |
</paths> | |
</dojo> | |
<clientModule initializer="alloy.Initializer"> | |
<moduleDependencies> | |
<add dependency="CMS" type="RunAfter" /> | |
</moduleDependencies> | |
</clientModule> | |
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
"dojo/topic", | |
"dojo/_base/declare", | |
"epi/dependency", | |
"epi/shell/command/_Command" | |
], function (topic, declare, dependency, command) { | |
return declare([command], { | |
label: "View on Website", | |
iconClass: "epi-iconNewWindow", | |
constructor: function () { | |
var registry = dependency.resolve("epi.storeregistry"); | |
this.store = registry.get("epi.cms.contentdata"); | |
}, | |
_execute: function () { | |
if (this.model != null && this.model.publicUrl != null) { | |
var publicUrl = location.protocol + "//" + location.host + this.model.publicUrl; | |
window.open(publicUrl, "_blank"); | |
} | |
}, | |
_onModelChange: function () { | |
this.set("canExecute", true); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment