What you should do is rename Courses_CoursesController to Courses_IndexController. There's no point "namespacing" the Courses controller a second time. Here's what Courses_IndexController should look like:
PHP Code:
<?php
require_once "Zend/Controller/Action.php";
class Courses_IndexController extends Zend_Controller_Action
{
public function indexAction()
{
echo 'I should be the URL: /courses/ or /courses/index/';
}
public function viewAction()
{
$url = $this->_request->getParam('url');
echo 'I should be the URL: /courses/index/view/ (url: ' . $url . ')';
}
}
Once that works you can use a route so that you can make /courses/view/url work, as well as /courses/index/view/url.
So add this route:
Code:
routes.course.route = "courses/view/:url/*"
routes.course.defaults.module = courses # courses module
routes.course.defaults.controller = index # the controller is now index
routes.course.defaults.action = view # use the view action
PHP Code:
<?php
require_once "Zend/Controller/Action.php";
class Courses_IndexController extends Zend_Controller_Action
{
public function indexAction()
{
echo 'I should be the URL: /courses/ or /courses/index/';
}
public function viewAction()
{
$url = $this->_request->getParam('url');
echo 'I should be the URL: /courses/index/view/ (url: ' . $url . ')';
echo 'I might also be the URL: /courses/view/' . $url . '/');
}
}
I think that should work.
Bookmarks