Re: [fw-general] How can i pass a variable using zend_paginator

2009-03-27 Thread David Mintz
The Zend_View_Helper_PaginationControl helper provides a paginationControl()
method that lets you pass in additional params as an optional 4th argument.
FWIW.

On Thu, Mar 26, 2009 at 3:21 AM, Anees  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?
>


-- 
David Mintz
http://davidmintz.org/

The subtle source is clear and bright
The tributary streams flow through the darkness


Re: [fw-general] How can i pass a variable using zend_paginator

2009-03-26 Thread Anees

Hi Justin
Thanks for your wonderful effort

I just tried to solve by using Registry

i set an array of the extra elements in my controller

from my pagination.html file i added the extra element into the array and
using 'url()' function i generated the whole link

In Controller
$this->registry->set('url_array', array('extra_var1' =>
$this->view->id,'extra_var2' => $this->view->name));

in pagination.phtml

$registry   = Zend_Registry::getInstance();
if ($registry->isRegistered('url_array')) 
$this->url_array= $registry->get('url_array');
else
$this->url_array= array();

.
.
.
$this->url_array['page'] = $this->previous;
.
.
"url_array); ?>">Previous 


Thanks
Anees


-- 
View this message in context: 
http://www.nabble.com/How-can-i-pass-a-variable-using-zend_paginator-tp22716996p22736117.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] How can i pass a variable using zend_paginator

2009-03-26 Thread Justin Barnes
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  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.
>
>


[fw-general] How can i pass a variable using zend_paginator

2009-03-26 Thread Anees

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.