I am using Ajax paginate it works great.
when a new record is created i would like them to be redirected back
the last page there where at.
So I created a function called GetBack.
I cant figurer how to use my getback function.
So basically how do i use a function
?
if i just add
$this->Session->write('WriteBack',$this->here);
to my index function it works
and if i add
$this->redirect($this->Session->read('WriteBack'));
to my add function it works
Do i add the varible to my index function
like so?
public function index($WriteBack=null)
Also How do i call the function in my view index file ?
//this works
echo $this->Session->read('WriteBack');
//this doesnt
echo $this->Post->GetBack('WriteBack');
//this doesnt
echo $this->WriteBack;
This doesnt work
echo $this->GetBack();
// Post controller
public function index() {
$this->Client->recursive = 0;
$this->paginate = array(
'limit' => 50);
//this works
$this->Session->write('WriteBack',$this->here);
$this->set('clients', $this->paginate());
}
public function GetBack() {
$WriteBack=$this->Session->write('WriteBack',$this->here);
$ReturnAjaxBackLink=$this->Session->read($WriteBack);
$this->set('WriteBack'$WriteBack,'ReturnAjaxBackLink',
$ReturnAjaxBackLink);
}
public function add() {
if ($this->request->is('post')) {
$this->Client->create();
if ($this->Post->save($this->request->data)) {
$this->Session->setFlash(__('The Post has been
saved'));
//this line below redirects after the record has been saved works
$this->redirect($this->Session->read('WriteBack'));
} else {
$this->Session->setFlash(__('The Post could not
be saved. Please,
try again.'));
}
}
$this->set(compact('Post'));
}
//the view index.ctp
<?php
$this->Paginator->options(array(
'update' => '#content',
'evalScripts' => true,
'url'=>$this->parmas ));
?>
<?php
echo $this->Paginator->prev('< ' . __('previous'), array(),
null,
array('class' => 'prev disabled'));
echo $this->Paginator->numbers(array('separator' => ''));
echo $this->Paginator->next(__('next') . ' >', array(), null,
array('class' => 'next disabled'));
?>
</div>
<?php
//this works and changes each time you page threw the records
echo $this->Session->read('WriteBack');
//this doesnt work and i do not get any errors
echo $this->WriteBack;
//this also doesnt work
echo $this->ReturnAjaxBackLink;
//this also doesnt work
echo $this->Session->read('ReturnAjaxBackLink');
?>
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php