Templates
Templates help change the structure and appearance of your project without altering its source code. Components can be initially described in your project's code and marked with templates created in OneEntry Headless CMS. They can differ in design solutions, behavior, etc. By switching templates, you can influence the operation of your entities, whether it's a page, block, form, etc.
Kotlin Multiplatform
Getting all templates
val types = TemplatesService.templates()
val templates = types.flatMap { it.value }
Getting all templates of a specific type
val templates = TemplatesService.templates(TemplateType.FOR_CATALOG_PRODUCTS)
Getting a template
By identifier
val template = TemplatesService.template(id = 10)
By marker
val template = TemplatesService.template(marker = "horizontal_card")
Swift
To simplify, the singleton service is extracted into a separate variable
let service = TemplatesService.shared
Getting all templates
let types = try await service.templates(langCode: "en_US")
let templates = types.flatMap { $0.value }
Getting all templates of a specific type
let templates = try await service.templates(
type: .forCatalogProducts,
langCode: "en_US"
)
Getting a template
By identifier
let template = try await service.template(
id: 10,
langCode: "en_US"
)
By marker
let template = try await service.template(
marker: "horizontal_card",
langCode: "en_US"
)
Last modified: 18 February 2025