forum.coppermine-gallery.net
Support => cpg1.5.x Support => cpg1.5 themes (visuals) => Topic started by: allvip on June 09, 2014, 09:09:57 am
-
Is there a way to make coppermine sort images by keywords the same way is sorting images by most viewed and top rated?
I want to add a custom menu with: Nature, Animals, Cars etc and one users click on Cars coppermine to show all images that has cars in the keywords from all the albums and categories including User galleries.
I know I can make Cars to link to http://allvip.us/gallery/thumbnails.php?album=search&keywords=on&search=cars but that looks ugly.I want the link to be sort.Something like http://allvip.us/gallery/thumbnails.php?album=cars
-
You'd need to create an Apache rewrite rule or a custom meta album if you don't like the search URL in the address bar. Regarding the meta album, I suggest to extend the More meta albums plugin (http://forum.coppermine-gallery.net/index.php/topic,63706.0.html) to avoid core code modification. That plugin already has a lot of custom meta albums, so you can get an idea how it works and use one of them as base for your custom meta albums.
-
I did try to edit the plugin but I am no good at that.
-
Then I suggest to use the rewrite rule.
-
I wood like to use the plugin.
Hope you can give me the code to add a new meta album: Cars, that will show all the images with keywords cars.
-
Inside the function mma_get_pic_pos, find
default:
and above, add
case 'cars':
case 'nature':
case 'animal':
$query = "SELECT COUNT(*) FROM {$CONFIG['TABLE_PICTURES']} AS p
INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS r ON r.aid = p.aid
$RESTRICTEDWHERE
AND approved = 'YES'
AND CONCAT('{$CONFIG['keyword_separator']}', `keywords`, '{$CONFIG['keyword_separator']}') LIKE '%{$CONFIG['keyword_separator']}$album{$CONFIG['keyword_separator']}%'
AND pid < $pid";
$result = cpg_db_query($query);
list($pos) = mysql_fetch_row($result);
mysql_free_result($result);
return strval($pos);
break;
Inside the function mma_meta_album, find
default:
and above, add
case 'cars':
case 'nature':
case 'animal':
$album_name = $meta['album'];
if ($CURRENT_CAT_NAME) {
$album_name .= " - $CURRENT_CAT_NAME";
}
$query = "SELECT pid FROM {$CONFIG['TABLE_PICTURES']} AS p
INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS r ON r.aid = p.aid
$RESTRICTEDWHERE
AND approved = 'YES'
AND CONCAT('{$CONFIG['keyword_separator']}', `keywords`, '{$CONFIG['keyword_separator']}') LIKE '%{$CONFIG['keyword_separator']}{$meta['album']}{$CONFIG['keyword_separator']}%'";
$result = cpg_db_query($query);
$count = mysql_num_rows($result);
mysql_free_result($result);
if (!$count) {
$rowset = array();
break;
}
$query = "SELECT p.* FROM {$CONFIG['TABLE_PICTURES']} AS p
INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS r ON r.aid = p.aid
$RESTRICTEDWHERE
AND approved = 'YES'
AND CONCAT('{$CONFIG['keyword_separator']}', `keywords`, '{$CONFIG['keyword_separator']}') LIKE '%{$CONFIG['keyword_separator']}{$meta['album']}{$CONFIG['keyword_separator']}%'
ORDER BY pid ASC
{$meta['limit']}";
$result = cpg_db_query($query);
$rowset = cpg_db_fetch_rowset($result);
mysql_free_result($result);
build_caption($rowset);
break;
(not tested, but should work).
-
OK.Test it on my localhost.It works.Thanks 1000 times.
-
For your information, I added that solution to the plugin announcement thread: http://forum.coppermine-gallery.net/index.php/topic,63706.msg375149/topicseen.html#msg375149
-
Great.I wanted to do the same thing (just a link to this thread as the plugin thread is not my thread).