Skip to content

RockFrontend and Markup Regions

Bernhard Baumrock edited this page Oct 1, 2022 · 1 revision

If you want to use Markup Regions together with RockFrontend you can do so. The only thing you have to take care of is to make sure that the region's content markup is output BEFORE the regions position markup:

<div id='foo'>foo content</div>

<div id='foo'>this content will be replaced by "foo content"</div>

Basic Setup

RockFrontend renders its markup from _main.php which is rendered AFTER the php template files (like home.php or basic-page.php). That means you can place your regions in _main.php (or in any other file that is rendered from _main.php, for example sections/header.latte or sections/footer.latte) and then you can place the content of that regions in the PHP template file:

// /site/templates/home.php
<div id='footer'>I am the homepage footer</div>

// /site/templates/sections/footer.latte
<div id='footer'>I am a LATTE footer on page "{$page->title}"</div>

// /site/templates/_main.php
echo $rockfrontend->render('sections/header.latte');
echo $rockfrontend->render('sections/main.latte');
echo $rockfrontend->render('sections/footer.latte');

Basic Setup with LATTE files

In the above example we rendered the region content from a PHP file. If you want to render it from a LATTE file you can simply use $rockfrontend->render() for that:

// home.php
echo $rockfrontend->render('home.latte');

Advanced Setup

With the basic setup you need to create a PHP file for every page that renders markup region content. You can get rid of those PHP template files by creating a custom render file and setting that in the template settings:

/site/templates/LatteRenderer.php

<?php

namespace ProcessWire;

echo $rockfrontend->render($page->template . ".latte");

Now your template will execute the LatteRenderer.php on render which will then use RockFrontend to render the LATTE file!

Clone this wiki locally