Optimizely CMS Common Interfaces

Optimizely CMS Common Interfaces

In this blog post we are going to explain a little bit which ones are some of the common interfaces used in the Optimizely/Episerver CMS and how these interfaces can be used. So without further due lets begin.

IContentLoader

This interface allows the developer to access any content in the CMS. It is recommended to use when you want to get read only content items. It uses the cache layer implemented by the CMS improving performance when requesting items.

MethodDescription
Get<T>Gets a T content item using a GUID or a Content Reference
GetAncestorsGets all items as IContent on top of the current Content Reference item
GetBySegmentGets an item as IContent using a parent Content Reference, the path to access it and the language
GetChildren<T>Gets all T content items that are below (1 level) from the current Content Reference item
GetDescendentsGets all items as IContent below of the current Content Reference item
GetItemsGets all items as IContent from a list of Content Reference items and a language

IContentRepository

This interface allows the developer to not just access to any content in the CMS, but also take some actions around the item like save, move, generate copies, send them to trash and more. Behind the scenes IContentRepository inherits the interface IContentLoader.

MethodDescription
CopyCopies a content item choosing a destination, it requires proper permissions to execute it
CreateLanguageBranch<T>Create a language branch for the current Content Reference item T using a culture info
DeleteLanguageBranch<T> Deletes a language branch for the current Content Reference item T using a culture info
GetLanguageBranches<T>Get all T content items for the current Content Reference item T for each language
DeleteDelete a Content Reference item, it can force the deletion if necessary
DeleteChildrenDeletes all content items that are below (1 level) from the current Content Reference item
SaveSave or publish a content item if the proper permissions are passed
MoveMoves a Content Reference item below the Content Reference item selected as destination, it requires proper permissions
MoveToWastebasketAllows to move a Content Reference item to the waste basket specifying the user
GetReferencesToContentIt gets all the references of a Content Reference item and its descendants if required
ListDelayedPublishGet all IContent items which have been set to delay publish
GetDefault<T>Gets a new instance of a T content item so it can be added as part of the CMS

ILanguageBranchRepository

Used to get all the relevant information about languages in the CMS including which ones are active and it also allows to modify the language branches available in the site.

MethodDescription
ListAllGets all language branches available in the CMS including the ones which are not active
ListEnabledGets all languages branches which are available and active in the CMS
LoadFirstEnabledBranchGets the first active branch in the CMS in the order defined in the languages interface
DeleteDeletes a language branch based on the id
SaveSaves the modifications of a language branch passed as parameter
LoadIt loads a language branch chosen by the culture info send as parameter

ISiteDefinitionRepository

This interface is used to get and modify the sites which are active in the CMS.

MethodDescription
ListList of all site definitions available in the site
DeleteDeletes a site based on its GUID
SaveSaves the modifications of a site definition passed as parameter
GetIt loads a site definition chosen by its GUID send as parameter

These are some of the most common used interfaces for developers trying to implement solutions in the Optimizely/Episerver CMS. If you have any question let me know. I hope it will help someone and as always keep learning !!!

Written by:

Jorge Cardenas

Developer with several years of experience who is passionate about technology and how to solve problems through it.

View All Posts

Leave a Reply