Track when user clicks on Lock & Edit item

It can be a case when you need to perform some action right after user has clicked 'Edit' button. To do that you need firstly patch "item:saved" event by adding your own custom handler: Secondly, implement ItemEventHandler class and OnItemSaved method: Several words about how and why it works: when user clicks 'Edit' button Sitecore … Continue reading Track when user clicks on Lock & Edit item

Sitecore + TDD: assertions

All we know Assert static class from Sitecore.Diagnostics namespace and its methods which help us to be sure that methods get proper parameters. E.g. if you explore Sitecore.Kernel and in particular code of pipelines you see something like that: In the example below, I'll show how we can test assertion using FluentAssertions. Tests:

Sitecore + TDD: test protected method

The current blog post is a continuation of blogs series about TDD. This one is about the testing of protected methods. E.g. if you implement custom field type you have to create a class which inherited from Sitecore.Web.UI.HtmlControls.Control one and also implement IContentField interface. The appearance of your custom type field in Content Editor is … Continue reading Sitecore + TDD: test protected method

Sitecore + TDD: bypassing system dependencies

Maybe be a case when your code dependents on system dependencies. E.g. your code can use DateTime.Now. The main idea of bypassing of such dependency is creating abstraction around last one. In the example below I wrap DateTime.Now in the protected virtual method: On the one hand it gives us the ability to override this … Continue reading Sitecore + TDD: bypassing system dependencies

Dynamic Insert Options

This post provides solution which gives ability to choose a folder and display the children under that folder as insert options. Create template, in my case, it is 'Dynamic Insert Option' one, which contains 'Starting Path' droptree field, set source to '{3C1715FE-6A13-4FCF-845F-DE308BA9741D}' (id of '/sitecore/templates' item). Then add 'Dynamic Insert Option' template to list of … Continue reading Dynamic Insert Options