This mod allows you to choose another theme for a category. Like all modern board software. It's based on 1.4.1 cvs.
Add a theme field to your "categories" table.
<coppermine>/include/init.inc.php
Find
// Process theme selection if present in URI or in user profile
if (!empty($_GET['theme'])) {
$USER['theme'] = $_GET['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 you don't want people to be able to choose another theme than the on you chose, remove it or comment it out.
Add before
// Looks if there's a sub-theme for that category
if (!empty($_GET['cat'])) {
$result = cpg_db_query("SELECT parent,theme FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '{$_GET['cat']}'");
$row = mysql_fetch_array($result);
if (!empty($row['theme']) && !isset($theme_temp))
$theme_temp = $row['theme'];
mysql_free_result($result);
while($row['parent'] != 0)
{
$result = cpg_db_query("SELECT parent,theme FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '{$row['parent']}'");
$row = mysql_fetch_array($result);
mysql_free_result($result);
if (isset($row['theme']) && !isset($theme_temp))
$theme_temp = $row['theme'];
} // while
if (isset($theme_temp))
$CONFIG['theme'] = $theme_temp;
}
// Looks if there's a sub-theme for that album
if (!empty($_GET['album'])) {
$result = cpg_db_query("SELECT category FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '{$_GET['album']}'");
$row = mysql_fetch_array($result);
mysql_free_result($result);
$row['parent'] = $row['category'];
while($row['parent'] != 0)
{
$result = cpg_db_query("SELECT parent,theme FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '{$row['parent']}'");
$row = mysql_fetch_array($result);
mysql_free_result($result);
if (isset($row['theme']) && !isset($theme_temp))
$theme_temp = $row['theme'];
} // while
if (isset($theme_temp))
$CONFIG['theme'] = $theme_temp;
}
<coppermine>/catmgr.php
Find
function display_cat_list() {
Add before
function form_sub_theme() {
global $CONFIG, $lang_catmgr_php, $current_category;
$theme_dir = 'themes/';
$dir = opendir($theme_dir);
while ($file = readdir($dir)) {
if (is_dir($theme_dir . $file) && $file != "." && $file != "..") {
$theme_array[] = $file;
}
}
closedir($dir);
natcasesort($theme_array);
echo <<<EOT
<tr>
<td class="tableb" width="60%">
{$lang_catmgr_php['cat_theme']}
</td>
<td class="tableb" valign="top">
<select name="theme" class="listbox">
EOT;
echo " <option value=\"\"></option>\n";
foreach ($theme_array as $theme) {
echo " <option value=\"$theme\" " . ($theme == $current_category['theme'] ? 'selected="selected"' : '') . ">" . strtr(ucfirst($theme), '_', ' ') . "</option>\n";
}
echo <<<EOT
</select>
</td>
</tr>
EOT;
}
Find
$current_category = array('cid' => '0', 'name' => '', 'parent' => '0', 'description' => '');
Change to
$current_category = array('cid' => '0', 'name' => '', 'parent' => '0', 'description' => '', 'theme' => '');
Find
$result = cpg_db_query("SELECT cid, name, parent, description, thumb FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '$cid' LIMIT 1");
Change to
$result = cpg_db_query("SELECT cid, name, parent, description, thumb, theme FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '$cid' LIMIT 1");
Find twice
if (!isset($_POST['cid']) || !isset($_POST['parent']) || !isset($_POST['name']) || !isset($_POST['description']))
Change to
if (!isset($_POST['cid']) || !isset($_POST['parent']) || !isset($_POST['name']) || !isset($_POST['description']) || !isset($_POST['theme']))
Find twice
$description = addslashes($_POST['description']);
Add after
$theme = addslashes($_POST['theme']);
Find
cpg_db_query("UPDATE {$CONFIG['TABLE_CATEGORIES']} SET parent='$parent', name='$name', description='$description', thumb='$thumb' WHERE cid = '$cid' LIMIT 1");
}else{
cpg_db_query("UPDATE {$CONFIG['TABLE_CATEGORIES']} SET name='$name', description='$description', thumb='$thumb' WHERE cid = '$cid' LIMIT 1");
Change to
cpg_db_query("UPDATE {$CONFIG['TABLE_CATEGORIES']} SET parent='$parent', name='$name', description='$description', thumb='$thumb', theme='$theme' WHERE cid = '$cid' LIMIT 1");
}else{
cpg_db_query("UPDATE {$CONFIG['TABLE_CATEGORIES']} SET name='$name', description='$description', thumb='$thumb', theme='$theme' WHERE cid = '$cid' LIMIT 1");
Find
cpg_db_query("INSERT INTO {$CONFIG['TABLE_CATEGORIES']} (pos, parent, name, description) VALUES ('10000', '$parent', '$name', '$description')");
Change to
cpg_db_query("INSERT INTO {$CONFIG['TABLE_CATEGORIES']} (pos, parent, name, description, theme) VALUES ('10000', '$parent', '$name', '$description', '$theme')");
Find
form_alb_thumb();
Add before
form_sub_theme();
<coppermine>/lang/<your_language>.php (and all the languages used by administrators)
Find
'cat_desc' => 'Category description',
Add after
'cat_theme' => 'Category theme',
(italic to be translated)
That's it!