Content Hub Tip #7: Creating custom settings

 

Content Hub Tips


As with all programming, it's a pain to maintain configuration with the code itself. If you need a change, the code needs to be recompiled again. The same goes for scripting within the Content Hub. Wouldn't it be cool if you had a place for configuration settings in the Content Hub? Well, Sitecore has already got your back.

On the Manage page of the Content Hub, you can find the Settings section. This will lead you to the default configuration settings of the Content Hub. The cool thing about this, you can add your own settings. When you click on the + Setting button. You can create your setting.

Add new setting

As with all things, naming them is the most difficult. Please think a bit ahead of what kind of settings you actually need and where you're going to use them. For the Name of the Setting, I like to prefix it with a C. so that everyone knows it's a custom setting. The Label will just be the name of the setting without prefixes and with spaces to make it human-readable. Last, but not least, we need to select a category. If the required category isn't already there, we have the ability to create a new one. I suggest limiting the number of new categories that are created. This will not help with maintaining the application throughout its lifecycle. When we are all set up, we can Save the setting.

The only left to do is add the JSON model to the Setting. Here we can make it as complex as we want. You could put all settings into one large JSON model, but let us not do that. Our fellow developers will not thank us now, but when we clutter up the setting, you will definitely hear about it ;).

In the next tip, I will write how you can extract the JSON model from a script.

Happy codin'!