Tags
Rate this article
3.00
  • email Email to a friend
  • print Print version
  • Plain text Plain text
Browsing: Home » How-Tos

PHP includes

The fastest and the cleanest way of doing includes in Vivvo 4

The fastest and the cleanest way of doing includes in Vivvo 4 is to include your PHP script output as HTML via vte:include

<vte:include href="http://www.vivvo.net/somepage.php" />

Note: you have to have allow_url_fopen enabled on your server to use this inclusion

Alternatively you would have to do the following for your custom PHP code.

Create include wrapper function:

PHP Code:

function include_something(){
    ob_start();       
    include 'my_include.php';
    $contents = ob_get_contents();
    ob_end_clean();
    return $contents;
}
   
$template->assign('included_php', strval(include_something()));

Note: this is not the cleanest way to perform inclusion as you may pollute vivvo variable scope and break the functionality of included script due to various reasons. This is only suitable for including simple scripts.

For debugging purposes you can add error_reporting(E_ALL) before include 'my_include.php'; 

Comments (0 posted):

You must be registered member of Vivvo.net to post a comment.