Hi. Say you want to include header.html and footer.html in a template.
First add the following function to the top of the search_function.php file:
PHP Code:
function get_my_includes($filename) {
if (file_exists($filename)) {
$buffer = "";
$handle = fopen($filename, "r");
while (!feof($handle)) {
$buffer .= fgets($handle, 4096);
}
fclose($handle);
return $buffer;
}
}
Next in search_function.php replace:
PHP Code:
if ($template == 'array' || is_file($template)) {
$phpdig_version = PHPDIG_VERSION;
$t_mstrings = compact('powered_by_link','title_message','phpdig_version','result_message','nav_bar','ignore_message','ignore_commess','pages_bar','previous_link','next_link','templates_links');
$t_fstrings = phpdigMakeForm($query_string,$option,$limite,SEARCH_PAGE,$site,$path,'template',$template);
if ($template == 'array') {
return array_merge($t_mstrings,$t_fstrings,array('results'=>$table_results));
}
else {
$t_strings = array_merge($t_mstrings,$t_fstrings);
phpdigParseTemplate($template,$t_strings,$table_results);
}
}
with the following:
PHP Code:
// check that the paths are correct or use full paths
$my_page_header = get_my_includes("../../dir/header.html");
$my_page_footer = get_my_includes("../../dir/footer.html");
if ($template == 'array' || is_file($template)) {
$phpdig_version = PHPDIG_VERSION;
$t_mstrings = compact('my_page_header','my_page_footer','powered_by_link','title_message','phpdig_version','result_message','nav_bar','ignore_message','ignore_commess','pages_bar','previous_link','next_link','templates_links');
$t_fstrings = phpdigMakeForm($query_string,$option,$limite,SEARCH_PAGE,$site,$path,'template',$template);
if ($template == 'array') {
return array_merge($t_mstrings,$t_fstrings,array('results'=>$table_results));
}
else {
$t_strings = array_merge($t_mstrings,$t_fstrings);
phpdigParseTemplate($template,$t_strings,$table_results);
}
}
Finally in the template use:
Code:
<phpdig:my_page_header/>
<phpdig:my_page_footer/>
Remember to remove any "word" wrapping in the above code.