Thanks for the quick reply burningice.
OK, I am just working through the help docs. I have a simple class below with some helper methods for the selector widget for use in datatypes and razor functions, example below. I followed the guide for creating widgets but it seemed overkill for what I wanted. This approach seems to work well but if I want to create a package installer then I need to automate registering the methods.
OK, I am just working through the help docs. I have a simple class below with some helper methods for the selector widget for use in datatypes and razor functions, example below. I followed the guide for creating widgets but it seemed overkill for what I wanted. This approach seems to work well but if I want to create a package installer then I need to automate registering the methods.
-
Am I right in thinking that this would be similar to adding static data types in that I could create a startup handler that would add these methods? Are you able to point me to an example?
-
I created a samplewidgetfunctionprovider by following the help but i'd be lying if I said I fully understood it. Again are there any examples that match my needs that I can pick apart and learn from?
public class WidgetHelper
{
[Function(Description = "Returns the pre defined color options available")]
public static IEnumerable<string> GetColours()
{
//Get Directory
DirectoryInfo di = new DirectoryInfo(HttpContext.Current.Server.MapPath("/frontend/ensured/css/color_scheme"));
//Get all css files
foreach (var fi in di.GetFiles("*.css"))
{
yield return Path.GetFileNameWithoutExtension(fi.Name);
}
}
[Function(Description = "Returns classes to set letter spacing")]
public static IEnumerable<string> GetLetterSpacingClasses()
{
int i = 0;
while (i < 11)
{
yield return ".letter-spacing-" + i.ToString();
i++;
}
}