Reputation: 694
I'm working with zend framework. In a view i use an action helper.
echo $this->action('info', 'comment', null, array('articleID' => $article->arti_id));
So, the helper call 'CommentController' class and method 'infoAction'. Inside my method i get the 'articleID' param and i begin process with model. Finally i render a shared view.
public function infoAction() {
$articleID = $this->getRequest()->getParam('articleID');
// Working with model
// .....
$this->renderScript('/View/Script/DefaultComment.phtml');
}
It's work well but i don't want that this controller/action be directly accessible by the url domain.com/comment/info
.
How can i avoid this ?
Thx
Upvotes: 2
Views: 670
Reputation: 5693
If your action method is always called with an article id parameter, then you could redirect the request in case there is no id:
public function infoAction() {
if ($this->_hasParam('articleID')) {
$articleID = $this->getRequest()->getParam('articleID');
// Working with model
// .....
$this->renderScript('/View/Script/DefaultComment.phtml');
} else {
$this->_helper->redirector('index', 'index', 'default');
}
}
Upvotes: 3