Custom Header problem - Showing {CUSTOM_HEADER} instead of my included php code? Custom Header problem - Showing {CUSTOM_HEADER} instead of my included php code?
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Custom Header problem - Showing {CUSTOM_HEADER} instead of my included php code?

Started by seanophobia, June 11, 2005, 05:24:18 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

seanophobia

I followed the documentation on how to do custom header etc, was getting a error, but i searched and fixed by changing
function pageheader($section, $meta = '')
{
  global $CONFIG, $THEME_DIR;
  global $template_header, $lang_charset, $lang_text_dir;
 
  if(empty($custom_header)){
     include('/includes/counter.php');
     static $custom_header = ob_get_contents();
     ob_clean();
  }


to

function pageheader($section, $meta = '')
{
  global $CONFIG, $THEME_DIR;
  global $template_header, $lang_charset, $lang_text_dir;
  static $custom_header;
 
  if(empty($custom_header)){
     include('counter.php');
     ob_clean();
  }


Which got rid of my error, but now when i put {CUSTOM_HEADER} in my template.html its not including the counter.php , its just showing {CUSTOM_HEADER}

I searched but i didnt find solution, if this problem has already been solved can someone point me to the page?

donnoman

The code you changed to won't EVER do anything.

Your code basically says start an output buffer (meaning capture output to memory instead of screen), inlcude the file (which creates output and is stored in memory), then clean out the buffer (throw away what was just put in the buffer).

Based on the fact that you say the error went away this is probably the correct way to populate the $custom_header variable.


function pageheader($section, $meta = '')
{
  global $CONFIG, $THEME_DIR;
  global $template_header, $lang_charset, $lang_text_dir;
 
  if(empty($custom_header)){
     include('counter.php');
     static $custom_header = ob_get_contents();
     ob_clean();
  }


Now you need to make the actual substitution happen, note the {CUSTOM_HEADER} token in the list of replacments.

in the pageheader function:

  $template_vars = array(
     '{LANG_DIR}' => $lang_text_dir,
     '{TITLE}' => $CONFIG['gallery_name'].' - '.$section,
     '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
     '{META}' => $meta,
     '{GAL_NAME}' => $CONFIG['gallery_name'],
     '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
     '{MAIN_MENU}' => theme_main_menu(),
     '{ADMIN_MENU}' => theme_admin_mode_menu(),
     '{CUSTOM_HEADER}' => $custom_header,
  );