forum.coppermine-gallery.net

Support => cpg1.3.x Support => Older/other versions => cpg1.3 Themes/Skins/Templates => Topic started by: seanophobia on June 11, 2005, 05:24:18 pm

Title: Custom Header problem - Showing {CUSTOM_HEADER} instead of my included php code?
Post by: seanophobia on June 11, 2005, 05:24:18 pm
I followed the documentation on how to do custom header etc, was getting a error, but i searched and fixed by changing
Code: [Select]
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

Code: [Select]
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?
Title: Re: Custom Header problem - Showing {CUSTOM_HEADER} instead of my included php code?
Post by: donnoman on June 11, 2005, 06:01:41 pm
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.

Code: [Select]
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:
Code: [Select]
  $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,
   );

Title: Re: Custom Header problem - Showing {CUSTOM_HEADER} instead of my included php code?
Post by: seanophobia on June 11, 2005, 07:51:44 pm
solved, thankz a bunch  ;D