How To Create A Box
This assumes you understand the standards from creating a new page. Sometimes you want to create independent boxes to include on different pages.
Create the following files
includes/boxes/box_hello_world.php:
<?php
$box_hello_world = new ent_view();
$box_hello_world->snippets = [
'title' => 'Hello World',
'content' => 'Lorem ipsum dolor',
];
echo $box_hello_world->stitch('views/box_hello_world');
And here is an example of a template view file:
includes/templates/mytemplate.catalog/views/box_hello_world.inc.php:
<article>
<h1>{snippet:title}</h1>
<p>{snippet:content}</p>
</article>
This is not very different from creating a new page. But when it comes to inserting the box on a page there are different approaches.
Include The View In Another View
To include e.g. a box view somewhere in a page view, we simply use a PHP include.
includes/templates/template.catalog/pages/index.inc.php:
<?php include vmod::check(FS_DIR_APP . 'includes/boxes/box_hello_world.inc.php'); ?>
The use of vmod::check() enables overriding the file using vMod. The constant FS_DIR_APP returns the file system path (FS) to your installation e.g. /home/me/public_html/.