Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
In your model, you have:
[UIHint("CustomProperty3")]
public virtual string CustomProperty3 { get; set; }
Should this be "CustomProperty3" as UIHint instead of "CutomProperty" from EditorDescriptor?
This is what it looks like:
<?xml version="1.0" encoding="utf-8"?>
<module>
<assemblies>
<!-- This adds the Alloy template assembly to the "default module" -->
<add assembly="TemplateTest" />
</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>
</module>
I'm trying to implement a custom property, much like this one: https://gregwiechec.com/2016/05/textarea-with-statistics/
Template file DojoProperty2.html:
Looks like this if I open the file in the browser:
But in the CMS I only get this:
DojoProperty.js:
define([ "dojo/_base/declare", "dijit/_Widget", "dijit/_TemplatedMixin", 'dojo/text!./DojoProperty2.html', ], function ( declare, _Widget, _TemplatedMixin, template ) { return declare("jondjones.CustomProperty.DojoProperty", [ _Widget, _TemplatedMixin], { templateString: template } ); } );
DojoPropertyEditorDescriptor.cs:
using EPiServer.Shell.ObjectEditing.EditorDescriptors; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace TemplateTest.Business.EditorDescriptors { [EditorDescriptorRegistration( TargetType = typeof(String), UIHint = "CustomProperty")] public class DojoPropertyDescriptor : EditorDescriptor { public DojoPropertyDescriptor() { ClientEditingClass = "alloy/editors/DojoProperty"; } } }
TeaserBlock.cs: (where the property is being used)
using System.ComponentModel.DataAnnotations; using EPiServer.Core; using EPiServer.DataAbstraction; using EPiServer.DataAnnotations; using EPiServer.Web; namespace TemplateTest.Models.Blocks { ///
/// Used to provide a stylized entry point to a page on the site
///
[SiteContentType(GUID = "EB67A99A-E239-41B8-9C59-20EAA5936047")] // BEST PRACTICE TIP: Always assign a GUID explicitly when creating a new block type
[SiteImageUrl] // Use site's default thumbnail
public class TeaserBlock : SiteBlockData
{
[Display(
Name = "Custom Property3",
Description = "Custom Property Desc3",
GroupName = SystemTabNames.Content,
Order = 1)]
[UIHint("CustomProperty3")]
public virtual string CustomProperty3 { get; set; }
[CultureSpecific]
[Required(AllowEmptyStrings = false)]
[Display(
GroupName = SystemTabNames.Content,
Order = 1)]
public virtual string Heading { get; set; }
[CultureSpecific]
[Required(AllowEmptyStrings = false)]
[Display(
GroupName = SystemTabNames.Content,
Order = 2)]
[UIHint(UIHint.Textarea)]
public virtual string Text { get; set; }
[CultureSpecific]
[Required(AllowEmptyStrings = false)]
[UIHint(UIHint.Image)]
[Display(
GroupName = SystemTabNames.Content,
Order = 3)]
public virtual ContentReference Image { get; set; }
[Display(
GroupName = SystemTabNames.Content,
Order = 4)]
public virtual PageReference Link { get; set; }
}
}
TeaserBlock.cshtml:
What am I doing wrong?
Version: 11.10.1.0