Working With Custom Hooks: OnBeforeCheckOut and OnAfterCheckOut
Version: CMS 10
July 18, 2022
Last updated: 7/15/2022
Checking out a Site Tree content item enables a user to take possession of the content item and edit it. There can only be one working copy of an item at any given time. Checked out copies of items cannot go live, their content must be checked in and marked for publish before they can be published to a live site.
Users can trigger this action manually using the following methods:
- Clicking the Check Out button in the toolbar above the edit form
- Using the right-click context menu in the Site Tree and selecting Check Out
- Using the right-click context menu in reports results and selecting Check Out
- Advancing a content item in a workflow that includes a check-out action
- performing a sync in Schema Designer on a content item and not selecting the option to “Sync pages without checking out”
As with other hooks, this action is about the workflow of your site. Checking out is less impactful than checking in, since it makes a version that can’t go live on its own without the chance for you to cross-check it. You will still need to make sure to account for any settings you have that might prevent the user from checking out.
Check Out Associated Components
To assist users in working on a collection of content all at once, you could have the system check out all associated components when a page containing them is checked out.
In this example, we’ll extend this custom hook to find all of the components on the page we are working on and check them out when we check out the page.
To do this, we’ll need to get a list of all the components on the page, make sure they are not already checked out, and then check them out.
IEnumerable<IElement> pageComponents = page.AllElements().Where(e => e.Type == EnumElementType.IGX_COMPONENT);
var pubTargets = session.PublishingManager.Targets(out outVar);
if (pubTargets.Any() && pageComponents.Any())
foreach (var comp in pageComponents)
var componentItem = (comp.Value != "") ? session.Site.Page(comp.Value) : null;
if (componentItem != null && !componentItem.CheckedOut)
Since checking out a content item also assigns it to the user who checked it out, making it immediately available to edit, you might consider extending this further by assigning any associated components that are already checked out to the user as well. This will enable them to automatically take ownership of the page they’ve checked out along with all associated components, whether they’re checked in or checked out at the time of the user taking possession of the page.
To enhance this hook further, you could set it to trigger only for certain schema scenarios, when it would be most likely that a user would need to work on all components. For example, maybe the components on your home page schema are all meant to be edited by specific people or groups so you wouldn’t want to auto-assign them in bulk to a user who checks out that page. In this scenario, you could exclude the home page schema from this custom hook.