Hi,

I did some reading and testing and here are my results (which worked for me)
and I hope someone else finds this useful:


Here are 3 different ways to add paginator partial:

1. Named route

<?= $this->paginationControl($this->paginator, "Sliding",
"pagination_controls.phtml", array("route" => "userchannels")) ?>

2. Array

<?= $this->paginationControl($this->paginator, "Sliding",
"pagination_controls.phtml", array("route" => array("module" => "birds",
"controller" => "list", "action" => "bycategory", "category" => 123))) ?>

3. string formatted in some logic (will be converted to array)

<?= $this->paginationControl($this->paginator, "Sliding",
"pagination_controls.phtml", array("route" =>
"module:controller:action:param1=val1:param2=val2")) ?>

I added the following code to the pagination partial
(pagination_controls.phtml):
<?php

// Get named route
$route = (isset($this->route) && !is_array($this->route)) ? $this->route :
null;

// Create URL from array (module, controller, action)
$params = (isset($this->route) && is_array($this->route)) ? $this->route :
array();

// If string with module, controller, action divided by semicolon
if (strstr($route, ":"))
{
        // Add data to params array
        $exploded_data = explode(":", $route, 4);
        
        $params["module"] = $exploded_data[0];
        $params["controller"] = $exploded_data[1];
        $params["action"] = $exploded_data[2];
        
        $leftover = (isset($exploded_data[3])) ? $exploded_data[3] : false;
        
        if ($leftover)
        {
                $exploded_data = explode(":", $leftover);
                
                foreach ($exploded_data as $param_string)
                {
                        list($param, $value) = explode("=", $param_string);
                        
                        $params[$param] = $value;
                }
        }
        
        // Important! Set named route to default when using module, controller,
action names
        $route = "default";
}

// Normal pagination template starts >>
?>
<?php if ($this->pageCount): ?>

<div class="pagination-controls clearfix">

        <!-- First page link -->
        <?php if (isset($this->previous)): $params_first = array_merge($params,
array("page" => $this->first)); ?>
         "<?= $this- url($params_first, $route); ?>" class="ajax-control">
                <div class="icon first left" title="<?= 
$this->translate("First")
?>"></div>
         
        <?php else: ?>
        <div class="icon first disabled left"></div>
        <?php endif; ?>

        <!-- Previous page link -->
        <?php if (isset($this->previous)): $params_previous = 
array_merge($params,
array("page" => $this->previous)); ?>
         "<?= $this- url($params_previous, $route); ?>" class="ajax-control">
                <div class="icon previous left" title="<?= 
$this->translate("Previous")
?>"></div>
         
        <?php else: ?>
        <div class="icon previous disabled left"></div>
        <?php endif; ?>

        <!-- Next page link -->
        <?php if (isset($this->next)): $params_next = array_merge($params,
array("page" => $this->next)); ?>
         "<?= $this- url($params_next, $route); ?>" class="ajax-control">
                <div class="icon next left" title="<?= $this->translate("Next") 
?>"></div>
         
        <?php else: ?>
        <div class="icon next disabled left"></div>
        <?php endif; ?>

        <!-- Last page link -->
        <?php if (isset($this->next)): $params_last = array_merge($params,
array("page" => $this->last)); ?>
         "<?= $this- url($params_last, $route); ?>" class="ajax-control">
                <div class="icon last left" title="<?= $this->translate("Last") 
?>"></div>
         
        <?php else: ?>
        <div class="icon last disabled left"></div>
        <?php endif; ?>

</div>

<?php endif; ?>
-- 
View this message in context: 
http://www.nabble.com/Zend_Paginator-and-Action-helper-%28or-Actionstack%29-tp21858042p21871324.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to