Phoca Gallery Image Module Bug - ordering average and count

Phoca Gallery modules - modules for Phoca Gallery extension
david1d3m
Phoca Newbie
Phoca Newbie
Posts: 1
Joined: 02 Jan 2015, 17:08

Phoca Gallery Image Module Bug - ordering average and count

Post by david1d3m »

Hi, I wanted to use average or count ordering in Phoca Gallery Image Module but I always had as result an 1054 error page and a message in frontend telling that r.average or r.count does not exist.

I tried to debug that and I found in : near line 667 of mod_phocagallery_image/mod_phocagallery_image.php

if (!empty($allowedCategories)) {
$image = '';
$query = 'SELECT cc.id AS idcat, a.id AS idimage'
.' FROM #__phocagallery_categories AS cc'
.' LEFT JOIN #__phocagallery AS a ON a.catid = cc.id'
.' WHERE a.published = 1'
.' AND a.approved = 1'
.' AND cc.published = 1';

there is no join on statistic table. I've done this :

if (!empty($allowedCategories)) {
$image = '';
$query = 'SELECT cc.id AS idcat, a.id AS idimage'
.' FROM #__phocagallery_categories AS cc'
.' LEFT JOIN #__phocagallery AS a ON a.catid = cc.id'
// Ajout David
.' LEFT JOIN #__phocagallery_img_votes_statistics AS r ON r.imgid = a.id'

.' WHERE a.published = 1'
.' AND a.approved = 1'
.' AND cc.published = 1';


Then near line 699 :

$query = 'SELECT cc.id, cc.alias as catalias, a.id, a.catid, a.title, a.alias, a.filename, a.description, a.extm, a.exts,a.extl, a.exto, a.extw, a.exth, a.extid,'
. ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(\':\', cc.id, cc.alias) ELSE cc.id END as catslug, '
. ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug'
. ' FROM #__phocagallery_categories AS cc'
. ' LEFT JOIN #__phocagallery AS a ON a.catid = cc.id'
// Ajout David
.' LEFT JOIN #__phocagallery_img_votes_statistics AS r ON r.imgid = a.id'

. ' WHERE a.id in (' . $imageIds . ')'



It is working but i think the solution could be better ^^
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47936
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Phoca Gallery Image Module Bug - ordering average and co

Post by Jan »

Hi, thank you for the info, which version of the module did you use?
If you find Phoca extensions useful, please support the project
Post Reply