This is kind of top-photos, but the principle of selection is slightly different from the standard. For me it was important to select from each category just one photo with the highest rating.
displayed on a separate page
design as a category page
1. the file includes/page_header.phpfind
"url_captcha_image" => $site_sess->url(ROOT_PATH."captcha.php"),
insert below
"url_top_rated" => $site_sess->url(ROOT_PATH."top_rated.php"),
"lang_top_rated" => $lang['top_rated'],
2. the file lang/your_lang/main.phpbefore
?> add
$lang['top_rated'] = "Top Rated";
$lang['top_rated_desc'] = "Here is one photo from each category with the highest rank.";
My English isn't good, so change a name and description, if necessary.
3. a new file top_rated.phpsave it in the root of gallery
<?php
/* --------- Most rated imade from each category on one page with paging ----------------- */
$templates_used = 'top_rated,thumbnail_bit';
$main_template = 'top_rated';
define('GET_CACHES', 1);
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
include(ROOT_PATH.'includes/page_header.php');
$cache_id = create_cache_id(
'page.top_rated',
array(
$user_info[$user_table_fields['user_id']],
$cat_id,
$page,
$perpage,
isset($user_info['lightbox_image_ids']) ? substr(md5($user_info['lightbox_image_ids']), 0, 8) : 0,
$config['template_dir'],
$config['language_dir']
)
);
if (!$cache_page_top_rated || !$content = get_cache_file($cache_id)) {
// Always append session id if cache is enabled
if ($cache_page_top_rated) {
$old_session_mode = $site_sess->mode;
$site_sess->mode = 'get';
}
ob_start();
//-----------------------------------------------------
//--- Show Images -------------------------------------
//-----------------------------------------------------
$sql = "SELECT cat_id
FROM ".IMAGES_TABLE."
WHERE cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")
GROUP BY cat_id";
$result = $site_db->query($sql);
$num_rows_all = mysql_num_rows($result);
$link_arg = $site_sess->url(ROOT_PATH."top_rated.php");
include(ROOT_PATH.'includes/paging.php');
$getpaging = new Paging($page, $perpage, $num_rows_all, $link_arg);
$offset = $getpaging->get_offset();
$site_template->register_vars(array(
"paging" => $getpaging->get_paging(),
"paging_stats" => $getpaging->get_paging_stats()
));
$imgtable_width = ceil((intval($config['image_table_width'])) / $config['image_cells']);
if ((substr($config['image_table_width'], -1)) == "%") {
$imgtable_width .= "%";
}
$additional_sql = "";
if (!empty($additional_image_fields)) {
foreach ($additional_image_fields as $key => $val) {
$additional_sql .= ", a.".$key;
}
}
$sql = "SELECT a.image_id, a.cat_id, a.user_id, a.image_description, a.image_keywords, a.image_date, a.image_active, a.image_media_file, a.image_thumb_file, a.image_download_url, a.image_allow_comments, a.image_comments, a.image_downloads, a.image_votes, a.image_hits".$additional_sql.", a.image_name, c.cat_name
FROM (".IMAGES_TABLE." a, ".CATEGORIES_TABLE." c)
WHERE a.image_active = 1 AND a.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").") AND a.image_votes != 0 AND a.image_rating = (SELECT MAX(image_rating)
FROM ".IMAGES_TABLE." b
WHERE a.cat_id= b.cat_id)
GROUP BY a.cat_id
ORDER BY ".$config['image_order']." ".$config['image_sort']."
LIMIT $offset, $perpage";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
if (!$num_rows) {
$thumbnails = "";
$msg = $lang['no_images'];
}
else {
$thumbnails = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">\n";
$count = 0;
$bgcounter = 0;
while ($image_row = $site_db->fetch_array($result)){
if ($count == 0) {
$row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
$thumbnails .= "<tr class=\"imagerow".$row_bg_number."\">\n";
}
$thumbnails .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";
show_image($image_row);
$thumbnails .= $site_template->parse_template("thumbnail_bit");
$thumbnails .= "\n</td>\n";
$count++;
if ($count == $config['image_cells']) {
$thumbnails .= "</tr>\n";
$count = 0;
}
} // end while
if ($count > 0) {
$leftover = ($config['image_cells'] - $count);
if ($leftover > 0) {
for ($i = 0; $i < $leftover; $i++){
$thumbnails .= "<td width=\"".$imgtable_width."\">\n \n</td>\n";
}
$thumbnails .= "</tr>\n";
}
}
$thumbnails .= "</table>\n";
} //end else
$site_template->register_vars("thumbnails", $thumbnails);
unset($thumbnails);
//-----------------------------------------------------
//--- Clickstream ------------- -----------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a title=\"".$lang['home']."\" href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].$lang['top_rated']."</span>";
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
"top_rated_desc" => $lang['top_rated_desc'],
"msg" => $msg,
"clickstream" => $clickstream,
));
$site_template->print_template($site_template->parse_template($main_template));
$content = ob_get_contents();
ob_end_clean();
if ($cache_page_top_rated) {
// Reset session mode
$site_sess->mode = $old_session_mode;
save_cache_file($cache_id, $content);
}
} // end if get_cache_file()
echo $content;
include(ROOT_PATH.'includes/page_footer.php');
?>
4. a new file top_rated.html4.1 to save design of gallery, open your file categories.html and save it as top_rated.html
4.2 find 3 times
random_cat_image
replace with
random_image
4.3 find
{cat_name}
replace with
{lang_top_rated}
4.4 find and delete
{upload_button}
4.5 find
{cat_description} (Hits: {cat_hits})
replace with
{top_rated_desc}
4.6 find and remove all from (if categories) and to (endif categories) inclusive
5. for a link to this page anywhere on the siteuse
<a href="{url_top_rated}">{lang_top_rated}</a>