forum.coppermine-gallery.net

Support => Older/other versions => cpg1.2 Standalone Support => Topic started by: Michi on March 13, 2005, 08:42:38 pm

Title: Includes in custom pageheader()
Post by: Michi on March 13, 2005, 08:42:38 pm
Hey.

This is what my pageheader-function looks like now:

Code: [Select]
function pageheader($section, $meta = '')
{
    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir;

   // this is the place where the custom header file gets included

      ob_start();
      include('/home/docs/php/templates/layout.php');
      beginBody();
      $beginBody = ob_get_contents();
      ob_end_clean();

      ob_start();
      beginPage();
      $beginPage = ob_get_contents();
      ob_end_clean();


    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
    user_save_profile();

    $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(),
        '{BEGIN_PAGE}' => $beginPage,
        '{BEGIN_BODY}' => $beginBody,
        );

    echo template_eval($template_header, $template_vars);
}
The layout.php -file I'm including checks what style template file the page is supposed to use. The template file consists of functions, eg beginBody(), that consist of the template HTML-stuff I'm trying to wrap the Coppermine galleries with.

Problem is that when I try to print out certain stuff, for example the username, the $username variable that is declared in the beginning of the template file, isn't available in the beginBody-function.


Code: [Select]
$userid = $_REQUEST['bbuserid']; //THIS IS SET IN A COOKIE

It works fine in vBulletin, so I've figured it has something to do with CPG... I have CPG 1.2.0 installed. Does Coppermine somehow "separate" the functions from the original file and therefore loses the variables along the way...?
Title: Re: Includes in custom pageheader()
Post by: kegobeer on March 13, 2005, 11:06:55 pm
Any variables you want available inside of a function need to be declared in a GLOBAL statement.  Coppermine doesn't use $username, your username is set in the constant USER_NAME, which doesn't need to be declared in a global statement.  You can see this variable used in the theme.php file.
Title: Re: Includes in custom pageheader()
Post by: Michi on March 14, 2005, 03:13:22 pm
in the function endPage() I'm trying to call variable $userid, which is defined in the very beginning of the template file.

Code: [Select]
$userid = $_COOKIE['bbuserid'];
After that, I have
Code: [Select]
GLOBAL $userid
But in the endPage() a "echo $userid;" -code prints out nothing.

As I use the same templates with vBulletin and news publishing, I really wouldn't want to start inserting CPG variables to the templates...