views:

55

answers:

1

The problem is i want to call the index function, i need it to render the view and then the afterFilter to redirect again to the index function and do the same.. Like a loop, the problem is it doesnt render it, ive tried using $this->render('index') but it doesnt work and also other things..

PS: I didnt include all the code that i have in index, because its pointless, doesnt render with or without it, just included the things i needed for the view.

function afterFilter()
{

if ($this->params['action'] == 'index')
{
   sleep(3);
   $this->redirect(array('action'=>'index',$id), null, true);
}

}

THE FUNCTION

function index($ido = 0)
{

$this->set('Operator', $this->Operator->read(null, $ido));
$this->set('ido', $ido);
}

THE VIEW = INDEX.CTP

  <legend>Operator StandBy Window</legend>
  <?php



  ?>

 </fieldset>

   <?php echo $html->link('LogIn', array('controller' => 'operators', 'action' => 'add'));  ?>
   <?php echo $html->link('LogOut', array('controller' => 'operators', 'action' => 'logout',$ido));  ?>
+1  A: 

a function that constantly checks my database for a change, if a change occurs ill redirect, if not i need to have that constant loop of 'checking the database' and 'rendering the view'.

This is not possible entirely on the server with PHP, and especially not with CakePHP's template system. PHP just "makes pages" on the server and sends them to the browser and a linear fashion. If you loop on the server, the content of your page will just repeat itself:

Normal content
Normal content
Normal content
<redirect>

To redirect the client, you need to output headers. The headers need to be output before anything else. If you've already looped a few times and content has already been sent to the client, you can't redirect anymore.

There are two ways:

deceze