Search
Other Articles Anywhere questions
Forum

Sorting results with two criteria.

Collin Lafrance's Avatar Collin Lafrance
Hello, I am wanting to sort the results of the articles that it pulls and displays.

I wish to sort by the value of a custom field (number ascending) and then sorted by the TIME (number ascending).

I can do one or the other to sort but I haven't been able to figure out a way to sort one and then the other.

For a sort by the EVENT TYPE (which is a number)
ordering="type-of-media-advisory ASC"

For a sort by the TIME I use
ordering="date-nf1 ASC"

IS there a way to sort first by type-of-media-advisory ASC and then date-nf1 ASC? In other words they are all sorted by type-of-media-advisory, and each of those with that field is further sorted by date-nf1?
{articles category="Media Advisory" date="date('today')" OR category="Media Advisory" date-2="date('today')" OR category="Media Advisory" date-3="date('today')" OR category="Media Advisory" date-4="date('today')" OR category="Media Advisory" date-5="date('today')" OR category="Media Advisory" date-6="date('today')" OR category="Media Advisory" date-7="date('today')" OR category="Media Advisory" date-8="date('today')" ordering="date-nf1 ASC"}
<hr />
<p style="color:red"><strong>[status-of-media-advisory]</strong></p>
<b> [location-date-time]</b><br />
<br />
<b>[link][title][/link]</b><br />
[text]<br />{/articles}

Thank you in advance for your help. If you have other suggestions please feel free to share.
Peter van Westen's Avatar Peter van Westen ADMIN
Try:
ordering="type-of-media-advisory ASC,date-nf1 ASC"
Or simply:
ordering="type-of-media-advisory,date-nf1"
Please post a rating at the Joomla! Extensions Directory
Collin Lafrance's Avatar Collin Lafrance
That worked perfectly. Thank you.

Another somewhat related question, is there a way to combine this to make it shorter or that's really the only way to do it? It is a series of 8 Date Fields.
date="date('today')" OR date-2="date('today')" OR date-3="date('today')" OR date-4="date('today')" OR date-5="date('today')" OR date-6="date('today')" OR date-7="date('today')" OR date-8="date('today')"

I'm just trying to make it more efficient on the database queries as we seem to be having a problem lately with it.
Peter van Westen's Avatar Peter van Westen ADMIN
I don't see a shorter way to do that.

If you run into slow query issues, enable the debug mode.
Then track down the slow queries, and see if adding indexes to the relevant database tables makes a difference.
Please post a rating at the Joomla! Extensions Directory
Collin Lafrance's Avatar Collin Lafrance
Thanks. Could you elaborate what you mean by adding indexes to the relevant database tables?
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription