Friday, December 19, 2008

TreelistEx not registering links in LinkDatabase

Ahh nothing like being kept up till 11pm on the last day before xmas holidays... :P So here's the thing. TreelistEx is broken. You're supposed to be using this field type to "tag" content. Probably most often, you will use this to tag up categories for news articles, blog posts, meta keywords and similar stuff. And on that same note, quite obviously, you're supposed to be able to "reverse lookup" all these tags you can set. Not much point in having to loop through ALL of your 100.000 articles to find the ones that are marked "Holiday Capers" - Sitecore has a Link Database for that. If you've not worked with the Link Database before, Lars Nielsen has an excellent post about it. But here's the catch. As I said, this is broken. Nothing you store in a TreelistEx field will be registered in the LinkDatabase. "tree list", reference, droplink - sure. They all work. But not this one. A little work with Dr. Reflector eventually led me in the right direction. Now why one would need to, is an entirely different story for a different day - I believe I already had a few comments on that earlier. It comes down to TreelistEx being unknown to Sitecore itself - odd as this may sound. The field type simply doesn't exist in FieldTypes.config - and this will eventually force Sitecore to skip the field when doing it's internal RebuildItem functionality. This is, as Reflector will tell you, the method that Sitecore will recursively call when rebuilding the Link Database. Add the missing field type to /App_Config/FieldTypes.config - force a full rebuild of the Link Database - and everything now clicks into place as it should. fieldType name="TreelistEx" type="Sitecore.Data.Fields.MultilistField,Sitecore.Kernel" Thanks Sitecore. Where do I bill my lack of sleep? ;-) EDIT: 14-February-2009 This fix was released in build 090212 (also known as Service Release 1).

1 comment:

kaalen said...

Wow... great Mark... you just saved a bit of my sanity with this post. It's nice of Sitecore to release this as a fix but our team is midway into development and we started of working on a Sitecore release 090120 and we didn't have time to upgrade yet.

Regards,
Alenka Caserman