Skip to content

Commit

Permalink
improving the method to allow custom model being used for the list
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmatic69 committed Oct 13, 2012
1 parent 18adc01 commit 8cf36d7
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Core/Filter/View/Helper/FilterHelper.php
Expand Up @@ -141,17 +141,19 @@ public function clear($filter, $div = false) {
*
* @return string ul->li list of things found
*/
public function alphabetFilter() {
if(empty($this->request->params['models'])) {
return false;
public function alphabetFilter($model = null) {
if(empty($model)) {
if(empty($this->request->params['models'])) {
return false;
}
$model = implode('.', current($this->request->params['models']));
}

$model = implode('.', current($this->request->params['models']));
$letters = ClassRegistry::init($model)->getLetterList();

$return = array();
foreach($letters as $key => $value) {
$url = ($value == true) ? $this->__filterLink($key) : $key;
$url = ($value == true) ? $this->__filterLink($model, $key) : $key;
if(is_array($url)) {
$url = $this->Html->link(
$key,
Expand All @@ -175,11 +177,10 @@ public function alphabetFilter() {
* @param string $text the text to show/filter with
* @return array the url cake style
*/
private function __filterLink($text = null) {
private function __filterLink($model, $text = null) {
if(!$text) {
return false;
}
$model = implode('.', current($this->request->params['models']));

$filter = array(
ClassRegistry::init($model)->alias . '.' . ClassRegistry::init($model)->displayField => $text
Expand Down

0 comments on commit 8cf36d7

Please sign in to comment.