Hiding Content Editor Fields Depending on Selected Values

tl;dr Custom Field which hides other fields in the Content Editor depending on the selected value

A recent question on Stackoverflow asked if it was possible to hide fields in the Sitecore Content Editor when certain values are selected. This is a pretty common (and easy task) on any normal web site and it makes sense from a usability point of view to only show those fields which are relevant to the user. I gave a half answer to the question that a Composite Custom Field could be created to fire off the relevant Javascript and hide the sibling fields on change. I was unsure however how to hide the fields on document load.

Read More

Advertisements

Adding custom Javascript and Stylesheets in the Content Editor

tl;dr Add custom resources in the Sitecore Content Editor from config setting

I recently created some custom fields in which I needed to add some custom JavaScript. I looked at a couple of other implementations of custom fields but they all worked on the individual control, not at an Item level or adding snippets of Javascript by inlining it adding if from code-behind declarations. I also wanted to avoid modifying any standard Sitecore files if at all possible, which some of the other custom field implementation had done and makes installing multiple packages tricky since each would overwrite the changes of the others. Aside from which, I wanted to avoid it from an upgrade point of view. I also needed to update the UI when the content had been loaded so would need to listen for that event.

Read More