tmatbcorp VIP
Total posts: 41
25 Feb 2015 21:18

Hi,

For a section, for the list view, I need the articles to be ordered as:

  • featured first
  • most recent first (with or without an expiration date)

Currently, I have 'Most recent first' set everywhere in the section's configuration and "Featured first"="Yes".

But, the generated query is like '... ORDER BY featured DESC, ftime DESC, ctime DESC'.

This means that articles are displayed as:

  • featured first
  • articles WITH AN EXPIRATION DATE and most recent first
  • articles WITHOUT AN EXPIRATION DATE and most recent first

This means that if we create a new article for this section with no expiration date, it will not appear right after the featured articles (which is what we want) but a lot further.

I would like to change the query to '... ORDER BY featured DESC, ctime DESC, ftime DESC' (first ctime then ftime).

How is it possible (as where in the section configuration or where in Cobalt code)?

Kind regards,

Last Modified: 03 Mar 2015


Sergey
Total posts: 13,748
26 Feb 2015 05:50

That is strange. Because after article stopped being featured the ftime is reser to 0000-00-00 00:00:00. This means that ftime DESC will have no effect on articles with featured = 1. this means that featured DESC, ftime DESC, ctime DESC will sort only featured articles by ftime and none-featured by ctime.


tmatbcorp VIP
Total posts: 41
26 Feb 2015 08:31

The problem is that we have articles NOT featured (and never been featured) but WITH an expiration date.

Those articles are displayed before the not featured newly created ones but we want the contrary.

To be clear, let's say we have :

  • article A1: featured, never expires, created 2 weeks ago
  • article A2: not featured, expires tomorrow, created 2 weeks ago
  • article A3: not featured, never expires, created just now

Now the display is A1 then A2 then A3.

We want A1 then A3 then A2.

Please tell me where to change Cobalt code to get the query the way I want.


tmatbcorp VIP
Total posts: 41
26 Feb 2015 08:58

Finally I changed code one line 230 on /components/com_cobalt/models/records.php:

We don't need to sort by ftime for our web site then instead of $query->order('r.featured DESC, r.ftime DESC'); I wrote $query->order('r.featured DESC');.


Sergey
Total posts: 13,748
02 Mar 2015 11:59

How does expiration influence all of this? It is not in the formula, right? Why do you meantion it?


Konstantin
Total posts: 1,113
03 Mar 2015 11:16

tmatbcorp

  • article A1: featured, never expires, created 2 weeks ago
  • article A2: not featured, expires tomorrow, created 2 weeks ago
  • article A3: not featured, never expires, created just now
  • Checked localy and it shows as here:

    tmatbcorp We want A1 then A3 then A2.

    Powered by Cobalt