forum.coppermine-gallery.net

Support => cpg1.3.x Support => Older/other versions => cpg1.3 Themes/Skins/Templates => Topic started by: cynikalsam on November 13, 2004, 03:22:03 am

Title: Different banner IF logged in
Post by: cynikalsam on November 13, 2004, 03:22:03 am
Is there a way to get a different banner logo displayed one the user has logged in?
Title: Re: Different banner IF logged in
Post by: Joachim Müller on November 14, 2004, 01:19:14 pm
The banner by default resides in template.html, which is static. If you want dynamic content, you'll have to create a "custom header" (search the board for this search term). You can then add a switch like the one discussed in http://forum.coppermine-gallery.net/index.php?topic=11619.0

Joachim
Title: Re: Different banner IF logged in
Post by: cynikalsam on November 14, 2004, 02:33:52 pm
Ok, i read the faq's about custom headers, and if i understand it correctly (and i probably dont), im supposed to put

Code: [Select]
<?php
if (USER_ID) {
    
//banner for logged in users..
} else {
    
//banner for guests
}
?>


In my theme.php file? Where would i put it exactly? Would i have to remove the template.html, or edit it to remove any reference to my current banner?
Title: Re: Different banner IF logged in
Post by: Joachim Müller on November 14, 2004, 02:41:50 pm
The code you're refering to is not from the custom header thread, it's from a thread that explains how to built a switch that distinguishes between logged-in and non-logged-in visitors. The actual "custom header" thread (well, one of them actually - like I said, you were suppossed to search the board!) is http://forum.coppermine-gallery.net/index.php?topic=9863.0 Please make sure to read the whole thread - even the stuff that doesn't apply to your question, because I will not design a custom header for you, I'm only giving you some hints on how to accomplish this on your own (as I believe that doing support actually means making users learn something, which can be fun and entertaining imo, instead of just posting code that is ready to be copied and pasted).

Joachim
Title: Re: Different banner IF logged in
Post by: cynikalsam on November 14, 2004, 03:40:44 pm
Ok, so here's what ive done so far; I followed your directions for including a custom header from that thread, and i added {CUSTOM_HEADER} right after the <body> tag. I opened my theme.php file, and added

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
   if(empty($custom_header)){
      ob_start();
      include('http://www.cynikalsam.com/gallery/themes/cold_wire/header.php');
      $custom_header = cleanup_custom_includes(ob_get_contents());
      ob_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(),
        '{CUSTOM_HEADER}' => $custom_header,
        );

    echo template_eval($template_header, $template_vars);
}

In place of the origional code. Then i created the header.php;

Code: [Select]
<?php
if (USER_ID) { 
  include(
'http://www.cynikalsam.com/gallery/themes/cold_wire/template2.html');

else {
  include(
'http://www.cynikalsam.com/gallery/themes/cold_wire/template3.html');
}
?>


Template2 has the banner for logged in users, while template3 is loaded for guests. The switch works great, except the body of the gallery doesnt load. Error (http://www.cynikalsam.com/gallery/)

The banner is done in flash, so i need to reference an html file in the swich, and not just an image file. Any idea what im doing wrong?

Thanks for your help

//Correction.. The switch didnt work. It just displays the logged in banner. *bangs head on wall* :(
Title: Re: Different banner IF logged in
Post by: kegobeer on November 14, 2004, 04:09:38 pm
The function cleanup_custom_includes isn't being found in the cold wire theme.php file.  I'm not familiar with the code you're attempting to add to your site, so I can't tell you exactly what's going wrong.  Verify that function cleanup_custom_includes is where it's supposed to be.
Title: Re: Different banner IF logged in
Post by: cynikalsam on November 14, 2004, 04:12:11 pm
The code i added to the theme.php file is what i posted. Should i post the entire code from the file?
Title: Re: Different banner IF logged in
Post by: kegobeer on November 14, 2004, 05:30:43 pm
Nope.  I'm just telling you that the function cleanup_custom_includes isn't being found in your theme.php file.  I suggest reviewing the threads you found the mod in and see if that function needs to be put into your theme.php file.  Most likely you just missed it.  Do a search for cleanup_custom_includes.
Title: Re: Different banner IF logged in
Post by: cynikalsam on November 14, 2004, 07:21:30 pm
Im just telling you it's there, in the code i posted. Thats my theme.php file. The first code.. Its in there, so im not sure what else to do.

This is my theme.php. The code is in there

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
   if(empty($custom_header)){
      ob_start();
      include('http://www.cynikalsam.com/gallery/themes/cold_wire/header.php');
      $custom_header = cleanup_custom_includes(ob_get_contents());
      ob_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(),
        '{CUSTOM_HEADER}' => $custom_header,
        );

    echo template_eval($template_header, $template_vars);
}
Title: Re: Different banner IF logged in
Post by: kegobeer on November 14, 2004, 07:28:28 pm
I guess my eyesight just isn't what it used to be.  I didn't see this function in any of your posts:

Code: [Select]
// Function to clean up any double html leftovers from the custom header and footer that are not meant to get parsed
function cleanup_custom_includes($string) {
    $string = str_replace('<HTML>', '', $string);
    $string = str_replace('<HEAD>', '', $string);
    $string = str_replace('<BODY>', '', $string);
    $string = str_replace('</HTML>', '', $string);
    $string = str_replace('</HEAD>', '', $string);
    $string = str_replace('</BODY>', '', $string);
    return $string;
}

The code you posted calls the cleanup_custom_includes function, but you didn't add the function to your theme.php file.

See the following thread:
http://forum.coppermine-gallery.net/index.php?topic=11373.0
Title: Re: Different banner IF logged in
Post by: cynikalsam on November 15, 2004, 11:09:25 am
Ok i added that code, but i get errors.

{META}
{MAIN_MENU}
{ADMIN_MENU}
{GALLERY}
(c)2004 cynikalsam.com {LANGUAGE_SELECT_FLAGS} {LANGUAGE_SELECT_LIST} {THEME_SELECT_LIST}

Are all visible under my banner.

theme.php
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
   if(empty($custom_header)){
      ob_start();
      include('http://www.cynikalsam.com/gallery/themes/cold_wire/header.php');
      $custom_header = cleanup_custom_includes(ob_get_contents());
      ob_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(),
        '{CUSTOM_HEADER}' => $custom_header,
        );

    echo template_eval($template_header, $template_vars);
}

// Function to clean up any double html leftovers from the custom header and footer that are not meant to get parsed
function cleanup_custom_includes($string) {
    $string = str_replace('<HTML>', '', $string);
    $string = str_replace('<HEAD>', '', $string);
    $string = str_replace('<BODY>', '', $string);
    $string = str_replace('</HTML>', '', $string);
    $string = str_replace('</HEAD>', '', $string);
    $string = str_replace('</BODY>', '', $string);
    return $string;
}

header.php
Code: [Select]
<?php
if (USER_ID) { 
  include(
'http://www.cynikalsam.com/gallery/themes/cold_wire/template2.html');

  else {
  include(
'http://www.cynikalsam.com/gallery/themes/cold_wire/template3.html');
}
?>

I've been messing with this for hours, and i cant see what im missing :(
Title: Re: Different banner IF logged in
Post by: Casper on November 15, 2004, 01:42:15 pm
I don't know anything about using the custom header / footers as I never use them.  I place my custom header directly in the template.

So, coming from this angle, and seeing you not getting what you want, why not try a new way.

Create your header for the logged on users in your main theme template, using standard html, and leaving the theme.php file alone.  Let's call it 'logged'.

Now create a copy of that theme, but with the un-logged users header in the template.  Call it 'unlogged'.

Now, open your include/init.inc.php file, and find this code;

Code: [Select]
if (!file_exists("themes/{$CONFIG['theme']}/theme.php")) $CONFIG['theme'] = 'classic';
require "themes/{$CONFIG['theme']}/theme.php";
$THEME_DIR = "themes/{$CONFIG['theme']}/";

Now put you 'if/else' switch here, so if the user is logged on, they see theme 'logged', else they see 'unlogged.  Example code;

Code: [Select]
if (USER_ID) {
  $theme='logged';
       require "themes/logged/theme.php";
       $THEME_DIR = "themes/logged/";
} else {

if (!file_exists("themes/{$CONFIG['theme']}/theme.php")) $CONFIG['theme'] = 'classic';
require "themes/{$CONFIG['theme']}/theme.php";
$THEME_DIR = "themes/{$CONFIG['theme']}/";
  }

Now, for this code to work, you set 'unlogged' as your default site theme in admin.
Title: Re: Different banner IF logged in
Post by: cynikalsam on November 16, 2004, 02:48:06 pm
That last method worked perfectly. Thank you! :)
Title: Re: Different banner IF logged in
Post by: Casper on November 16, 2004, 02:58:50 pm
Is there a way to get a different banner logo displayed one the user has logged in?