Hi all,
im using the mac osx theme, and i only have one thing that i need to change. When someone clicks lets say category "pictures" they will get this view
(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fhem.bredband.net%2Fb215244%2Fcategory_album_view.jpg&hash=49471dd11e6585e3db71dda818853bd8f584d1c4)
this looks good, but i have way to many pictures on my gallery to have statistics enabled, and when i remove the statistics code
SELECT a.aid, count( p.pid ) AS pic_count, max( p.pid ) AS last_pid, max( p.ctime ) AS last_upload, a.keyword FROM cpg147_albums AS a LEFT JOIN cpg147_pictures AS p ON a.aid = p.aid AND p.approved = 'YES' WHERE a.aid IN (4, 3, 5, 6, 7, 8, 9, 10, 11, 12, 17)GROUP BY a.aid
the thumbnails for the albums are gone, and it ends up looking bad. So what i wanted to do is to remove everything but the album name and ofcourse remove the space between that was saved for the thumbnail so it looks real good.
my guess is that its this code i need to modify to get that result, but how to actually do that i need expert help!
- // Function to display first level Albums of a category
function theme_display_album_list_cat(&$alb_list, $nbAlb, $cat, $page, $total_pages)
{
global $CONFIG, $STATS_IN_ALB_LIST, $statistics, $template_tab_display, $template_album_list_cat, $lang_album_list;
if (!$CONFIG['first_level']) {
return;
}
$theme_alb_list_tab_tmpl = $template_tab_display;
$theme_alb_list_tab_tmpl['left_text'] = strtr($theme_alb_list_tab_tmpl['left_text'], array('{LEFT_TEXT}' => $lang_album_list['album_on_page']));
$theme_alb_list_tab_tmpl['inactive_tab'] = strtr($theme_alb_list_tab_tmpl['inactive_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&page=%d'));
$tabs = create_tabs($nbAlb, $page, $total_pages, $theme_alb_list_tab_tmpl);
// echo $template_album_list_cat;
$template_album_list_cat1 = $template_album_list_cat;
$album_cell = template_extract_block($template_album_list_cat1, 'c_album_cell');
$empty_cell = template_extract_block($template_album_list_cat1, 'c_empty_cell');
$tabs_row = template_extract_block($template_album_list_cat1, 'c_tabs');
$stat_row = template_extract_block($template_album_list_cat1, 'c_stat_row');
$spacer = template_extract_block($template_album_list_cat1, 'c_spacer');
$header = template_extract_block($template_album_list_cat1, 'c_header');
$footer = template_extract_block($template_album_list_cat1, 'c_footer');
$rows_separator = template_extract_block($template_album_list_cat1, 'c_row_separator');
$count = 0;
$columns = $CONFIG['album_list_cols'];
$column_width = ceil(100 / $columns);
$thumb_cell_width = $CONFIG['alb_list_thumb_size'] + 2;
starttable('100%');
if ($STATS_IN_ALB_LIST) {
$params = array('{STATISTICS}' => $statistics,
'{COLUMNS}' => $columns,
);
echo template_eval($stat_row, $params);
}
echo $header;
if (is_array($alb_list)) {
foreach($alb_list as $album) {
$count ++;
$params = array('{COL_WIDTH}' => $column_width,
'{ALBUM_TITLE}' => $album['album_title'],
'{THUMB_CELL_WIDTH}' => $thumb_cell_width,
'{ALB_LINK_TGT}' => "thumbnails.php?album={$album['aid']}",
'{ALB_LINK_PIC}' => $album['thumb_pic'],
'{ADMIN_MENU}' => $album['album_adm_menu'],
'{ALB_DESC}' => $album['album_desc'],
'{ALB_INFOS}' => $album['album_info'],
);
echo template_eval($album_cell, $params);
if ($count % $columns == 0 && $count < count($alb_list)) {
echo $rows_separator;
}
}
}
$params = array('{COL_WIDTH}' => $column_width,
'{SPACER}' => $thumb_cell_width
);
$empty_cell = template_eval($empty_cell, $params);
while ($count++ % $columns != 0) {
echo $empty_cell;
}
echo $footer;
// Tab display
$params = array('{COLUMNS}' => $columns,
'{TABS}' => $tabs,
);
echo template_eval($tabs_row, $params);
endtable();
echo $spacer;
}
function theme_display_thumbnails(&$thumb_list, $nbThumb, $album_name, $aid, $cat, $page, $total_pages, $sort_options, $display_tabs, $mode = 'thumb')
{
global $CONFIG;
global $template_thumb_view_title_row,$template_fav_thumb_view_title_row, $lang_thumb_view, $template_tab_display, $template_thumbnail_view, $lang_album_list;
static $header = '';
static $thumb_cell = '';
static $empty_cell = '';
static $row_separator = '';
static $footer = '';
static $tabs = '';
static $spacer = '';
if ($header == '') {
$thumb_cell = template_extract_block($template_thumbnail_view, 'thumb_cell');
$tabs = template_extract_block($template_thumbnail_view, 'tabs');
$header = template_extract_block($template_thumbnail_view, 'header');
$empty_cell = template_extract_block($template_thumbnail_view, 'empty_cell');
$row_separator = template_extract_block($template_thumbnail_view, 'row_separator');
$footer = template_extract_block($template_thumbnail_view, 'footer');
$spacer = template_extract_block($template_thumbnail_view, 'spacer');
}
$cat_link = is_numeric($aid) ? '' : '&cat=' . $cat;
$uid_link = (isset($_GET['uid']) && is_numeric($_GET['uid'])) ? '&uid=' . $_GET['uid'] : '';
$theme_thumb_tab_tmpl = $template_tab_display;
if ($mode == 'thumb') {
$theme_thumb_tab_tmpl['left_text'] = strtr($theme_thumb_tab_tmpl['left_text'], array('{LEFT_TEXT}' => $aid == 'lastalb' ? $lang_album_list['album_on_page'] : $lang_thumb_view['pic_on_page']));
$theme_thumb_tab_tmpl['inactive_tab'] = strtr($theme_thumb_tab_tmpl['inactive_tab'], array('{LINK}' => 'thumbnails.php?album=' . $aid . $cat_link . '&page=%d'));
$theme_thumb_tab_tmpl['inactive_next_tab'] = strtr($theme_thumb_tab_tmpl['inactive_next_tab'], array('{LINK}' => 'thumbnails.php?album=' . $aid . $cat_link . '&page=%d'));
$theme_thumb_tab_tmpl['inactive_prev_tab'] = strtr($theme_thumb_tab_tmpl['inactive_prev_tab'], array('{LINK}' => 'thumbnails.php?album=' . $aid . $cat_link . '&page=%d'));
} else {
$theme_thumb_tab_tmpl['left_text'] = strtr($theme_thumb_tab_tmpl['left_text'], array('{LEFT_TEXT}' => $lang_thumb_view['user_on_page']));
$theme_thumb_tab_tmpl['inactive_tab'] = strtr($theme_thumb_tab_tmpl['inactive_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&page=%d'));
$theme_thumb_tab_tmpl['inactive_next_tab'] = strtr($theme_thumb_tab_tmpl['inactive_next_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&page=%d'));
$theme_thumb_tab_tmpl['inactive_prev_tab'] = strtr($theme_thumb_tab_tmpl['inactive_prev_tab'], array('{LINK}' => 'index.php?cat=' . $cat . '&page=%d'));
}
$thumbcols = $CONFIG['thumbcols'];
$cell_width = ceil(100 / $CONFIG['thumbcols']) . '%';
$tabs_html = $display_tabs ? create_tabs($nbThumb, $page, $total_pages, $theme_thumb_tab_tmpl) : '';
// The sort order options are not available for meta albums
if ($sort_options) {
$param = array('{ALBUM_NAME}' => $album_name,
'{AID}' => $aid,
'{PAGE}' => $page,
'{NAME}' => $lang_thumb_view['name'],
'{TITLE}' => $lang_thumb_view['title'],
'{DATE}' => $lang_thumb_view['date'],
'{SORT_TA}' => $lang_thumb_view['sort_ta'],
'{SORT_TD}' => $lang_thumb_view['sort_td'],
'{SORT_NA}' => $lang_thumb_view['sort_na'],
'{SORT_ND}' => $lang_thumb_view['sort_nd'],
'{SORT_DA}' => $lang_thumb_view['sort_da'],
'{SORT_DD}' => $lang_thumb_view['sort_dd'],
'{POSITION}' => $lang_thumb_view['position'],
'{SORT_PA}' => $lang_thumb_view['sort_pa'],
'{SORT_PD}' => $lang_thumb_view['sort_pd'],
);
$title = template_eval($template_thumb_view_title_row, $param);
} else if ($aid == 'favpics' && $CONFIG['enable_zipdownload'] == 1) { //Lots of stuff can be added here later
$param = array('{ALBUM_NAME}' => $album_name,
'{DOWNLOAD_ZIP}'=>$lang_thumb_view['download_zip']
);
$title = template_eval($template_fav_thumb_view_title_row, $param);
}else{
$title = $album_name;
}
if ($mode == 'thumb') {
starttable('100%', $title, $thumbcols);
} else {
starttable('100%');
}
echo $header;
$i = 0;
foreach($thumb_list as $thumb) {
$i++;
if ($mode == 'thumb') {
if ($aid == 'lastalb') {
$params = array('{CELL_WIDTH}' => $cell_width,
'{LINK_TGT}' => "thumbnails.php?album={$thumb['aid']}",
'{THUMB}' => $thumb['image'],
'{CAPTION}' => $thumb['caption'],
'{ADMIN_MENU}' => $thumb['admin_menu']
);
} else {
$params = array('{CELL_WIDTH}' => $cell_width,
'{LINK_TGT}' => "displayimage.php?album=$aid$cat_link&pos={$thumb['pos']}",
'{THUMB}' => $thumb['image'],
'{CAPTION}' => $thumb['caption'],
'{ADMIN_MENU}' => $thumb['admin_menu']
);
}
} else {
$params = array('{CELL_WIDTH}' => $cell_width,
'{LINK_TGT}' => "index.php?cat={$thumb['cat']}",
'{THUMB}' => $thumb['image'],
'{CAPTION}' => $thumb['caption'],
'{ADMIN_MENU}' => ''
);
}
echo template_eval($thumb_cell, $params);
if ((($i % $thumbcols) == 0) && ($i < count($thumb_list))) {
echo $row_separator;
}
}
for (;($i % $thumbcols); $i++) {
echo $empty_cell;
}
echo $footer;
if ($display_tabs) {
$params = array('{THUMB_COLS}' => $thumbcols,
'{TABS}' => $tabs_html
);
echo template_eval($tabs, $params);
}
endtable();
echo $spacer;
}
the code above is probably wrong, the code that needs to be changed is probably the one in index.php
- /**
* list_cat_albums()
*
* This has been added to list the albums in a category, used for showing first level albumslargely a repetition of code elsewhere
* Redone for a cleaner approach
* @param integer $cat Category id for which albums are needed
*/
function list_cat_albums($cat = 0)
{
global $CONFIG, $USER, $lastup_date_fmt, $USER_DATA, $FORBIDDEN_SET, $FORBIDDEN_SET_DATA, $cpg_show_private_album;
global $lang_list_albums, $lang_errors;
$PAGE = 1;
if ($cat == 0) {
return '';
}
$cat_owner_id = ($cat > 10000)?(10000 - $cat):(10001);
$cpg_nopic_data = cpg_get_system_thumb('nopic.jpg', $cat_owner_id);
$cpg_privatepic_data = cpg_get_system_thumb('private.jpg', $cat_owner_id);
$alb_per_page = $CONFIG['albums_per_page'];
$maxTab = $CONFIG['max_tabs'];
$album_filter = '';
$pic_filter = '';
if (!empty($FORBIDDEN_SET) && !$cpg_show_private_album) {
$album_filter = ' and ' . str_replace('p.', 'a.', $FORBIDDEN_SET);
$pic_filter = ' and ' . $FORBIDDEN_SET;
}
$sql = "SELECT count(*) FROM {$CONFIG['TABLE_ALBUMS']} as a WHERE category = '$cat'" . $album_filter;
$result = cpg_db_query($sql);
$nbEnr = mysql_fetch_array($result);
$nbAlb = $nbEnr[0];
mysql_free_result($result);
if ($nbAlb == 0) {
return;
}
$totalPages = ceil($nbAlb / $alb_per_page);
if ($PAGE > $totalPages) $PAGE = 1;
$lower_limit = ($PAGE-1) * $alb_per_page;
$upper_limit = min($nbAlb, $PAGE * $alb_per_page);
$limit = "LIMIT " . $lower_limit . "," . ($upper_limit - $lower_limit);
$sql = 'SELECT a.aid, a.title, a.description, visibility, filepath, ' . 'filename, url_prefix, pwidth, pheight ' . 'FROM ' . $CONFIG['TABLE_ALBUMS'] . ' as a ' . 'LEFT JOIN ' . $CONFIG['TABLE_PICTURES'] . ' as p ' . 'ON a.thumb=p.pid ' . 'WHERE category=' . $cat . $album_filter . ' ORDER BY a.pos ' . $limit;
$alb_thumbs_q = cpg_db_query($sql);
$alb_thumbs = cpg_db_fetch_rowset($alb_thumbs_q);
mysql_free_result($alb_thumbs_q);
$disp_album_count = count($alb_thumbs);
$album_set = '';
foreach($alb_thumbs as $value) {
$album_set .= $value['aid'] . ', ';
}
$album_set = '(' . substr($album_set, 0, -2) . ')';
/*$sql = "SELECT aid, count(pid) as pic_count, max(pid) as last_pid, max(ctime) as last_upload " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE aid IN $album_set AND approved = 'YES' " . "GROUP BY aid";
$alb_stats_q = cpg_db_query($sql);
$alb_stats = cpg_db_fetch_rowset($alb_stats_q);
mysql_free_result($alb_stats_q);*/
//This query will fetch album stats and keyword for the albums
$sql = "SELECT a.aid, count( p.pid ) AS pic_count, max( p.pid ) AS last_pid, max( p.ctime ) AS last_upload, a.keyword" .
" FROM {$CONFIG['TABLE_ALBUMS']} AS a " .
" LEFT JOIN {$CONFIG['TABLE_PICTURES']} AS p ON a.aid = p.aid AND p.approved = 'YES' ".
"WHERE a.aid IN $album_set" . "GROUP BY a.aid";
$alb_stats_q = cpg_db_query($sql);
$alb_stats = cpg_db_fetch_rowset($alb_stats_q);
mysql_free_result($alb_stats_q);
foreach($alb_stats as $key => $value) {
$cross_ref[$value['aid']] = &$alb_stats[$key];
if ($CONFIG['link_pic_count'] == 1) {
if (!empty($value['keyword'])) {
$query = "SELECT count(pid) AS link_pic_count
FROM {$CONFIG['TABLE_PICTURES']}
WHERE aid != {$value['aid']} AND
keywords LIKE '%{$value['keyword']}%' AND
approved = 'YES'";
$result = cpg_db_query($query);
$link_stat = mysql_fetch_array ($result);
mysql_free_result($result);
$alb_stats[$key]['link_pic_count'] = $link_stat['link_pic_count'];
}
}
}
for ($alb_idx = 0; $alb_idx < $disp_album_count; $alb_idx++) {
$alb_thumb = &$alb_thumbs[$alb_idx];
$aid = $alb_thumb['aid'];
if (isset($cross_ref[$aid])) {
$alb_stat = $cross_ref[$aid];
$count = $alb_stat['pic_count'];
} else {
$alb_stat = array();
$count = 0;
}
// Inserts a thumbnail if the album contains 1 or more images
$visibility = $alb_thumb['visibility'];
if (!in_array($aid,$FORBIDDEN_SET_DATA) || $CONFIG['allow_private_albums'] == 0) { //test for visibility
if ($count > 0) { // Inserts a thumbnail if the album contains 1 or more images
if ($alb_thumb['filename']) {
$picture = &$alb_thumb;
} else {
$sql = "SELECT filepath, filename, url_prefix, pwidth, pheight " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE pid='{$alb_stat['last_pid']}'";
$result = cpg_db_query($sql);
$picture = mysql_fetch_array($result);
mysql_free_result($result);
}
$pic_url = get_pic_url($picture, 'thumb');
if (!is_image($picture['filename'])) {
$image_info = getimagesize(urldecode($pic_url));
$picture['pwidth'] = $image_info[0];
$picture['pheight'] = $image_info[1];
}
$image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $CONFIG['alb_list_thumb_size']);
$alb_list[$alb_idx]['thumb_pic'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$picture['filename']}\" />";
} else { // Inserts an empty thumbnail if the album contains 0 images
// $image_size = compute_img_size(100, 75, $CONFIG['alb_list_thumb_size']);
$alb_list[$alb_idx]['thumb_pic'] = '<img src="' . $cpg_nopic_data['thumb'] . '" ' . $cpg_nopic_data['whole'] . ' class="image" border="0" alt="" />';
}
} elseif ($CONFIG['show_private']) {
// $image_size = compute_img_size(100, 75, $CONFIG['alb_list_thumb_size']);
$alb_list[$alb_idx]['thumb_pic'] = '<img src="' . $cpg_privatepic_data['thumb'] . '" ' . $cpg_privatepic_data['whole'] . ' class="image" border="0" alt="" />';
}
// Prepare everything
if (!in_array($aid,$FORBIDDEN_SET_DATA) || $CONFIG['allow_private_albums'] == 0) {
$last_upload_date = $count ? localised_date($alb_stat['last_upload'], $lastup_date_fmt) : '';
$link_pic_count = !empty($alb_stat['link_pic_count']) ? $alb_stat['link_pic_count'] : 0;
$alb_list[$alb_idx]['aid'] = $alb_thumb['aid'];
$alb_list[$alb_idx]['album_title'] = $alb_thumb['title'];
$alb_list[$alb_idx]['album_desc'] = bb_decode($alb_thumb['description']);
$alb_list[$alb_idx]['pic_count'] = $count;
$alb_list[$alb_idx]['last_upl'] = $last_upload_date;
$alb_list[$alb_idx]['album_info'] = sprintf($lang_list_albums['n_pictures'], $count) . ($count ? sprintf($lang_list_albums['last_added'], $last_upload_date) : "") . (($CONFIG['link_pic_count'] && $link_pic_count > 0) ? sprintf(", {$lang_list_albums['n_link_pictures']}, {$lang_list_albums['total_pictures']}", $link_pic_count, $count + $link_pic_count) : "");
$alb_list[$alb_idx]['album_adm_menu'] = (GALLERY_ADMIN_MODE || (USER_ADMIN_MODE && $cat == USER_ID + FIRST_USER_CAT)) ? html_albummenu($alb_thumb['aid']) : '';
} elseif ($CONFIG['show_private']) { // uncomment this else block to show private album description
$last_upload_date = $count ? localised_date($alb_stat['last_upload'], $lastup_date_fmt) : '';
$link_pic_count = !empty($alb_stat['link_pic_count']) ? $alb_stat['link_pic_count'] : 0;
$alb_list[$alb_idx]['aid'] = $alb_thumb['aid'];
$alb_list[$alb_idx]['album_title'] = $alb_thumb['title'];
$alb_list[$alb_idx]['album_desc'] = bb_decode($alb_thumb['description']);
$alb_list[$alb_idx]['pic_count'] = $count;
$alb_list[$alb_idx]['last_upl'] = $last_upload_date;
$alb_list[$alb_idx]['album_info'] = sprintf($lang_list_albums['n_pictures'], $count) . ($count ? sprintf($lang_list_albums['last_added'], $last_upload_date) : "") . (($CONFIG['link_pic_count'] && $link_pic_count > 0 )? sprintf(", {$lang_list_albums['n_link_pictures']}, {$lang_list_albums['total_pictures']}", $link_pic_count, $count + $link_pic_count) : "");
$alb_list[$alb_idx]['album_adm_menu'] = (GALLERY_ADMIN_MODE || (USER_ADMIN_MODE && $cat == USER_ID + FIRST_USER_CAT)) ? html_albummenu($alb_thumb['aid']) : '';
}
}
ob_start();
theme_display_album_list_cat($alb_list, $nbAlb, $cat, $PAGE, $totalPages);
$cat_albums = ob_get_contents();
ob_end_clean();
return $cat_albums;
}
Are you just trying to remove the Statistics from the page? You're explaination is rather cumbersome and hard to follow but check out this post and see if it's what you want - http://forum.coppermine-gallery.net/index.php?topic=32833.0 (http://forum.coppermine-gallery.net/index.php?topic=32833.0).
Please use the "insert code" tags when you want to paste code into a post. It's the second row of icons and has the "#" sign on it. Also, it's hard to see your photo so attach it next time with a larger one. You do this under the "Additional Options" below the post window.
its hard to explain why i would like to remove the thumbnails, maybe there is another way. The problem i have is that my index.php is loading rather slowly. Im down to 3.7 seconds now but there is one thing that bothers me and its taking up 2.2 seconds of that time. If i check the debug its this code:
[21] => SELECT a.aid, count( p.pid ) AS pic_count, max( p.pid ) AS last_pid, max( p.ctime ) AS last_upload, a.keyword FROM cpg147_albums AS a LEFT JOIN cpg147_pictures AS p ON a.aid = p.aid AND p.approved = 'YES' WHERE a.aid IN (4, 3, 5, 6, 7, 8, 9, 10, 11, 12, 17)GROUP BY a.aid (2.191s)
so i disabled that from loading by putting /* */ on this part of the code in index.php (2 places)
//This query will fetch album stats and keyword for the albums
$sql = "SELECT a.aid, count( p.pid ) AS pic_count, max( p.pid ) AS last_pid, max( p.ctime ) AS last_upload, a.keyword" .
" FROM {$CONFIG['TABLE_ALBUMS']} AS a " .
" LEFT JOIN {$CONFIG['TABLE_PICTURES']} AS p ON a.aid = p.aid AND p.approved = 'YES' ".
"WHERE a.aid IN $album_set" . "GROUP BY a.aid";
$alb_stats_q = cpg_db_query($sql);
$alb_stats = cpg_db_fetch_rowset($alb_stats_q);
mysql_free_result($alb_stats_q);
this does remove the loading time, but also it removes my thumbnails on my albums, and all the albums seem "empty" with 0 files reported, but once you click em they are still there. So i wanted to modify the look of the albumlist cause of this. But if there is another way (maybe buy modifying the code i disabeled and only disable the parts that causing the long load time) i would clearly like to do that insted, i just though it would be much more simple to modify the theme.
Thanks for your help!
OK... now we're getting to the bottom of your request. You are now saying you have a slow load time and you tried to fix it my editing the code. This is not my area of expertise in CPG (well... none is for that fact...) but you mentioned in your first post that you have a lot of pictures and albums in your gallery. On your main page, are you loading the "random" and "latest" photos? Check out this post - http://forum.coppermine-gallery.net/index.php?topic=33967.0 (http://forum.coppermine-gallery.net/index.php?topic=33967.0) and see a quote from Nibbler,
Quote
Try disabling 'Show number of linked files' in config.
Also do a search on tweaking Coppermine.
My fault for not asking in the first place but post a link to your gallery and a debug report - http://coppermine-gallery.net/demo/cpg14x/docs/index.htm#debug_mode (http://coppermine-gallery.net/demo/cpg14x/docs/index.htm#debug_mode). If you've mangled any files other than what's in your theme folder, put them back before generating the debug report.