Programmactially Editing a Sitecore Item and Expanding Setting Standard Values
With the CRUD functions as entry points for the Modal it is a matter of retrieving fields for the item and then mapping them into our Models.
Determining if the Field is a Standard Field was simple by using the Sitecore.Configuration.Settings class to retrieve the DefaultBaseTemplate and calling ContainsField. The class is incredibly useful, if like me, you wish to avoid having hardcoded Ids and Paths in the solution.
One minor ‘gotcha‘ is remembering to call Item.Fields.ReadAll to request all fields for the Item as the standard GetItem call only returns a subset for efficiency reasons. Due to time constraints we had to push the functionality of toggling Standard Fields from view to post-Hackathon build.
The update function follows the standard architecture for updating Sitecore Items programmatically. It is abstract so can be used for both the Item in context or the items that are based on the Template Item in context.
I do recommend avoid using SecurityDisabler and replacing with UserSwitcher so that the account being used can be locked down to only update items it has permission to. Before we timed-out Mike implemented MasterVariablesReplacer to compute any Tokens in the Standard Values and replacing with the correct value.
Although we didn’t have time to implement every idea we wanted in the 24 hours, we have a long list of future features we are going to implement. Such as Item Search, displaying and selecting/deselecting referring Items, Improving the UI with the Rules Engine etc.We’ll be looking to put the Module on the Marketplace when we’ve decided what will be in version 1.0.
And that’s it!
Writing about the Hackathon has really solidified just how much we set out and achieved in such a short time. For me, taking part in the Sitecore Hackathon was very much a resurgence in developing and being creative. It’s easy to let your day job as a developer, working to someone else’s requirements, constraints and ideas, take away from your enjoyment of the craft. But now I feel that drive to contribute to the Sitecore community through creating Modules to benefit other members, writing blogs about experiences or technical approaches that have worked well. Personally, it has reawakened that sense of achievement and excitement when completing something that you conceptualised and made real.