Different banner IF logged in Different banner IF logged in
 

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

Different banner IF logged in

Started by cynikalsam, November 13, 2004, 03:22:03 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

cynikalsam

Is there a way to get a different banner logo displayed one the user has logged in?

Joachim Müller

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

cynikalsam

Ok, i read the faq's about custom headers, and if i understand it correctly (and i probably dont), im supposed to put


<?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?

Joachim Müller

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

cynikalsam

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


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;


<?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

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* :(

kegobeer

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.
Do not send me a private message unless I ask for one.  Make your post public so everyone can benefit.

There are no stupid questions
But there are a LOT of inquisitive idiots

cynikalsam

The code i added to the theme.php file is what i posted. Should i post the entire code from the file?

kegobeer

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.
Do not send me a private message unless I ask for one.  Make your post public so everyone can benefit.

There are no stupid questions
But there are a LOT of inquisitive idiots

cynikalsam

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

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);
}

kegobeer

I guess my eyesight just isn't what it used to be.  I didn't see this function in any of your posts:

// 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
Do not send me a private message unless I ask for one.  Make your post public so everyone can benefit.

There are no stupid questions
But there are a LOT of inquisitive idiots

cynikalsam

#10
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
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
<?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 :(

Casper

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;

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;

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.
It has been a long time now since I did my little bit here, and have done no coding or any other such stuff since. I'm back to being a noob here

cynikalsam

That last method worked perfectly. Thank you! :)

Casper

Quote from: 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?
It has been a long time now since I did my little bit here, and have done no coding or any other such stuff since. I'm back to being a noob here