zend, access app without loading controllers?
if i wanted to have my app load profile names, like 开发者_Python百科this: www.mydomain.com/simon where simon isnt a controller, its the username of the user to bring up the profile, is this possible?
class ProfileController extends Zend_Controller_Action {
public function init() {
}
public function indexAction(){
echo $this->_request->getParam('profileuser');
this is where i can display the user.
}
or something...
You might use Zend_Route
for this purpose.
Just add the following to your application Bootstrap:
protected function _initRoutes()
{
$frontController = Zend_Controller_Front::getInstance();
$router = $frontController->getRouter();
$router->addRoute('profile', new Zend_Controller_Router_Route(
':profileuser',
array('module' => 'default', 'controller' => 'profile', 'action' => 'index')
));
}
More information on using Zend_Controller_Router
here.
Presuming ProfileController
is your default Controller, so you will get there by default, you can use
$profileName = ltrim($this->getRequest()->getRequestUri(), "/");
in indexAction
to get 'simon' from your url.
精彩评论