View Single Post
Old 01-02-2004, 08:18 PM   #2
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
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($handle4096);
    }
    
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.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote