Category themes Category themes
 

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]

Main Menu

Category themes

Started by Nibbler, December 23, 2005, 05:55:37 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Nibbler

This mod allows you to set different themes for different categories. Any albums or pics viewed inside that category will be displayed in the specified theme.

There are 3 parts to this mod.

1) You need to add a new field into your database:

ALTER TABLE `cpg_categories` ADD `cat_theme` VARCHAR( 32 ) NOT NULL ;

Run that query in phpmyadmin or whatever you like to use. Change cpg_ to the actual prefix you chose during installation.

2) Edit include/init.inc.php

find:

// Process theme selection if present in URI or in user profile
if (!empty($_GET['theme'])) {
    $USER['theme'] = $_GET['theme'];
}


Before that, add this code:

// Process category specific themes
$cid = 0;
if (isset($_GET['cat'])){
$cid = (int) $_GET['cat'];
} elseif (isset($_GET['album'])){
$aid = (int) $_GET['album'];
$result = cpg_db_query("SELECT category FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '$aid' LIMIT 1");
if (mysql_num_rows($result)) list($cid) = mysql_fetch_row($result);
} elseif (isset($_GET['pos'])){
$pid = (int) -$_GET['pos'];
$result = cpg_db_query("SELECT category FROM {$CONFIG['TABLE_ALBUMS']} AS a INNER JOIN {$CONFIG['TABLE_PICTURES']} AS p ON p.aid = a.aid WHERE pid = '$pid' LIMIT 1");
if (mysql_num_rows($result)) list($cid) = mysql_fetch_row($result);
} elseif (isset($_GET['id'])){
$pid = (int) $_GET['id'];
$result = cpg_db_query("SELECT category FROM {$CONFIG['TABLE_ALBUMS']} AS a INNER JOIN {$CONFIG['TABLE_PICTURES']} AS p ON p.aid = a.aid WHERE pid = '$pid' LIMIT 1");
if (mysql_num_rows($result)) list($cid) = mysql_fetch_row($result);
}

if ($cid){
$result = cpg_db_query("SELECT cat_theme FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '$cid' LIMIT 1");
if (mysql_num_rows($result)) list($CONFIG['theme']) = mysql_fetch_row($result);
}


3) Update the category manager to provide the new option.

Since the changes here are numerous, I have attached a pre-modded catmgr.php. Download it from this post, extract it, and overwrite your existing catmgr.php.

This mod kindly sponsored by julala.

Titooy

http://forum.coppermine-gallery.net/index.php?topic=22781.0

My mod has some more features :
- it works for all the subcats
- by default it doesn't put a theme for each cat so you can still change the main theme (in yours, every cat has a theme so changing the main theme doesn't change much...)

;)

julala

Thanks Nibbler.  The mod is absolutely perfect for the task I needed.  :D

lily64

I tried using this mod and though I set it  up exactly as shown, I get no changes whatsoever after choosing a new theme.  I added the field to the db, changed the file init.inc.php, created new templates, uploaded them and uploaded the catmgr.php as well.  Since all I really want is the header image to change, I went into each new template, changed the site_logo.png for each template.

Any ideas why it won't change to a new template?  I even tried changing it to another template, one that I did not create, just one of the standard templates that comes with it and those won't work either.

Thanks in advance for any ideas.

Nibbler

Post a link to your gallery with debug mode enabled or post the debug output when viewing a category that is supposed to have a special theme.

lily64


lily64

Sorry this is a link to a specific category that is supposed to have a different theme.

http://www.liveedgepottery.com/cpg149/thumbnails.php?album=1

lily64

Ok got it figured out.  The catmgr.php had not overwritten the old one.  Thanks much for your assistance.  Now to go on to another topic.  :)


cottage

Does this mod also work in 1.5.22?


Jeff Bailey

Most likey not, You can test it though.
Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford