August 31, 2011
Making Sitefinity 4 Control Templates Easier
One of the great things about Sitefinity 3 was that you could add a couple of attributes to your controls and have a great design experience with little to no additional effort. The steps you have to go through to get the same thing in Sitefinity 4 are, well, insane. Take a look at this...six files for what you used to be able to do in one. There had to be a better way.
What I'm sharing today is pre-alpha, but is a large step towards bringing back attribute-based design experiences.
First, download the ZIP file with the code. It contains four files: DesignerScript.ashx, DesignerScript.ashx.cs, EmptyLayout.ascx, and GenericDesigner.cs. Drop all four files in the root of your Sitefinity 4.2 or higher project and ensure they're included in the project.
Second, add the following attribute to your UserControl's class:
If you get a red squiggly on that class, add "using Telerik.Sitefinity.Web.UI.ControlDesign;" to your using clauses.
That's it. The new system respects the Browsable and DisplayName attributes, gives you checkboxes for booleans, basic validation for integer types, and if your property is a string type with "Html" in the property name, it will spit out a text area for you instead.
Lots of work still to do as you can see from the comments in the code, but this is a step in the right direction for the product.
Subscribe to: Post Comments (Atom)
Michael was kind enough to share this code with me prior to releasing it. This is a great initiative and definitely worth a look! This is an extremely fast way to stamp out a simple UI for your custom controls.
Regarding the relative complexity of creating client-side UI for custom controls, this is something the Sitefinity team is currently investigating. The current technique takes advantage of a lot of client-side functionality. This is great because it avoids full-page postbacks, but it also requires a bit more plumbing to put into place.
Michael's code does a great job of automating that plumbing. We'll do even more with this in future Sitefinity releases.
Thanks Michael for sharing this with the community. Great work!
Telerik | Sitefinity CMS
Post a Comment