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 ^^
Phoca Gallery Image Module Bug - ordering average and count
-
- Phoca Newbie
- Posts: 1
- Joined: 02 Jan 2015, 17:08
- Jan
- Phoca Hero
- Posts: 48386
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Phoca Gallery Image Module Bug - ordering average and co
Hi, thank you for the info, which version of the module did you use?
If you find Phoca extensions useful, please support the project