Packaging a custom datatype: resources, jquery & css
Hi all,
I am working on a custom data type which I would like to distribute in a package (hopefully pretty soon).
Before submitting the package I would like to get some insights concerning best practices in packaging up a data type. I know many of you have done this before so I'd love to hear your opinions!
1) I found it easier to create the editor control using the IUserControlDataEditor interface (UserControlWrapper) instead of inheriting from BaseDataType (uComponents approach). I'm just wondering if this approach is fine when working with packages? Are there any con's I should be aware off?
2) The editor control contains some initial resource files (.resx) for a few languages. Where would be the best place to store these files?
3) Client dependencies: I noticed that uComponents uses the ClientDependencyFramework and add client dependencies through embedded web resources. I can't seem to get this working within a regular user control, should I be able to get this working or do I need to take a different approach. What if I want to use an alternative version or plugin of Jquery/JqueryUI than the onces distributed with Umbraco, and is it even possible to do so?
1. I don't see any issues in IUserControlDataEditor in a package. My only consideration would be the versions of Umbraco that you want to support . The User control wrapper has undergone a bit of an overhaul through the last few versions.
2. Can't you you just embed your resources in your assembly?
3. I don't see why you can't use client dependency - perhaps offer a bit more of an explanation as to why it isn't working for you. Having said - I always see Clientdependency as a "Nice to have" not essential.
I have used the XML SerializationHelper which was added to Umbraco in version 4.6 (Juno) so I guess the data type will only support version 4.6 and up, which does not necessarely have to be a bad thing. To ease the AJAX implementation the editor control uses an UpdatePanel so I'm glad I can just stick to using the IUserControlDataEditor tbh ;-)
As for resources, I have considered embedding them into the assembly, but this would not allow consumers to update the provided resources nor to add additional resources for non-supported languages (unless they create a new build of course). Perhaps there is a way to provide an editor of some kind?
I started by creating the data type outside of Umbraco, and it requires Jquery 1.5.1 and JqueryUI 1.8.3 (which has autocomplete support) and for styling it uses the JqueryUI 1.8.3 Lightness CSS. I noticed that the Umbraco backend already comes with Jquery and JqueryUI files - albeit different versions - and recently also autocomplete.js (which does not reside in the UI folder?). My main concern of course is not having the data type conflict with any other data types, and I would like to use the resources provided by Umbraco as often as possible so I would think the ClientDependencyFramework is the only way to make this work?
But before I get into too much detail, I do think I should have another look at the ClientDependency and try to fully understand the mechanism.
Next, I wanted to add the dependencies to the editor control using the ClientDependencyFramework. I first got this working outside of Umbraco using ClientDependencyAttributes but they failed when I deployed to Umbraco (I think it was because of the path references which did not seem to get resolved properly in Umbraco). As an alternative I just c/p the extension methods used in uComponents, and added the dependencies in the Control_OnInit():
So far so good, the editor control now works fine in Umbraco 4.7, although I am still not sure whether this is a good approach:
1) I've just referenced Jquery 1.5.1, chances are big it will break other references to Jquery. I don't actually need 1.5.1, the Jquery provided with Umbraco should also work.
2) I actually need JqueryUI 1.8.11 because it has an update for autocomplete. What about other editor controls that reference a lower version?
Packaging a custom datatype: resources, jquery & css
Hi all,
I am working on a custom data type which I would like to distribute in a package (hopefully pretty soon).
Before submitting the package I would like to get some insights concerning best practices in packaging up a data type. I know many of you have done this before so I'd love to hear your opinions!
1) I found it easier to create the editor control using the IUserControlDataEditor interface (UserControlWrapper) instead of inheriting from BaseDataType (uComponents approach). I'm just wondering if this approach is fine when working with packages? Are there any con's I should be aware off?
2) The editor control contains some initial resource files (.resx) for a few languages. Where would be the best place to store these files?
3) Client dependencies: I noticed that uComponents uses the ClientDependencyFramework and add client dependencies through embedded web resources. I can't seem to get this working within a regular user control, should I be able to get this working or do I need to take a different approach. What if I want to use an alternative version or plugin of Jquery/JqueryUI than the onces distributed with Umbraco, and is it even possible to do so?
Cheers
Lennart
Hi Lennart:
1. I don't see any issues in IUserControlDataEditor in a package. My only consideration would be the versions of Umbraco that you want to support . The User control wrapper has undergone a bit of an overhaul through the last few versions.
2. Can't you you just embed your resources in your assembly?
3. I don't see why you can't use client dependency - perhaps offer a bit more of an explanation as to why it isn't working for you. Having said - I always see Clientdependency as a "Nice to have" not essential.
Hi Darren,
Thanks for your reply.
I have used the XML SerializationHelper which was added to Umbraco in version 4.6 (Juno) so I guess the data type will only support version 4.6 and up, which does not necessarely have to be a bad thing. To ease the AJAX implementation the editor control uses an UpdatePanel so I'm glad I can just stick to using the IUserControlDataEditor tbh ;-)
As for resources, I have considered embedding them into the assembly, but this would not allow consumers to update the provided resources nor to add additional resources for non-supported languages (unless they create a new build of course). Perhaps there is a way to provide an editor of some kind?
I started by creating the data type outside of Umbraco, and it requires Jquery 1.5.1 and JqueryUI 1.8.3 (which has autocomplete support) and for styling it uses the JqueryUI 1.8.3 Lightness CSS. I noticed that the Umbraco backend already comes with Jquery and JqueryUI files - albeit different versions - and recently also autocomplete.js (which does not reside in the UI folder?). My main concern of course is not having the data type conflict with any other data types, and I would like to use the resources provided by Umbraco as often as possible so I would think the ClientDependencyFramework is the only way to make this work?
But before I get into too much detail, I do think I should have another look at the ClientDependency and try to fully understand the mechanism.
Meanwhile, any advice is still appreciated ;-)
Cheers!
Here's a short follow up regarding the client dependencies.
First I've added the web resources, like this:
Next, I wanted to add the dependencies to the editor control using the ClientDependencyFramework. I first got this working outside of Umbraco using ClientDependencyAttributes but they failed when I deployed to Umbraco (I think it was because of the path references which did not seem to get resolved properly in Umbraco). As an alternative I just c/p the extension methods used in uComponents, and added the dependencies in the Control_OnInit():
So far so good, the editor control now works fine in Umbraco 4.7, although I am still not sure whether this is a good approach:
1) I've just referenced Jquery 1.5.1, chances are big it will break other references to Jquery. I don't actually need 1.5.1, the Jquery provided with Umbraco should also work.
2) I actually need JqueryUI 1.8.11 because it has an update for autocomplete. What about other editor controls that reference a lower version?
Love to hear your thoughts on this.
Lennart
is working on a reply...