I was curious if anyone would like to comment on these few changes
I've made to the pagination helper.

I've noticed that regardless everything is always sorted asc, which
for me didn't work as I need to be able to sort asc or desc from links
next to the field names. (EG: Name (Asc) | (Desc))

So in order to do this, I pilfered through the pagination helper and
tweaked it a little bit.

        function sort($title, $key = null, $options = array()) {
                $options = am(array('url' => array(), 'model' => null, 'dir' =>
null), $options);
                $url = $options['url'];
                unset($options['url']);

                if (empty($key)) {
                        $key = $title;
                        $title = Inflector::humanize(preg_replace('/_id$/', '', 
$title));
                }

                if (isset($options['dir'])) {
                        $dir = $options['dir'];
                        unset($options['dir']);
                } elseif ($this->sortKey($options['model']) == $key && $this-
>sortDir($options['model']) == 'asc') {
                        $dir = 'desc';
                }

                if (isset($options['model'])) {
                        $key = $options['model'].'.'.$key;
                        unset($options['model']);
                }

                $url = am(array('sort' => $key, 'direction' => $dir), $url,
array('order' => null));
                return $this->link($title, $url, $options);
        }

Basically just added the dir option, and the ability to append the key
with the model name sense currently in 1.2 it doesn't appear to accept
the model option. By accept I mean actually perform something, from
what I've seen prior to my changes it would sort by default.name
instead of say, state.name.

very odd considering that this should work?

<?php echo $paginator->sort('blah', 'name', array('dir' => 'desc',
'model' => 'Business'));?>

But apparently doesn't.

Thanks,
Dave


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to