Hi Anees,

I have created a custom class which extends the base class of Zend_Paginator
to solve this problem.

I then add a custom getter and setter to add additional view parameters to
the new pagination object.

Finally I changed the __toString() and render() functions to pass in the
additional parameters to the rendering of the pagination control using the
new getter.

Not sure if this is a perfect solution but it worked for me. Maybe
Zend_Paginator base class should included these additional getters and
setters for passing additional information to the pagination control view
rendering?


  Class Jnb_Paginator extends Zend_Paginator
    {

    protected $addtionalViewParams = null;

    public static function factory($data, $adapter = self::INTERNAL_ADAPTER,
                                   array $prefixPaths = null)
    {
        if ($adapter == self::INTERNAL_ADAPTER) {
            if (is_array($data)) {
                $adapter = 'Array';
            } else if ($data instanceof Zend_Db_Table_Select) {
                $adapter = 'DbTableSelect';
            } else if ($data instanceof Zend_Db_Select) {
                $adapter = 'DbSelect';
            } else if ($data instanceof Iterator) {
                $adapter = 'Iterator';
            } else if (is_integer($data)) {
                $adapter = 'Null';
            } else {
                $type = (is_object($data)) ? get_class($data) :
gettype($data);

                /**
                 * @see Zend_Paginator_Exception
                 */
                require_once 'Zend/Paginator/Exception.php';

                throw new Zend_Paginator_Exception('No adapter for type ' .
$type);
            }
        }

        $pluginLoader = self::getAdapterLoader();

        if (null !== $prefixPaths) {
            foreach ($prefixPaths as $prefix => $path) {
                $pluginLoader->addPrefixPath($prefix, $path);
            }
        }

        $adapterClassName = $pluginLoader->load($adapter);

        return new self(new $adapterClassName($data));
    }

    public function setAddtionalViewParams($params)
        {
        $this->addtionalViewParams = $params;
        }

    public function getAddtionalViewParams()
        {
        return $this->addtionalViewParams;
        }

    public function __toString()
        {
        try {
            // This statement has added a call to get the addtional view
params
            $return = $this->render(null,$this->getAddtionalViewParams());
            return $return;
            }
        catch (Exception $e)
            {
            trigger_error($e->getMessage(), E_USER_WARNING);
            }
        return '';
        }

    public function render(Zend_View_Interface $view = null,
$paginationControlParams = null)
        {
        if (null !== $view)
            {
            $this->setView($view);
            }
        $view = $this->getView();
        // this statement has been modified to inject the addtional params
into the pagination control view
        return
$view->paginationControl($this,null,null,$paginationControlParams);
        }
      }

On Thu, Mar 26, 2009 at 2:21 AM, Anees <anees_m...@yahoo.com> wrote:

>
> Hi,
>
> I am using zend_paginator class to generate the Paging script
> And it is working well.
>
> But i need to pass a variable other than 'page' as GET
> how could i do this?
>
> My current script is
>
> $paginator = Zend_Paginator::factory($result);
> $paginator->setView($this->view);
> $paginator->setItemCountPerPage($site_rec_per_page);
> $paginator->setCurrentPageNumber($this->view->page);
> $this->view->paginator = $paginator;
>
> [here $result = recordset]
>
> at present when i click on page 2 it comes in URL as
> mysite.com/ads/page/2
>
> but i want to pass a location id to the next page
> so the URL will be something like
> mysite.com/ads/page/2/location_id/345
>
> Please Help
>
> Regards
> Anees
>
>
> --
> View this message in context:
> http://www.nabble.com/How-can-i-pass-a-variable-using-zend_paginator-tp22716996p22716996.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
>

Reply via email to