Version: 4.3.0 Reporter: afrihostbrandteam —
Hi There
When using the entries loop with order by view_count and a specific category_id specified, an exception is thrown. Here is the code:
{exp:channel:entries category="1" orderby="view_count_two" sort="desc" limit="10"}
And here is the exception:
SQLSTATE[HY000]: General error: 3065 Expression #2 of ORDER BY clause is not in SELECT list, references column 'help_center.t.view_count_two' which is not in SELECT list; this is incompatible with DISTINCT:
SELECT DISTINCT t.entry_id , exp_channels.channel_id , t.sticky FROM exp_channel_titles AS t LEFT JOIN exp_channels ON t.channel_id = exp_channels.channel_id INNER JOIN exp_category_posts ON t.entry_id = exp_category_posts.entry_id INNER JOIN exp_categories ON exp_category_posts.cat_id = exp_categories.cat_id WHERE t.entry_id != '' AND t.site_id IN ('1') AND t.entry_date < 1529424496 AND (t.expiration_date = 0 OR t.expiration_date > 1529424496) AND exp_categories.cat_id = '1' AND t.status = 'open' ORDER BY t.sticky desc, t.view_count_two desc, t.entry_date desc, t.entry_id desc LIMIT 0, 100
Thanks,
In system/ee/EllisLab/Addons/Channel/mod.channel.php start looking around line 2132. This line needs to be added: $distinct_select .= ", t.{$vc} ";
so it looks like:
case 'view_count' :
$vc = $order.$view_ct;
$end .= " t.{$vc} ".$sort_array[$key];
$distinct_select .= ", t.{$vc} ";
if (count($order_array)-1 == $key)
{
$end .= ", t.entry_date ".$sort_array[$key];
}
ExpressionEngine implements Markdown Extra and BBCode. Please see the Markdown Extra docs and the BBCode Wikipedia article for a full reference.
**bold**
, __bold__
, *italics*
, _italics_
, ~strike/del~
, `code()`
bold, italics, strike/del, code()
Link: [link title](https://example.com)
Image: ![alt text](https://example.com/image.jpg)
[blockquote]...[/blockquote]
, [quote]...[/quote]
, and Markdown style:
> Some quoted text. > > This is all one quote.
[code]...[/code]
, and you can also specify the language for syntax highlighting, [code=php]...[/code]
GitHub flavored Markdown code fences are also supported:
``` public function decoderRing($str) { return str_rot13($str); } ```