Different themes for different albums? Different themes for different albums?
 

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 themes for different albums?

Started by davetd02, January 16, 2004, 09:40:21 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

davetd02

Is it possible (without diving too deep into PHP) to easily set a different theme for different albums?  I would like "Album X" to display in Theme X and "Album Y" to display in Theme Y.

Thanks a lot!

Dave

Joachim Müller


davetd02

THanks for the fast response.

If I were going to go ahead and hack the code, what general section would I need to hack?  I'm sure people have had this issue before.  I don't need a full tutorial (I'm sure it's a pretty simple if-then), but I don't know where to look to find where the theme is set.

Thanks!

Joachim Müller

files that are involved in displaying album content are thumbnail.php and displayimage.php, but I'd go for include/init.inc.php, since it's the place where the request vars are handled.
You can use the var that is handed over by the url ($album). A simple statement likeif ($_GET["album"] == '1' ) { $theme='whatever';}should do the trick...

GauGau

davetd02

That's exactly what I was looking for.

Thanks a lot!  You rock!

sintax

Where would I put that in the init.inc.php file?

I want to use a different theme (located in the directory "pocky") on any images in Category 4.

if ($_GET["cat"] == '4' ) { $theme='pocky';}

Is how I think it would go... but where I do I insert that into the init.inc.php file?

Nibbler

Put it in the gap at line 227, and you need to use $CONFIG['theme'] in place of $theme.

Casper

If you use the code you have;
if ($_GET["cat"] == '4' ) { $theme='pocky';}

This will work, but only on the category page, and pics in the meta albums on the page, but not on the actual album pages within the cat.

I got it to work this far by changing this;
if (!file_exists("themes/{$CONFIG['theme']}/theme.php")) $CONFIG['theme'] = 'default';
        require "themes/{$CONFIG['theme']}/theme.php";
        $THEME_DIR = "themes/{$CONFIG['theme']}/";


to this;
if ($_GET["cat"] == '15' ) { $theme='water drop';
        require "themes/water_drop/theme.php";
        $THEME_DIR = "themes/water_drop/";
} else {

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



I think you also need to add the album id's to the 'if' query.
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

sintax

I changed those three lines of my code to this:


if ($_GET["cat"] == '15' ) { $theme='pocky';
   require "themes/pocky/theme.php";
   $THEME_DIR = "themes/pocky/";
} else {

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


But am now getting the following error:


Parse error: parse error in /home/dizand2/public_html/gallery/include/init.inc.php on line 228

Fatal error: Call to undefined function: breadcrumb() in /home/dizand2/public_html/gallery/index.php on line 118


Any ideas?

sintax

#9
Just in case it will help anyone help me I figured I would post my code thus far:


<?php
// ------------------------------------------------------------------------- //
// Coppermine Photo Gallery 1.2.1                                            //
// ------------------------------------------------------------------------- //
// Copyright (C) 2002,2003 Gregory DEMAR                                     //
// http://www.chezgreg.net/coppermine/                                       //
// ------------------------------------------------------------------------- //
// Updated by the Coppermine Dev Team                                        //
// (http://coppermine.sf.net/team/)                                          //
// see /docs/credits.html for details                                        //
// ------------------------------------------------------------------------- //
// This program is free software; you can redistribute it and/or modify      //
// it under the terms of the GNU General Public License as published by      //
// the Free Software Foundation; either version 2 of the License, or         //
// (at your option) any later version.                                       //
// ------------------------------------------------------------------------- //
define('COPPERMINE_VERSION''1.2.1');
// User database integration
// Uncomment the applicable line if you want to use it
// define('UDB_INTEGRATION', 'phpbb');
// define('UDB_INTEGRATION', 'invisionboard');
// define('UDB_INTEGRATION', 'vbulletin');
// define('UDB_INTEGRATION', 'yabbse');
if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');
// Start output buffering
ob_start();
// Report all errors except E_NOTICE
// This is the default value set in php.ini
// error_reporting (E_ALL ^ E_NOTICE);
error_reporting(E_ALL);

set_magic_quotes_runtime(0);
// used for timing purpose
$query_stats = array();
$queries = array();
function 
getmicrotime()
{
    list(
$usec$sec) = explode(" "microtime());
    return ((float)
$usec + (float)$sec);
}
$time_start getmicrotime();
// Do some cleanup in GET, POST and cookie data and un-register global vars
$HTML_SUBST = array('"' => '&quot;''<' => '&lt;''>' => '&gt;');
if (
get_magic_quotes_gpc()) {
    if (
is_array($HTTP_POST_VARS)) {
        foreach (
$HTTP_POST_VARS as $key => $value) {
            if (!
is_array($value))
                
$HTTP_POST_VARS[$key] = strtr(stripslashes($value), $HTML_SUBST);
            if (isset($
$key)) unset($$key);
        }
    }

    if (
is_array($HTTP_GET_VARS)) {
        foreach (
$HTTP_GET_VARS as $key => $value) {
            
$HTTP_GET_VARS[$key] = strtr(stripslashes($value), $HTML_SUBST);
            if (isset($
$key)) unset($$key);
        }
    }

    if (
is_array($HTTP_COOKIE_VARS)) {
        foreach (
$HTTP_COOKIE_VARS as $key => $value) {
            if (!
is_array($value))
                
$HTTP_COOKIE_VARS[$key] = stripslashes($value);
            if (isset($
$key)) unset($$key);
        }
    }
} else {
    if (
is_array($HTTP_POST_VARS)) {
        foreach (
$HTTP_POST_VARS as $key => $value) {
            if (!
is_array($value))
                
$HTTP_POST_VARS[$key] = strtr($value$HTML_SUBST);
            if (isset($
$key)) unset($$key);
        }
    }

    if (
is_array($HTTP_GET_VARS)) {
        foreach (
$HTTP_GET_VARS as $key => $value) {
            
$HTTP_GET_VARS[$key] = strtr($value$HTML_SUBST);
            if (isset($
$key)) unset($$key);
        }
    }

    if (
is_array($HTTP_COOKIE_VARS)) {
        foreach (
$HTTP_COOKIE_VARS as $key => $value) {
            if (isset($
$key)) unset($$key);
        }
    }
}
// Initialise the $CONFIG array and some other variables
$CONFIG = array();
$PHP_SELF = isset($HTTP_SERVER_VARS['REDIRECT_URL']) ? $HTTP_SERVER_VARS['REDIRECT_URL'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
$REFERER urlencode($PHP_SELF . (isset($HTTP_SERVER_VARS['QUERY_STRING']) && $HTTP_SERVER_VARS['QUERY_STRING'] ? '?' $HTTP_SERVER_VARS['QUERY_STRING'] : ''));
$ALBUM_SET '';
$FORBIDDEN_SET '';
$CURRENT_CAT_NAME '';
$CAT_LIST '';
// Record User's IP address
$raw_ip stripslashes($HTTP_SERVER_VARS['REMOTE_ADDR']);

if (isset(
$HTTP_SERVER_VARS['HTTP_CLIENT_IP'])) {
    
$hdr_ip stripslashes($HTTP_SERVER_VARS['HTTP_CLIENT_IP']);
} else {
    if (isset(
$HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'])) {
        
$hdr_ip stripslashes($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']);
    } else {
        
$hdr_ip $raw_ip;
    }
}
// Define some constants
define('USER_GAL_CAT'1);
define('FIRST_USER_CAT'10000);
define('RANDPOS_MAX_PIC'200);
define('TEMPLATE_FILE''template.html');
// Constants used by the cpg_die function
define('INFORMATION'1);
define('ERROR'2);
define('CRITICAL_ERROR'3);

$IMG_TYPES = array(=> 'GIF',
    
=> 'JPG',
    
=> 'PNG',
    
=> 'SWF',
    
=> 'PSD',
    
=> 'BMP',
    
=> 'TIFF',
    
=> 'TIFF',
    
=> 'JPC',
    
10 => 'JP2',
    
11 => 'JPX',
    
12 => 'JB2',
    
13 => 'SWC',
    
14 => 'IFF'
    
);
// Include config and functions files
require 'include/config.inc.php';
require 
'include/functions.inc.php';

$CONFIG['TABLE_PICTURES'] = $CONFIG['TABLE_PREFIX'] . "pictures";
$CONFIG['TABLE_ALBUMS'] = $CONFIG['TABLE_PREFIX'] . "albums";
$CONFIG['TABLE_COMMENTS'] = $CONFIG['TABLE_PREFIX'] . "comments";
$CONFIG['TABLE_CATEGORIES'] = $CONFIG['TABLE_PREFIX'] . "categories";
$CONFIG['TABLE_CONFIG'] = $CONFIG['TABLE_PREFIX'] . "config";
$CONFIG['TABLE_USERGROUPS'] = $CONFIG['TABLE_PREFIX'] . "usergroups";
$CONFIG['TABLE_VOTES'] = $CONFIG['TABLE_PREFIX'] . "votes";
$CONFIG['TABLE_USERS'] = $CONFIG['TABLE_PREFIX'] . "users";
$CONFIG['TABLE_BANNED'] = $CONFIG['TABLE_PREFIX'] . "banned";
// User DB system
if (defined('UDB_INTEGRATION')) require 'bridge/' UDB_INTEGRATION '.inc.php';
// Connect to database
cpg_db_connect() || die("<b>Coppermine critical error</b>:<br />Unable to connect to database !<br /><br />MySQL said: <b>" mysql_error() . "</b>");
// Retrieve DB stored configuration
$results db_query("SELECT * FROM {$CONFIG['TABLE_CONFIG']}");
while (
$row mysql_fetch_array($results)) {
    
$CONFIG[$row['name']] = $row['value'];
// while
mysql_free_result($results);
// Set error logging level
if ($CONFIG['debug_mode']) {
    
error_reporting (E_ALL);
} else {
    
error_reporting (E_ALL E_NOTICE);
}
// Parse cookie stored user profile
user_get_profile();
// Authenticate
if (defined('UDB_INTEGRATION')) {
    
udb_authenticate();
} else {
    if (!isset(
$HTTP_COOKIE_VARS[$CONFIG['cookie_name'] . '_uid']) || !isset($HTTP_COOKIE_VARS[$CONFIG['cookie_name'] . '_pass'])) {
        
$cookie_uid 0;
        
$cookie_pass '*';
    } else {
        
$cookie_uid = (int)$HTTP_COOKIE_VARS[$CONFIG['cookie_name'] . '_uid'];
        
$cookie_pass substr(addslashes($HTTP_COOKIE_VARS[$CONFIG['cookie_name'] . '_pass']), 032);
    }

    
$sql "SELECT * " "FROM {$CONFIG['TABLE_USERS']}{$CONFIG['TABLE_USERGROUPS']} " "WHERE user_group = group_id " "AND user_id='$cookie_uid'" "AND user_active = 'YES' " "AND user_password != '' " "AND BINARY MD5(user_password) = '$cookie_pass'";
    
$results db_query($sql);

    if (
mysql_num_rows($results)) {
        
$USER_DATA mysql_fetch_array($results);
        unset(
$USER_DATA['user_password']);

        
define('USER_ID', (int)$USER_DATA['user_id']);
        
define('USER_NAME'$USER_DATA['user_name']);
        
define('USER_GROUP'$USER_DATA['group_name']);
        
define('USER_GROUP_SET''(' $USER_DATA['group_id'] . ($USER_DATA['user_lang'] != '' ',' $USER_DATA['user_lang'] : '') . ')');
        
define('USER_IS_ADMIN', (int)$USER_DATA['has_admin_access']);
        
define('USER_CAN_SEND_ECARDS', (int)$USER_DATA['can_send_ecards']);
        
define('USER_CAN_RATE_PICTURES', (int)$USER_DATA['can_rate_pictures']);
        
define('USER_CAN_POST_COMMENTS', (int)$USER_DATA['can_post_comments']);
        
define('USER_CAN_UPLOAD_PICTURES', (int)$USER_DATA['can_upload_pictures']);
        
define('USER_CAN_CREATE_ALBUMS', (int)$USER_DATA['can_create_albums']);
        
mysql_free_result($results);
    } else {
        
$results db_query("SELECT * FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_id = 3");
        if (!
mysql_num_rows($results)) die('<b>Coppermine critical error</b>:<br />The group table does not contain the Anonymous group !');
        
$USER_DATA mysql_fetch_array($results);
        
define('USER_ID'0);
        
define('USER_NAME''Anonymous');
        
define('USER_GROUP'$USER_DATA['group_name']);
        
define('USER_GROUP_SET''(' $USER_DATA['group_id'] . ')');
        
define('USER_IS_ADMIN'0);
        
define('USER_CAN_SEND_ECARDS', (int)$USER_DATA['can_send_ecards']);
        
define('USER_CAN_RATE_PICTURES', (int)$USER_DATA['can_rate_pictures']);
        
define('USER_CAN_POST_COMMENTS', (int)$USER_DATA['can_post_comments']);
        
define('USER_CAN_UPLOAD_PICTURES', (int)$USER_DATA['can_upload_pictures']);
        
define('USER_CAN_CREATE_ALBUMS'0);
        
mysql_free_result($results);
    }
}
// Test if admin mode
$USER['am'] = isset($USER['am']) ? (int)$USER['am'] : 0;
define('GALLERY_ADMIN_MODE'USER_IS_ADMIN && $USER['am']);
define('USER_ADMIN_MODE'USER_ID && USER_CAN_CREATE_ALBUMS && $USER['am'] && !GALLERY_ADMIN_MODE);
// Process theme selection if present in URI or in user profile
if (!empty($HTTP_GET_VARS['theme'])) {
    
$USER['theme'] = $HTTP_GET_VARS['theme'];
}
// Load theme file
if (isset($USER['theme']) && !strstr($USER['theme'], '/') && is_dir('themes/' $USER['theme'])) {
    
$CONFIG['theme'] = strtr($USER['theme'], '$/\\:*?"\'<>|`''____________');
} else {
    unset(
$USER['theme']);
}

if (
$_GET["cat"] == '15' ) { $theme='pocky'
   require 
"themes/pocky/theme.php"
   
$THEME_DIR "themes/pocky/"
} else { 

   if (!
file_exists("themes/{$CONFIG['theme']}/theme.php")) $CONFIG['theme'] = 'default'
   require 
"themes/{$CONFIG['theme']}/theme.php"
   
$THEME_DIR "themes/{$CONFIG['theme']}/"
}
// Process language selection if present in URI or in user profile or try
// autodetection if default charset is utf-8
if (!empty($HTTP_GET_VARS['lang'])) {
    
$USER['lang'] = $HTTP_GET_VARS['lang'];
}

if (isset(
$USER['lang']) && !strstr($USER['lang'], '/') && file_exists('lang/' $USER['lang'] . '.php')) {
    
$CONFIG['lang'] = strtr($USER['lang'], '$/\\:*?"\'<>|`''____________');
} elseif (
$CONFIG['charset'] == 'utf-8') {
    include(
'include/select_lang.inc.php');
    if (
file_exists('lang/' $USER['lang'] . '.php')) $CONFIG['lang'] = $USER['lang'];
} else {
    unset(
$USER['lang']);
}

if (!
file_exists("lang/{$CONFIG['lang']}.php")) $CONFIG['lang'] = 'english';
require 
"lang/{$CONFIG['lang']}.php";
// See if the fav cookie is set else set it
if (isset($HTTP_COOKIE_VARS[$CONFIG['cookie_name'] . '_fav'])) {
    
$FAVPICS = @unserialize(@base64_decode($HTTP_COOKIE_VARS[$CONFIG['cookie_name'] . '_fav']));
} else {
    
$FAVPICS = array();
}
// load the main template
load_template();
// Remove expired bans
$now time();
db_query("DELETE FROM {$CONFIG['TABLE_BANNED']} WHERE expiry < $now");
// Check if the user is banned
$user_id USER_ID;
$result db_query("SELECT * FROM {$CONFIG['TABLE_BANNED']} WHERE ip_addr='$raw_ip' OR ip_addr='$hdr_ip' OR user_id=$user_id");
if (
mysql_num_rows($result)) {
    
pageheader($lang_error);
    
msg_box($lang_info$lang_errors['banned']);
    
pagefooter();
    exit;
}
mysql_free_result($result);
// Retrieve the "private" album set
if (!GALLERY_ADMIN_MODE && $CONFIG['allow_private_albums']) get_private_album_set();

?>


sintax

Bump...

Anyone from the evening shift available to help?

Joachim Müller


Casper

ok,

change the cat number from '15' to the id of the one you want to change, and make sure the theme 'pocky' is spelt right and actually works.

Also remember, this will not work in the album pages, unless you add the album id's to the if function.
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

sintax

Quote from: "casper"ok,

change the cat number from '15' to the id of the one you want to change, and make sure the theme 'pocky' is spelt right and actually works.

Also remember, this will not work in the album pages, unless you add the album id's to the if function.

Casper... man you rock!
OK, can I ask one last favor? I want to add Album 10 for example... how do I do that? My code (snippit) looks like this so far:


if ($_GET["cat"] == '4' ) { $theme='pocky';
   require "themes/pocky/theme.php";
   $THEME_DIR = "themes/pocky/";
} else {

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


UPDATE:

Getting Errors now... Tried modifying the code to work with Album 10 but it isn't working.


if ($_GET["cat"] == '4' ) { $theme='pocky';
   require "themes/pocky/theme.php";
   $THEME_DIR = "themes/pocky/";
if ($_GET["album"] == '10' ) { $theme='pocky';
   require "themes/pocky/theme.php";
   $THEME_DIR = "themes/pocky/";
   }
}
else {

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

Casper

OK, done it.

Go back to your first code;
if ($_GET["cat"] == '4' ) { $theme='pocky';
   require "themes/pocky/theme.php";
   $THEME_DIR = "themes/pocky/";
} else {

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


and change this;
($_GET["cat"] == '4' )

to this;
(($_GET["cat"] == '4') OR ($_GET["album"] == '10'))
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

Nibbler

You've nested the second if inside the first if, make sure the {} are in the right places.

Probably better to just combine the 2:


if ($_GET["cat"] == '4' || $_GET["album"] == '10' ) {

   $theme='pocky';
   require "themes/pocky/theme.php";
   $THEME_DIR = "themes/pocky/";

} else {

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

Casper

hi nibbler,

I'm just learning code myself.  I see you did this;

($_GET["cat"] == '4' || $_GET["album"] == '10' )

where I did this;

(($_GET["cat"] == '4') OR ($_GET["album"] == '10'))

So my question is, does this '||' do the same as 'OR'.  

And just what key do you type to get '|'  :oops:
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

sintax

couldn't get either to work and then just deleted the file and started with a fresh one.... VIOLA!

Thanks both of you for the help. Is one suggestion better then the other? And if I want to add another album later on , do I just do something like this?

((($_GET["cat"] == '4') OR ($_GET["album"] == '10') OR ($_GET["album"] == '11')))

Or would the other suggestion with the "||" be better for when I wanted to add another album to it?

Nibbler

Yeah, just use OR or || to combine them together, in this case it doesnt matter which you use.

Casper

Glad you got it to work  :wink:

What you put would work, but I suspect Nibblers method is the more professional one, and will save on brackets.
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