Templates API
De Templates API biedt endpoints voor het beheren van template styles in Joomla.
Base URL
/api/index.php/v1/templates
Endpoints Overzicht
Site Templates
| Methode | Endpoint | Beschrijving |
|---|---|---|
| GET | /templates/styles/site | Alle site template styles |
| GET | /templates/styles/site/{id} | Specifieke style ophalen |
| POST | /templates/styles/site | Nieuwe style aanmaken |
| PATCH | /templates/styles/site/{id} | Style bijwerken |
| DELETE | /templates/styles/site/{id} | Style verwijderen |
Administrator Templates
| Methode | Endpoint | Beschrijving |
|---|---|---|
| GET | /templates/styles/administrator | Alle admin template styles |
| GET | /templates/styles/administrator/{id} | Specifieke admin style ophalen |
| PATCH | /templates/styles/administrator/{id} | Admin style bijwerken |
Site Template Styles
Alle site styles ophalen
GET /api/index.php/v1/templates/styles/site
Response
{
"data": [
{
"type": "template-styles",
"id": "10",
"attributes": {
"template": "cassiopeia",
"title": "Cassiopeia - Standaard",
"home": "1",
"params": {
"logoFile": "",
"fluidContainer": "0",
"siteTitle": "",
"siteDescription": "",
"colorName": "colors_standard",
"useFontScheme": "0"
}
}
}
]
}
Specifieke style ophalen
GET /api/index.php/v1/templates/styles/site/{id}
Voorbeeld
curl -X GET "https://jouwesite.nl/api/index.php/v1/templates/styles/site/10" \
-H "X-Joomla-Token: JOUW_API_TOKEN"
Template style aanmaken
POST /api/index.php/v1/templates/styles/site
Request Body
{
"template": "cassiopeia",
"title": "Cassiopeia - Aangepast",
"home": "0",
"params": {
"logoFile": "images/logo.png",
"fluidContainer": "1",
"colorName": "colors_alternative"
}
}
Verplichte velden
| Veld | Type | Beschrijving |
|---|---|---|
| template | string | Template naam (map naam) |
| title | string | Titel van de style |
Optionele velden
| Veld | Type | Standaard | Beschrijving |
|---|---|---|---|
| home | string | "0" | Standaard template ("1" = ja) |
| params | object | Template specifieke parameters |
Voorbeeld
curl -X POST "https://jouwesite.nl/api/index.php/v1/templates/styles/site" \
-H "X-Joomla-Token: JOUW_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"template": "cassiopeia",
"title": "Mijn Aangepaste Style",
"params": {
"logoFile": "images/custom-logo.png",
"fluidContainer": "1"
}
}'
Template style bijwerken
PATCH /api/index.php/v1/templates/styles/site/{id}
Request Body
{
"title": "Nieuwe Titel",
"params": {
"colorName": "colors_standard"
}
}
Voorbeeld
curl -X PATCH "https://jouwesite.nl/api/index.php/v1/templates/styles/site/10" \
-H "X-Joomla-Token: JOUW_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "Cassiopeia - Bijgewerkt"
}'
Template style verwijderen
DELETE /api/index.php/v1/templates/styles/site/{id}
Let op
Je kunt de standaard template style niet verwijderen. Stel eerst een andere style in als standaard.
Administrator Template Styles
Alle admin styles ophalen
GET /api/index.php/v1/templates/styles/administrator
Admin style bijwerken
PATCH /api/index.php/v1/templates/styles/administrator/{id}
Standaard Template Instellen
Om een template style als standaard in te stellen:
curl -X PATCH "https://jouwesite.nl/api/index.php/v1/templates/styles/site/10" \
-H "X-Joomla-Token: JOUW_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"home": "1"
}'
info
Er kan maar één standaard template style zijn. Het instellen van een nieuwe standaard zet automatisch de vorige op "0".
Cassiopeia Parameters
Het Cassiopeia template (Joomla 4/5 standaard) heeft deze parameters:
| Parameter | Type | Beschrijving |
|---|---|---|
| logoFile | string | Pad naar logo afbeelding |
| siteTitle | string | Site titel (overschrijft config) |
| siteDescription | string | Site beschrijving |
| fluidContainer | string | "0" = fixed, "1" = fluid container |
| colorName | string | Kleurenschema naam |
| useFontScheme | string | "0" = standaard, "1" = aangepast |
Beschikbare kleurenschema's
| Waarde | Beschrijving |
|---|---|
| colors_standard | Standaard kleuren |
| colors_alternative | Alternatieve set |
Template Style per Menu Item
Template styles kunnen gekoppeld worden aan specifieke menu items. Dit gebeurt bij het menu item, niet bij de template style.
Voorbeeld: Menu item met template style
curl -X PATCH "https://jouwesite.nl/api/index.php/v1/menus/site/items/101" \
-H "X-Joomla-Token: JOUW_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"template_style_id": 11
}'
Filtering
Op template
GET /api/index.php/v1/templates/styles/site?filter[template]=cassiopeia
Standaard styles
GET /api/index.php/v1/templates/styles/site?filter[home]=1
Template Posities Ophalen
Om beschikbare template posities te zien, bekijk het template's templateDetails.xml bestand of gebruik:
# Activeer de template preview module positie
# Preview URL: jouwesite.nl/?tp=1
Voorbeeld: Meerdere Styles Beheren
<?php
/**
* Template styles beheren via API
*/
class TemplateManager {
private $baseUrl;
private $token;
public function __construct($baseUrl, $token) {
$this->baseUrl = $baseUrl;
$this->token = $token;
}
public function createStyle($template, $title, $params = []) {
$url = $this->baseUrl . '/api/index.php/v1/templates/styles/site';
$data = [
'template' => $template,
'title' => $title,
'params' => $params
];
return $this->request('POST', $url, $data);
}
public function setDefault($styleId) {
$url = $this->baseUrl . "/api/index.php/v1/templates/styles/site/{$styleId}";
return $this->request('PATCH', $url, ['home' => '1']);
}
private function request($method, $url, $data = null) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-Joomla-Token: ' . $this->token,
'Content-Type: application/json'
]);
if ($data) {
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
}
?>