Technical notes about OctoberCMS a Laravel CMS. Notes are written by inetis team, a Swiss webagency

<- Back

Render the content of subpages

Posted on by

If you are building a onepage template with octoberCMS, it is a good idea to manage blocks with the Page plugin. But how can you render them on the final page without losing snippet functionality ?

The first solution is to use a plugin . This plugin allow you to pass the name of a page in parameter and display all the subpages.

url = "/"
title = "One page exemple"
layout = "default"


//php code block
<div class="container">
    {% component 'subpages' %}

Another solution that does not require a plugin is to use the RainLab\Pages\Classes\Page class. Don't forget to use a raw filter for the content of your page, because it contains HTML tags.

use RainLab\Pages\Classes\Page;

function onStart()
    $file = 'accueil-1.htm';
    $page = Page::find($file);
    $this['home1Title'] = $page->title;    
    $this['home1'] = $page->getProcessedMarkup();  
<div class="container">
            <h2>{{ home1Title }}</h2>
            {{ home1|raw }}