PHP-Zend
PHP-Zend

Reputation: 311

redirect to a controller via a hyperlink

I'm new to php, MVC and Zend Framework. I need to redirect to a controller/action via a hyperlink. I used this, as I have used it in a form to redirect to a controller. <a href="mycontroller/myaction"> But this time, it didn't work.

my controller is a very basic controller, where I only tried to dispaly the view conneced to the controller. Here it is:

<?php

class NewUserController extends Zend_Controller_Action {

public function init()
{
    /* Initialize action controller here */
}

public function newuserAction()
{
    $this->view->newuser;
}
}

?>

I searched for answers and every answer was similar to what I have done. please help me to sort this out.

Thanks in advance Charu

Upvotes: 1

Views: 139

Answers (1)

J.K.A.
J.K.A.

Reputation: 7404

First change your controller name NewUser to Newuser and try to pass url like this :

<?php $url = $this->url(array("controller" => "Newuser", "action" => "newuser")); ?>
<a href="<?php echo $url; ?>">test</a>

And in controller :

<?php

class NewuserController extends Zend_Controller_Action {
    public function init() {
        /* Initialize action controller here */
    }

    public function newuserAction() {
        $this->view->newuser;
        echo "----In newuserAction()----";      
    }
}
?>

Hope it will work for you.

Upvotes: 2

Related Questions