Edit on GitHub

Pimcore Template Layouts


Layouts define everything that repeats on one page to another, such as a header, footer, navigation. Layouts often contain the basic structure of a HTML document, such as <html>, <head> and the <body> tag as well as scripts and stylesheets.

Layouts in Pimcore are located in /website/views/layouts.

Usage of Layouts

A Simple Sample Layout Looks Like the Following:
<!DOCTYPE html>
<html lang="en">
<?php /** @var $this \Pimcore\View */ ?>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="/website/static/css/screen.css" />
    <div id="site">
        <?= $this->layout()->content; ?>

Of course, PHP can be used within the layout file and therefore layouts can become much more complicated. The most important line though is <?= $this->layout()->content; ?>. It includes the actual rendered content of the view.

To Enable a Layout in Your Controller Action Use:

By default, the layout layout.php is used. If you want to change default layout, you need to add the following line to specify another layout. You can use as many layouts as you like.

    //change layout to catalog.php

<div id="product">