Content
Content is a term used to describe different types of data within a CMS. By default, content is not used anywhere in Ucommerce. By using the definition system, it can be added to any definition-driven entity, by giving it a field with the Content or ContentPickerMultiSelect data types.
To make use of content within Ucommerce, you will need to implement your content service based on the IContentService
interface.
Prerequisites
Before implementing your custom content service, ensure the following:
External Data Source: You need access and necessary permissions to fetch and format data from an external source and into Ucommerce. If you are using a CMS, it will most likely have some form of content management API that requires authentication.
IContentService
When you implement IContentService
, you will be faced with four distinct methods for retrieving and managing content.
GetContent
Method
GetContent
MethodThis method has two variants: one that accepts a single content ID and another that accepts a list of IDs. Both should retrieve the content associated with the specified ID(s), whether individual or multiple.
GetChildren
Method
GetChildren
MethodThis method should retrieve all content items that have the specified content ID as their parent.
Additionally, if the ID given is null, this method should return the root level content (the content with no parent).
DownloadContent
Method
DownloadContent
MethodThis method should return a complete HTML file for the specified content input. By default, it is used in a single location: the DefaultSendConfirmationEmailPipelineTask
, where it populates an email with HTML content. So if there is no need for this functionality, ignore this method and consider removing/altering that task.
All methods should fetch and filter data based on the configured external data source.
The DefaultContentService
implementation built into Ucommerce already implements the DownloadContent
method in a meaningful way. By inheriting from DefaultContentService
instead of IContentService
you can skip implementing DownloadContent
and focus on overriding the other methods that the DefaultContentService
does not implement in a meaningful way (it always returns a content object representing Not found).
Last updated