In a former question I've had good advice how to sort titles with sql-query's alphabetically in a correct (human) way, IN CASE titles (or names, documents, articles, ..) all begin with a same word (e.g. Appendix) followed by a number (1, 2, 3,...). When this leads to decimals (Appendix 10 and higher), sorting within Joomla is not correct anymore (Appendix 10 comes after Appendix 1 in stead of after Appendix 9). I'm now trying to integrate the given advice (one of the sql-query's) within the Joomla code. I'm using Component Contacts as a tryout, and trying to modify the file category.php so it will fit my needs. But until now no luck. The specific question is how / where to integrate one of the query's (e.g. $query->order("CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(a.name, ' ', 2), ' ', -1) AS UNSIGNED), a.name");) in category.php in such a way that it gives no conflict with existing code.

  • As a side note, may I recommend changing if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', ''))) { $listOrder = 'ASC'; } to if (strtoupper($listOrder) != 'DESC') { $listOrder = 'ASC'; } – mickmackusa Dec 28 '18 at 21:47
  • You've dumped a whole file here. Which lines would you like me to look at specifically? Why isn't my earlier answer suitable? – mickmackusa Dec 28 '18 at 21:48
  • You might like to read stackoverflow.com/q/26164224/2943403 regarding published date ranges. (I'm viewing from my phone so reading the whole git file is a bunch of slow scrolling. p.s. you some unnecessary/extra parentheses in a few of your where() clauses -- no big deal, just saying. – mickmackusa Dec 28 '18 at 22:02
  • Line 153 quoteName() will happily receive the table alias as the 2nd parameter. Line 165, when there is only one WHEN in a CASE expression, it is more brief and easier to read IMO to simply write a mysql IF statement. Line 205, in is a reserved word and should be IN. – mickmackusa Dec 28 '18 at 22:26
  • I just realized that that is not your work on github, but actually the staging branch. Ha. I guess if I had more github confidence, I'd be a contributor. – mickmackusa Dec 28 '18 at 23:53

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.