Ga naar hoofdinhoud

Template Management

Overview

DocuDesk provides CRUD operations for reusable Twig/HTML templates stored as OpenRegister objects. Templates are scoped per-app via a namespace field, enabling multiple Nextcloud apps to maintain their own template collections through a shared service.

API Endpoints

MethodURLDescription
GET/api/templatesList templates (supports namespace, _search, _limit, _offset)
POST/api/templatesCreate template (requires name, content, namespace)
GET/api/templates/{id}Get single template
PUT/api/templates/{id}Update template (namespace immutable)
DELETE/api/templates/{id}Delete template

Template Properties

PropertyRequiredDescription
nameYesTemplate display name
contentYesHTML/Twig template content
namespaceYesApp identifier (e.g., larpingapp, opencatalogi)
descriptionNoTemplate description
formatNoPage size: A4, A3, Letter, Legal (default: A4)
orientationNoP (portrait) or L (landscape) (default: P)

Usage via DI

Other Nextcloud apps can use the TemplateService directly:

$templateService = $container->get(\OCA\DocuDesk\Service\TemplateService::class);
$templates = $templateService->getTemplatesByNamespace('myapp');