Hi,

I needed a solution for a drop down alphanumeric paginator for names with
select options like:
Abigail - Caleb
Eliza - Gavin
Isabella - Matthew

My quick solution is probably very far from the "best solution", but here it
is:

(thanks for any comments, improvements or anything :) )

$select = $db->select()->
        from('favorite_users', 'who_id')->
        joinLeft('users', 'id = who_id', 'username' )->
        where('user_id='.$current_id)->
        order('username');
                
$paginator = Zend_Paginator::factory($select);
$paginator->setCurrentPageNumber($currentPage);

if ($paginator->getPages()->pageCount) {
        echo '<select id="paginationDropDownControl" size="1">';
        foreach ($paginator->getPages()->pagesInRange as $page){
                $firstItem = $paginator->getItem(1,$page);
                $lastItem =
$paginator->getItem(count($paginator->getItemsByPage($page)),$page);
                
                $selected = ($page == $paginationData->current)?' 
selected="selected"':'';
                echo '
                        <option value="page-'.$page.'"'.$selected.'>'.
                                $firstItem['username'].' - 
'.$lastItem['username'].'</option>';
        }
        echo '</select>';

        echo '
                <script type="text/javascript">
                        $(document).ready(function(e) {
                                
$(\'#paginationDropDownControl\').bind(\'change\', function(){
                                        window.location = 
$(this).attr(\'value\');
                                });
                        });
                </script>';
}

Bye,
Rudi

PS. I'm not using MVC in this project.


lightflowmark wrote:
> 
> Hi - has anyone implemented an alphanumeric paginator plugin?  i.e., one
> that will list pages like A-C, D-E, F-Z or whatever?  I was surprised not
> to find this in Zend_Paginate and don't want to reinvent the wheel if
> someone's already built one!
> 
> Cheers,
> Mark
> 

-- 
View this message in context: 
http://www.nabble.com/Alphabetic-paginator--tp23540329p24729734.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to