This mod adds a new meta album to show most viewed albums.
Demo:
http://vanrokken.altervista.org/thumbnails.php?album=topnalbUsage: to include this meta album in Main page/Album list display, add 'topnalb' code to your Configuration > Album list view > Main page content list
(E.g. anycontent/breadcrumb/catlist/alblist/lastalb,1/topnalb,1).
To add a link "Most viewed albums" to your Gallery sub menu, enter "
Most viewed albums" in "Name of your custom link" field, "
thumbnails.php?album=topnalb" in "URL of your custom link" field under Configuration > Themes settings
Files to edit:
index.php
include/functions.inc.php
lang/english.php (repeat for all the desired language files)
themes/your_theme/theme.phpOPEN
index.phpFIND
case 'lastalb':
display_thumbnails('lastalb', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
break;
AFTER, ADD
case 'topnalb':
display_thumbnails('topnalb', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
break;
OPEN
include/functions.inc.phpFIND
$rowset = CPGPluginAPI::filter('thumb_caption_favpics',$rowset);
return $rowset;
break;
AFTER, ADD
case 'topnalb': // Last albums to which uploads
if ($META_ALBUM_SET && $CURRENT_CAT_NAME) {
$album_name = $lang_meta_album_names['topnalb'].' - '. $CURRENT_CAT_NAME;
} else {
$album_name = $lang_meta_album_names['topnalb'];
}
$META_ALBUM_SET_MWA = str_replace( "aid", $CONFIG['TABLE_PICTURES'].".aid" , $META_ALBUM_SET );
$query = "SELECT count({$CONFIG['TABLE_ALBUMS']}.aid) FROM {$CONFIG['TABLE_PICTURES']},{$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND approved = 'YES' $META_ALBUM_SET_MWA GROUP BY {$CONFIG['TABLE_PICTURES']}.aid";
$result = cpg_db_query($query);
$count = mysql_num_rows($result);
mysql_free_result($result);
$query = "SELECT *, SUM({$CONFIG['TABLE_PICTURES']}.hits) AS hits, {$CONFIG['TABLE_ALBUMS']}.title AS title, {$CONFIG['TABLE_ALBUMS']}.aid AS aid FROM {$CONFIG['TABLE_ALBUMS']},{$CONFIG['TABLE_PICTURES']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND {$CONFIG['TABLE_PICTURES']}.approved = 'YES' AND hits > 0 $META_ALBUM_SET_MWA GROUP BY {$CONFIG['TABLE_ALBUMS']}.aid ORDER BY hits DESC $limit";
$result = cpg_db_query($query);
$rowset = cpg_db_fetch_rowset($result);
mysql_free_result($result);
if ($set_caption) build_caption($rowset,array('hits'));
$rowset = CPGPluginAPI::filter('thumb_caption_topnalb',$rowset);
return $rowset;
break;
OPEN
lang/english.phpFIND
'favpics'=> 'Favorite Files', //cpg1.4
AFTER, ADD
'topnalb' => 'Most viewed Albums',
OPEN
themes/your_theme/theme.phpFIND
function theme_display_thumbnails
(if absent, copy and paste it from themes/sample/theme.php)FIND
$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']));
REPLACE WITH
$theme_thumb_tab_tmpl['left_text'] = strtr($theme_thumb_tab_tmpl['left_text'], array('{LEFT_TEXT}' => ($aid == 'lastalb' || $aid == 'topnalb') ? $lang_album_list['album_on_page'] : $lang_thumb_view['pic_on_page']));
FIND
if ($aid == 'lastalb') {
REPLACE WITH
if ($aid == 'lastalb' || $aid == 'topnalb') {
SAVE AND CLOSE ALL FILES