Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Re: Adding PHP Include  (Read 5604 times)

0 Members and 1 Guest are viewing this topic.

Nibbler

  • Guest
Re: Adding PHP Include
« on: May 09, 2005, 05:11:25 pm »

Try posting a link to your site and the changes you have made to your theme.php.
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Adding PHP Include
« Reply #1 on: May 09, 2005, 05:33:19 pm »

FAQ: Custom Header.

I'll use the classic theme as the example.

You've got two custom includes so we establish which tokens we want to use for each. There's nothing magical about {CUSTOM_HEADER}.. as long as we don't use a token thats already in coppermine we're fine.

{NEWSLETTER}
{REMOTE_IP}

In your template.html stick them where you want the content to end up. (pick your own places, unless you really like mine ;D )
Code: [Select]
                               <td width="100%" align="center">
                                        <h1>{GAL_NAME}</h1>
                                        <h3>{GAL_DESCRIPTION}</h3><br />
                                        {NEWSLETTER}
                                        {MAIN_MENU}
                                </td>

Code: [Select]
               <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                        <tr>
                                <td align="center" valign="top">
                                        {ADMIN_MENU}
                                        {GALLERY}
                                        {REMOTE_IP}
                                </td>
                        </tr>
                </table>

Now you need to edit theme.php so you can establish what each token should be

{NEWSLETTER} Appears before {GALLERY} so we will edit the pageheader function to be able to replace it.
find function pageheader in theme.php
Code: [Select]
function pageheader($section, $meta = '')
{
    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir;

    $charset = ($CONFIG['charset'] == 'language file') ? $lang_charset : $CONFIG['charset'];

    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
    header("Content-Type: text/html; charset=$charset");
    user_save_profile();

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

    echo template_eval($template_header, $template_vars);
}

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

    if(empty($newsletter)){
       ob_start();
       require('themes/classic/newsletter.php'); //paths are relative to coppermines index.php
       static $newsletter;
       $newsletter= ob_get_contents();
       ob_clean();
    }

    $charset = ($CONFIG['charset'] == 'language file') ? $lang_charset : $CONFIG['charset'];

    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
    header("Content-Type: text/html; charset=$charset");
    user_save_profile();

    $template_vars = array('{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => $CONFIG['gallery_name'] . ' - ' . $section,
        '{CHARSET}' => $charset,
        '{META}' => $meta,
        '{GAL_NAME}' => $CONFIG['gallery_name'],
        '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
        '{MAIN_MENU}' => theme_main_menu(),
        '{ADMIN_MENU}' => theme_admin_mode_menu(),
        '{NEWSLETTER}' => $newsletter,
        );

    echo template_eval($template_header, $template_vars);
}

{REMOTE_IP} is after {GALLERY} in my template.html so I need to edit the pagefooter function to be able to replace it.

find function pagefooter in theme.php
Code: [Select]
function pagefooter()
{
    global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS;
    global $USER, $USER_DATA, $ALBUM_SET, $CONFIG, $time_start, $query_stats, $queries;;
    global $template_footer;

    if ($CONFIG['debug_mode']==1 || ($CONFIG['debug_mode']==2 && GALLERY_ADMIN_MODE)) {
    cpg_debug_output();
    }

    echo $template_footer;
}

update to:
Code: [Select]
function pagefooter()
{
    global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS;
    global $USER, $USER_DATA, $ALBUM_SET, $CONFIG, $time_start, $query_stats, $queries;;
    global $template_footer;

    if ($CONFIG['debug_mode']==1 || ($CONFIG['debug_mode']==2 && GALLERY_ADMIN_MODE)) {
    cpg_debug_output();
    }

    $template_vars = array(
        '{REMOTE_IP}' =>$_SERVER["REMOTE_ADDR"],
        );

    echo template_eval($template_footer, $template_vars);
}

Notice I don't actually bother doing an include just to set one variable. Just make the substitution right in pagefooter itself.

If you really want to include the php follow the example for pageheader.
Logged

Crash_Sys

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 46
Re: Adding PHP Include
« Reply #2 on: May 10, 2005, 02:18:32 am »

Yeah-

Thank you. Specially donnoman, Thank YOU! I got it to work. Thanks Great Coding
;D ;D
Logged
Pages: [1]   Go Up
 

Page created in 0.022 seconds with 21 queries.