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: Category themes  (Read 20548 times)

0 Members and 1 Guest are viewing this topic.

Nibbler

  • Guest
Category themes
« 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.
Logged

Titooy

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Posts: 736
    • under construction...
Re: Category themes
« Reply #1 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...)

;)
Logged

julala

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Gender: Female
  • Posts: 55
    • Smileonthetiles
Re: Category themes
« Reply #2 on: December 23, 2005, 08:28:49 pm »

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

lily64

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: Category themes
« Reply #3 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.
Logged

Nibbler

  • Guest
Re: Category themes
« Reply #4 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.
Logged

lily64

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: Category themes
« Reply #5 on: November 14, 2006, 01:05:54 am »

Logged

lily64

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: Category themes
« Reply #6 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
Logged

lily64

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: Category themes
« Reply #7 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.  :)

Logged

cottage

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 22
Re: Category themes
« Reply #8 on: March 04, 2013, 01:38:03 pm »

Does this mod also work in 1.5.22?

Logged

Jeff Bailey

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1322
  • Fishing relaxes me.
    • Bailey Family Co.
Re: Category themes
« Reply #9 on: March 04, 2013, 09:05:26 pm »

Most likey not, You can test it though.
Logged
Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford
Pages: [1]   Go Up
 

Page created in 0.021 seconds with 20 queries.