Custom Sulu Template Development
A client recently approached us with a task: a service page needed to contain blocks for “Text,” “Image+Text,” “Call to Action,” and a sidebar with a feedback form. Sulu’s standard templates didn’t offer that combination—they would have had to hack the admin interface or create a custom template. We built the solution in 2 days: an XML schema with the required block types, a Twig template for rendering, and a custom controller to load testimonials. Now the manager can assemble the page from ready-made blocks in minutes. Our team has 5+ years of experience with Sulu CMS and has delivered 20+ projects, ensuring bug-free, requirement-compliant output. This flexibility lets our clients save up to 30% on maintenance budgets by eliminating hacks. When developing 5–8 custom templates for a corporate site, savings can reach 40% compared to purchasing a ready-made solution.
Why a Custom Sulu Template Is Better Than a Standard One
Standard templates cover basic needs. But for unique pages, you often need fields that aren’t in the box. A custom template allows:
- Add any field types: text editors, media, blocks with arbitrary structure.
- Create multiple layouts for the same page type.
- Connect a custom controller to load additional data (e.g., related records or testimonials).
- Control the view through Twig templates without limitations.
The result is flexibility impossible with standard solutions, with maintenance cost reduction of 30–50% thanks to eliminating workarounds. According to Sulu documentation, custom controllers save time on integrations.
How to Develop a Custom Sulu Template
The process includes several stages:
- Analyze page requirements and agree on structure.
- Design an XML schema with fields and blocks.
- Develop a Twig template with the design in mind.
- Write a custom controller (if additional data is needed).
- Integrate with the existing theme and test.
- Deploy to the server and final verification.
- Provide documentation and training.
Timelines depend on complexity. Below are approximate durations for different template types.
| Template Type | Unique Blocks | Development Time |
|---|---|---|
| Simple (text, media) | 2–4 | 1–2 days |
| Medium (block editor, custom fields) | 5–8 | 2–3 days |
| Complex (custom controller, integrations) | 8+ | 3–5 days |
Comparison of Standard and Custom Template
| Criterion | Standard Template | Custom Template |
|---|---|---|
| Number of fields | Limited | Unlimited |
| Block types | Only text | Text, media, CTA, gallery, etc. |
| Controller | Only DefaultController | Custom with any logic |
| Flexibility | Low | High |
Example XML Template
<template xmlns="http://schemas.sulu.io/template/template"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schemas.sulu.io/template/template
http://schemas.sulu.io/template/template-1.0.xsd">
<key>service</key>
<view>pages/service</view>
<controller>App\Controller\Website\ServiceController::indexAction</controller>
<cacheLifetime type="seconds">1800</cacheLifetime>
<properties>
<property name="title" type="text_line" mandatory="true">
<meta><title lang="en">Title</title></meta>
<tag name="sulu.rlp.part"/>
</property>
<property name="intro" type="text_area" colspan="12">
<meta><title lang="en">Introductory text</title></meta>
<params>
<param name="rows" value="3"/>
</params>
</property>
<block name="content_blocks" default-type="text" colspan="12">
<meta><title lang="en">Content blocks</title></meta>
<types>
<type name="text">
<meta><title lang="en">Text</title></meta>
<properties>
<property name="text" type="text_editor">
<meta><title lang="en">Text</title></meta>
</property>
</properties>
</type>
<type name="image_text">
<meta><title lang="en">Image + text</title></meta>
<properties>
<property name="image" type="single_media_selection">
<meta><title lang="en">Image</title></meta>
</property>
<property name="text" type="text_editor">
<meta><title lang="en">Text</title></meta>
</property>
<property name="image_position" type="select">
<meta><title lang="en">Image position</title></meta>
<params>
<param name="values" type="collection">
<param name="left" title="Left"/>
<param name="right" title="Right"/>
</param>
</params>
</property>
</properties>
</type>
<type name="cta">
<meta><title lang="en">Call to action</title></meta>
<properties>
<property name="heading" type="text_line">
<meta><title lang="en">Heading</title></meta>
</property>
<property name="button_text" type="text_line">
<meta><title lang="en">Button text</title></meta>
</property>
<property name="button_link" type="text_line">
<meta><title lang="en">Link</title></meta>
</property>
</properties>
</type>
</types>
</block>
<section name="sidebar">
<meta><title lang="en">Sidebar</title></meta>
<properties>
<property name="show_form" type="checkbox">
<meta><title lang="en">Show feedback form</title></meta>
<params>
<param name="defaultValue" value="true"/>
</params>
</property>
<property name="related_services" type="smart_content">
<meta><title lang="en">Related services</title></meta>
<params>
<param name="provider" value="pages"/>
<param name="types" value="service"/>
<param name="max_per_page" value="4"/>
</params>
</property>
</properties>
</section>
</properties>
</template>
Twig Template
{% extends 'base.html.twig' %}
{% block title %}{{ content.title }} | {{ app.request.host }}{% endblock %}
{% block body %}
<div class="page-service">
<h1>{{ content.title }}</h1>
{% for block in content.content_blocks %}
<div class="block block--{{ block.type }}">
{% if block.type == 'text' %}
{{ block.text|raw }}
{% elseif block.type == 'image_text' %}
<img src="{{ sulu_resolve_media(block.image, locale).thumbnails['service-block'] }}" alt="" loading="lazy">
{{ block.text|raw }}
{% elseif block.type == 'cta' %}
<h2>{{ block.heading }}</h2>
<a href="{{ block.button_link }}" class="btn">{{ block.button_text }}</a>
{% endif %}
</div>
{% endfor %}
</div>
{% endblock %}
Custom Controller
class ServiceController extends AbstractController
{
public function indexAction(StructureInterface $structure): Response
{
$testimonials = $this->testimonials->findByService($structure->getUuid(), limit: 3);
return $this->render('pages/service.html.twig', [
'content' => $structure->getContent(),
'testimonials' => $testimonials,
]);
}
}
Registering the Template in Webspace
<templates>
<template type="page">service</template>
</templates>
After adding the template, clear cache and reindex:
php bin/console cache:clear
php bin/console sulu:document:initialize
Typical Pitfalls and Solutions
-
Template not applied — most often forgotten to register the key in webspace or clear cache. Always check the config entry and run
cache:clear. -
Incorrect controller reference — specify the full class and method, otherwise Sulu won't find the controller. Use
debug:routerto verify. -
Blocks not displayed — ensure that in the Twig template, each block type has corresponding logic. A common mistake is missing the
typecheck in the loop.
What’s Included in the Work
- XML schema with fields and blocks
- Twig template with responsive layout
- Custom controller (if needed)
- CMS integration and access rights configuration
- Template structure documentation
- Training for content managers on working with blocks
- Quality guarantee and post-deployment support
We provide custom Sulu layout and full Sulu site development. Our custom Sulu template solutions fully meet your requirements and save budget.
Timelines and How to Order
One template with block editor, custom controller, and Twig takes 2–3 days. A complete set of templates (5–8 types) for a corporate site takes 1.5–2 weeks. Cost is calculated individually based on complexity and scope.
Contact us to discuss your project—we’ll prepare a detailed proposal. Get a consultation on custom Sulu template development today.







