User Tools

Site Tools


how_to_create_a_box

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

includes/boxes/box_hello_world.php
<?php
  $box_hello_world = new 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:

includes/templates/mytemplate.catalog/views/box_hello_world.php
<div id="box-hello-world" class="box white">
  <h1><?php echo $title; ?></h1>
  <p><?php echo $content; ?></p>
</div>

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.

Include The Box In a Page/View

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

  <?php include vmod::check(FS_DIR_HTTP_ROOT . WS_DIR_BOXES . 'box_hello_world.inc.php'); ?>

Please note:

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

The constant FS_DIR_HTTP_ROOT returns the file system path (FS) to your installation e.g. /home/me/public_html The constant WS_DIR_BOXES returns the web system path (WS) to your boxes folder e.g. /includes/boxes/.

how_to_create_a_box.txt · Last modified: 2017/04/23 04:03 by 177.227.37.175