Sort records based on dragSort of another table

4 posts by 3 authors in: Forums > CMS Builder
Last Post: April 20, 2011   (RSS)

Hi,

This might be tricky.

Table "tbl_courses" includes field "Discipline"

This Field "Discipline" is linked to table "tbl_disciplines", with 'num' recorded in the mySQL in tbl_courses.

So user creates new Course record, and selects the appropriate Discipline.


When listing the COURSES, and sorting by DISCIPLINE, it sorts then by NUM of the Discipline records.

However, how could we set the sort to sort by DISCIPLINE based on the dragSortOrder of the records in "tbl_discipline", rather than NUM?

I can only forsee a long winded messy hack type way of doing it... (which might only work in my head, not on paper) is there any efficient simple way?!

Thanks
Rob

Re: [rjbathgate] Sort records based on dragSort of another table

Hi Rob,

I did a search on sortby dragsortotrder and found some interesting posts, including this one:

http://www.interactivetools.com/iforum/Products_C2/CMS_Builder_F35/gforum.cgi?post=85670

Hope that offers some insights.

Good luck,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [rjbathgate] Sort records based on dragSort of another table

By Dave - April 20, 2011

Hi Rob,

There's an efficient way, and a simple way, but not both.

The simple way is to do lots of queries. Just load Discipline, sort it by dragSort and output it, then in the foreach load courses that match that discipline. So you get many many getRecords() calls, but if your database isn't too big you can probably get away with it.

The efficient way is to write a pure MySQL query with a JOIN and sort on that, but that will take some experimenting.

You can do a lot with the viewer functions but things like this are still often easier done by hand.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com