3069 Posts in 868 Topics by 650 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 781 Views |
-
default_sort using secondary table

7 February 2011 at 3:53pm
hi
I have a table called "options" and a table called "option groups". I want to sort the options by group and then by option. For the sorting, I have added the Sort field to both tables...
I would like to sort Options like this:
static $default_sort = "OptionGroup.Sort ASC, Option.Sort ASC";
I added the following function to Option:
<?php
class Option extends DataObject {
...
static $default_sort = "OptionGroup.Sort ASC, Option.Sort ASC";
public function extendedSQL($filter = "", $sort = "", $limit = "", $join = "", $having = ""){
$join .= " LEFT JOIN \"OptionGroup\" ON \"OptionGroup\".\"ID\" = \"Option\".\"OptionGroupID\"";
return parent::extendedSQL($filter, $sort, $limit, $join, $having);
}
...
}However, it does not work...
-
Re: default_sort using secondary table

12 February 2011 at 1:01am
does this thread help? (towards the end some is doing similar i think, sort based on join)
http://silverstripe.org/general-questions/show/5768?start=0
| 781 Views | ||
|
Page:
1
|
Go to Top |

