Hello,
I have followed 2 tutorials show how to include external files but non seem to work?
im currently only trying to call the header / footer / content.
- The first way says to create a snippet called "includeTemplate" with this code:
<?php
if ( !isset($tpl) || $tpl== "" ) return "Missing Template file!";
$tpl = $base_path.’assets/templates/’.$tpl;
ob_start();
include($tpl);
return ob_get_clean();
and then call the header by pasting this code in to the header chunk
[[includeTemplate? &tpl='assets/templates/main/site_header.html']]
- The second way says to create a snippet called "includeFile" with this code:
<?php
# Snippet to include files from filesystem
# [[includeFile? &file=`assets/templates/mytemplate/file.html`]]
if ( !isset($file) || $file== "" ) return "No file specified."; //check if there's a file given.
//Start the buffer
ob_start();
//include
include $file;
//get contents from the buffer
$ob_contents = ob_get_contents();
//and kill/delete the buffer
ob_end_clean();
//return it to MODx
return $ob_contents;
and then call the header by pasting this code in to the header chunk
[[includeFile? &file=`assets/templates/main/site_header.html`]]
both are not working.
my files are located at:
assets/templates/main/site_header.html
assets/templates/main/site_footer.html
assets/templates/main/site_template.html
site_template.html looks like this:
[[$bpSiteHeader]]
[[*content]]
[[$bpSiteFooter]]
any ideas . what am i doing wrong ?