Skip to content

Instantly share code, notes, and snippets.

@gregwiechec
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregwiechec/dab7094e72f44c9d83ac to your computer and use it in GitHub Desktop.
Save gregwiechec/dab7094e72f44c9d83ac to your computer and use it in GitHub Desktop.
Content Selector with page preview
public class ExtendedContentReferenceSelctorAttribute : Attribute, IMetadataAware
{
public void OnMetadataCreated(ModelMetadata metadata)
{
((ExtendedMetadata)metadata).ClientEditingClass = "alloy.editors.extendedContentSelector";
}
}
define([
"dojo/_base/declare",
"dojo/_base/lang",
"dojo/on",
"epi-cms/widget/ContentSelector",
// resources
"epi/i18n!epi/cms/nls/episerver.shared.header"
],
function(
declare,
lang,
on,
ContentSelector,
headingResources
) {
return declare("alloy.editors.extendedContentSelector", [ContentSelector], {
contentId: null,
contentUri: null,
contentTypeName: null,
_updateDisplayNode: function (content) {
this.contentUri = content.uri;
this.contentId = content.contentLink;
this.contentTypeName = content.contentTypeName;
this.inherited(arguments);
},
_updateDisplayNodeTitle: function () {
this.inherited(arguments);
this.resourceName.title = this.resourceName.title + ", " + headingResources.id + ": " + this.contentId + " (" + headingResources.type + ": " + this.contentTypeName + ")";
},
buildRendering: function () {
this.inherited(arguments);
on(this.resourceName, "dblclick", lang.hitch(this, function () {
var contextParameters = { uri: this.contentUri };
dojo.publish("/epi/shell/context/request", [contextParameters]);
}));
}
});
});
public abstract class SitePageData : EPiServer.Core.PageData
{
[Display(GroupName = SystemTabNames.Content)]
[UIHint(UIHint.Image)]
[ExtendedContentReferenceSelctor]
public virtual ContentReference PageImage { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment