Advanced search  

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

Pages: [1]   Go Down

Author Topic: Different banner IF logged in  (Read 6828 times)

0 Members and 1 Guest are viewing this topic.

cynikalsam

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 50
Different banner IF logged in
« 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?
« Last Edit: November 17, 2004, 06:53:54 am by GauGau »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Different banner IF logged in
« Reply #1 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
Logged

cynikalsam

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 50
Re: Different banner IF logged in
« Reply #2 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?
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Different banner IF logged in
« Reply #3 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
Logged

cynikalsam

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 50
Re: Different banner IF logged in
« Reply #4 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

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

kegobeer

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 4637
  • Beer - it does a body good!
    • The Kazebeer Family Website
Re: Different banner IF logged in
« Reply #5 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.
Logged
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

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 50
Re: Different banner IF logged in
« Reply #6 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?
Logged

kegobeer

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 4637
  • Beer - it does a body good!
    • The Kazebeer Family Website
Re: Different banner IF logged in
« Reply #7 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.
Logged
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

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 50
Re: Different banner IF logged in
« Reply #8 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);
}
Logged

kegobeer

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 4637
  • Beer - it does a body good!
    • The Kazebeer Family Website
Re: Different banner IF logged in
« Reply #9 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
Logged
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

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 50
Re: Different banner IF logged in
« Reply #10 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 :(
« Last Edit: November 15, 2004, 11:20:01 am by cynikalsam »
Logged

Casper

  • VIP
  • Coppermine addict
  • ***
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 5231
Re: Different banner IF logged in
« Reply #11 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.
Logged
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

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 50
Re: Different banner IF logged in
« Reply #12 on: November 16, 2004, 02:48:06 pm »

That last method worked perfectly. Thank you! :)
Logged

Casper

  • VIP
  • Coppermine addict
  • ***
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 5231
Re: Different banner IF logged in
« Reply #13 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?
Logged
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
Pages: [1]   Go Up
 

Page created in 0.024 seconds with 20 queries.