forum.coppermine-gallery.net

No Support => Modifications/Add-Ons/Hacks => Mods: Visuals => Topic started by: Nibbler on December 23, 2005, 05:55:37 pm

Title: Category themes
Post by: Nibbler on December 23, 2005, 05:55:37 pm
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:

Code: [Select]
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:

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

Before that, add this code:

Code: [Select]
// 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 (http://forum.coppermine-gallery.net/index.php?topic=23578.0).
Title: Re: Category themes
Post by: Titooy on December 23, 2005, 06:31:53 pm
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...)

;)
Title: Re: Category themes
Post by: julala on December 23, 2005, 08:28:49 pm
Thanks Nibbler.  The mod is absolutely perfect for the task I needed.  :D
Title: Re: Category themes
Post by: lily64 on November 13, 2006, 10:02:55 pm
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.
Title: Re: Category themes
Post by: Nibbler on November 13, 2006, 10:09:31 pm
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.
Title: Re: Category themes
Post by: lily64 on November 14, 2006, 01:05:54 am
Thanks Nibbler

http://www.liveedgepottery.com/cpg149/index.php is the main page


Title: Re: Category themes
Post by: lily64 on November 14, 2006, 01:27:16 am
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
Title: Re: Category themes
Post by: lily64 on November 14, 2006, 01:53:43 am
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.  :)

Title: Re: Category themes
Post by: cottage on March 04, 2013, 01:38:03 pm
Does this mod also work in 1.5.22?

Title: Re: Category themes
Post by: Jeff Bailey on March 04, 2013, 09:05:26 pm
Most likey not, You can test it though.