User Tools

Site Tools


How To Create A Box

Assuming 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

  $box_hello_world = new ent_view();
  $box_hello_world->snippets = array(
    '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:


This is not very much different from creating a new page. But when it comes to inserting the box on a page there are different approaches.

Option 1: Include The Box Directly In A View (Simple)

To include the box somwhere in another page we insert the following code somewhere inside an another view e.g. includes/templates/template.catalog/views/

  <?php include vmod::check(FS_DIR_APP . 'includes/boxes/'); ?>

Please note:

The use of vmod::check() enables overriding the file using vQmod.

The constant FS_DIR_APP returns the file system path (FS) to your installation e.g. /home/me/public_html/.

Option 2: Create A Snippet Of The Box (Advanced)

  $_page = new ent_view();
// Capture the box in a buffer and stick it into a snippet
  include vmod::check(FS_DIR_APP . 'includes/boxes/');
  $_page->snippets['box_hello_world'] = ob_get_clean();
  echo $_page->stitch('views/somepage');

The snippet box_hello_world can now be accessed through any of the following view syntax in the view file:

  • <!–snippet:box_hello_world–>
  • {snippet:box_hello_world}
  • <?php echo $box_hello_world; ?>
how_to_create_a_box.txt · Last modified: 2021/07/07 18:16 by tim