Pimcore Templates
Templates define the visual structure of a document and control which parts of a page are editable by editors in Pimcore Studio. A template combines standard HTML/Twig markup with Pimcore Editables, placeholders that turn into interactive input widgets (text fields, WYSIWYG editors, image pickers, etc.) when an editor opens the page in Pimcore Studio's edit mode.
Beyond simple content fields, special editables like Block and Areablock give editors the ability to make structural changes to the page, adding, removing, and reordering content sections without touching the template code itself.
Templates are standard Twig files located in
templates/[controller]/[action].html.twig, while
Symfony's directory conventions
also work.
Check the Pimcore Demo for practical examples.
Rendering Templates
Use Symfony's #[Template] attribute or render the view directly from your controller:
<?php
namespace App\Controller;
use Pimcore\Controller\FrontendController;
use Symfony\Bridge\Twig\Attribute\Template;
use Symfony\Component\HttpFoundation\Response;
class MyController extends FrontendController
{
/**
* The attribute will resolve the defined view
*/
#[Template('content/default.html.twig', vars: ['param1' => 'value1'])]
public function attributeAction(): void
{
}
public function directRenderAction(): Response
{
return $this->render('my/custom/action.html.twig', ['param1' => 'value1']);
}
}
You can also assign a template directly in a document's settings in Pimcore Studio. That template is used for auto-rendering when the controller does not return a response. See MVC in Pimcore for details on how documents resolve their controller and template.
The Template Dropdown
The template selector shown in a document's settings (and when configuring static routes)
is populated by scanning for *.twig files in the project's templates/ directory and in
the templates/ (or Resources/views/) directory of every registered bundle, except bundles
whose namespace starts with Symfony, Doctrine, Pimcore, or Sensio (so Pimcore's own
bundle templates are not listed). Project templates are listed by their relative path
(content/default.html.twig), bundle templates with the Twig namespace notation
(@AppBundle/content/default.html.twig).
To add templates that live outside those scanned paths (e.g. dynamically generated ones),
implement Pimcore\Controller\Config\TemplateProviderInterface and tag the service with
pimcore.template_provider:
services:
App\Templating\MyTemplateProvider:
tags: ['pimcore.template_provider']
Each name returned by getTemplates() must use the same notation as the scanned templates
(a project-relative path or a @Namespace/... name) and is merged into the dropdown.
The default document template detection can be disabled by setting
pimcore.documents.auto_provide_templates to false. In this case the developer needs to provide
their own template provider services, otherwise the list is empty.
Editables
Editables are the bridge between templates and Pimcore Studio. In the template, they look like Twig function calls. In Pimcore Studio's edit mode, they render as interactive input widgets. On the frontend, they output the content the editor has entered:
<h1>{{ pimcore_input('headline') }}</h1>
{{ pimcore_wysiwyg('content') }}
{{ pimcore_select('type', { reload: true, store: [["video","video"], ["image","image"]] }) }}
Pimcore provides editables for text, rich text, images, links, relations, dates, and more. See Editables for the full reference.
For structural flexibility, Block lets editors repeat a set of editables (e.g., a list of feature cards), while Areablock lets them compose pages from predefined content blocks called "bricks."
If you store an editable in a variable, pipe it through the raw filter to prevent HTML escaping:
{% set content = pimcore_wysiwyg('content') %}
{{ content|raw }}
Next Steps
- Template Inheritance and Layouts - define reusable page structures
- Twig Extensions - Pimcore's Twig functions, filters, and tags
- Editables - all available editable types
- Thumbnails - image handling in templates