I recently encountered an issue where my non-content blocks (site settings, categories, etc.) were producing a “For This” folder with a missing token. This missing token appeared in custom content, as well as add-ons like Geta Categories.
For custom content, two things are required to get a value into that empty token: an XML file under the lang folder and a UIDescriptor. In order to fix an add-on like Geta Categories (which already has the UIDescriptor baked-in), all that is needed is an XML file under the lang folder. This is a pretty simple XML that simply denotes the content type in question and the name you’d like to give it. Like so:
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <languages> <language name="English" id="en"> <contenttypes> <CategoryData> <name>Working Category! </name> </CategoryData> </contenttypes> </language> </languages>
Simply adding the file for Geta Categories will resolve the issue there since they’ve already included the required UIDescriptor in the package. The result will look like this:
For your own custom types, the already-mentioned UIDescriptor is also required. This is a simple bit of code to notify Optimizely what to fill in for what tokens. The XML can be expanded to include multiple types, each with their own user-defined name node.
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <languages> <language name="English" id="en"> <contenttypes> <SettingsBase> <name>Setting</name> </SettingsBase> <CategoryData> <name>Category</name> </CategoryData> </contenttypes> </language> </languages>
The UIDescriptor is a few lines of code that inherit from the generic UIDescriptor, where T is the content type we want to target. As you can see in the XML, the parent node of the name should be the content type name so that Optimizely can pair it up correctly.
[UIDescriptorRegistration] public class SettingsBlockFolderDescriptor : UIDescriptor { public SettingsBlockFolderDescriptor() { IsPrimaryType = true; } }
With both pieces in place, we’ll now see our XML-defined name appear instead of the empty token, {0}: