User Tools

Site Tools


how_to_create_a_box

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
how_to_create_a_box [2017/04/23 04:03]
A User Not Logged in the box file was wrong.
how_to_create_a_box [2021/02/03 23:15] (current)
tim [Option 1: Include The Box Directly In A View (Simple)]
Line 19: Line 19:
 And here is an example of a template view file: And here is an example of a template view file:
  
-<file php includes/templates/mytemplate.catalog/views/box_hello_world.php> +<file php includes/templates/mytemplate.catalog/views/box_hello_world.inc.php> 
-<div id="box-hello-world" class="box white"+<article
-  <h1><?php echo $title; ?></h1> +  <h1>{snippet:title}</h1> 
-  <p><?php echo $content; ?></p> +  <p>{snippet:content}</p> 
-</div>+</article>
 </file> </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. 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 =====+===== Option 1: Include The Box Directly In 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/pages/index.inc.php:+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/index.inc.php:
  
 <file php> <file php>
-  <?php include vmod::check(FS_DIR_HTTP_ROOT . WS_DIR_BOXES . 'box_hello_world.inc.php'); ?>+  <?php include vmod::check(FS_DIR_APP . 'includes/boxes/box_hello_world.inc.php'); ?>
 </file> </file>
  
Line 40: Line 40:
 The use of vmod::check() enables overriding the file using vQmod. 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 FS_DIR_APP 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 (WSto your boxes folder e.g. /includes/boxes/.+===== Option 2: Create A Snippet Of The Box (Advanced=====
  
 +<file php pages/somepage.inc.php>
 +<?php
 +  $_page = new view();
 +  
 +  ...
 +  
 +// Capture the box in a buffer and stick it into a snippet
 +  ob_start();
 +  include vmod::check(FS_DIR_APP . 'includes/boxes/box_hello_world.inc.php');
 +  $_page->snippets['box_hello_world'] = ob_get_clean();
 +  
 +  ...
 +
 +  echo $_page->stitch('views/somepage');
 +?>
 +</file>
 +
 +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.1492912986.txt.gz · Last modified: 2017/04/23 04:03 by A User Not Logged in