0 Comments

Umbraco allows you to write a custom converter for the datatype, so as to you can use strong type object. For example the standard Umbraco Core "Content Picker" stores a nodeId as String type. However if you implement a converter it could return a IPublishedContent object.

 

What is Property Value Converter

A property value converter converts a property editor database stored value to a strong type. The converted value can be accessed from MVC Razor or any other Pulished Content API, defined by Umbraco.

How to create a custom property converter

Here is an example to convert RelatedLink value into a IList<RelatedLink> object.

RelatedLink object looks like this

image

 

Implement custom converter RelatedLinksPropertyConverter by inheriting from PropertyValueConverterBase, and IPropertyValueConverterMeta. The custom converter looks like this

image

NOTE: the custom converter need to follow name convention  [DateType]PropertyConverter

References

https://our.umbraco.org/documentation/extending/property-editors/value-converters

0 Comments

Some personal thoughts about CMS =P (Please don't get me wrong)


There is always some arguments around what's best CMS system, Umbraco or Sitecore? It's bit unfaired to pick the best just based on comparing the upfront prince by ignoring the facts that Sitecore has more advanced features =P.

It is not denying that both of CMS are pretty good and they are existing to fit different needs. Sitecore is more suitable for Enterprise organization, whereas Umbraco is mainly for small business. As Sitecore provides more advanced features.


Presonlization (Dynamic content)

Sitecore comes with DMS (digital marketing system) which has various personlisation options built in. the rules-base segmentation is excellent, the dynamic persona generation is awesome, although Umbraco can achieve basic personlisation with 3rd party tool Spindoctor.




ECM (Email Campaign management)

ECM(email campaign management) has been fully implement in Sitecore as well. It allows user to share the content on the website in ECM which means less work for the Campaign manager. it also has the ability to perform A/B/N testing for message body. The most advanced feature for ECM is that it provide reporting dashbord which enable marketers to create and manage optimal email marketing campaigns.


Predictive Analytics by Machine learning (Forecasting)

This bringing together of the power of machine thinking combined with human context, to better understand customer behaviour and predict future trends. Using the Microsoft AzureML platform (a cloud-based service for predictive analytics), advanced business users can begin to mine the masses of data they have stored about their customers in the Sitecore Experience Database (xDB) and experiment with hypothesis against those big data sets using the power of cloud computing.


Now imagine that in the commercial world where you have millions of customer interactions that you simply can’t track or do anything with. This could be an answer; simply create the models, let the cloud do its thing and then monitor, action and test any predictions or trends that it suggests.


Workflow & version

Sitecore workflow enable the capability for use to approve the content before it goes to production. Empowered by versioning feature. content editor can create a new version of the content and publish the new version to production later on. By doing this, content editor can easily compare with the previous version and easily roll back with previous version.


Scalable

Sitecore has content database and website database separated which make it by nature easily to scale up. whereas umbraco has only one database, when handling large amount of data, it becomes a question in terms of the stability and performance

Please don't get me wrong, not saying Umbraco is not good. I like umbraco as well, as it's easy to implement. No doubt they are both great CMS and has their own values to the client. =)

0 Comments
Ditto is a great model mapper for Umbraco. It automatically map the properties to the object class properties which allows user to use strong-type object in the code. The idea behind the model mapper is to use reflection and custom attributes to map object for simple type properties (i.e. string, int etc). If you are not familiar with custom attributes, you can read a great article here. For a complex type (i.e. JObject), You can create a custom type converter to map the properties. However, the issue I was having is when converting the JObject into the class which has the custom type converter .

Issue:


I have a class with custom type converter LinkPickerTypeConverter

[TypeConverter(typeof(LinkPickerTypeConverter))]
public class LinkPicker
{
/// <summary>
/// Gets or sets the id.
/// </summary>
public int Id { get; set; }

/// <summary>
/// Gets or sets the name.
/// </summary>
public string Name { get; set; }

/// <summary>
/// Gets or sets the url.
/// </summary>
public string Url { get; set; }

/// <summary>
/// Gets or sets the target.
/// </summary>
public string Target { get; set; }
}

In LinkPickerTypeConverter,I need to covert JObject to Link Picker. So I used the ToObject method to convert. i.e. json.ToObject<LinkPicker>();

However, because NewtonJson is using Type converter which is overwritten by my custom type converter, which causing the failing when covert JObject to the class.

Solution:


For walk around the issue, I just change ToObject method with Deserialize of JavaScriptSerializer.

var serializer = new JavaScriptSerializer();

serializer.Deserialize<LinkPicker>(value.ToString());

I figured out another better solution by dynamically assigning the JsonConverter.

TypeDescriptor.AddAttributes(typeof(LinkPicker), new TypeConverterAttribute(typeof(JsonConverter)));

After this, you can use ToObject method to convert the JObject to the custom class. i.e. value.ToObject<LinkPicker>();

0 Comments
Today, I spent a few hours on researching about how to implement custom index field with Examine in Umbraco7. There are plenty of resources talking about IndexUserField, IndexAttributeField but none of them is actually using custom field.

So I looked into the Umbraco API, and worked it out. If you knew Examine, you can ignore this part, and jump to the solution straightaway. Otherwise, I want to give you a little intro to what is Examine.

What is Examine?

Examine wraps the Lucene.Net API, which makes it easy for Umbraco developers to build index and search data [1]. Lucene open source search engine enable us to build a search driven and a high performance website.

What is custom index field?

Custom index field, also called "computed filed", is normally not existing in your database, but frequently used in program.

How to implement?


There might be other ways to implement "custom index field", but here I am going to introduce "UmbracoContentIndexer". UmbracoContentIndexer is an indexer for creating index document by getting data from Umbraco nodes. All you need to do is to add "custom index field" by overriding "GetDataToIndex" method.

Reference
[1] http://umbraco.com/follow-us/blog-archive/2011/9/16/examining-examine