开发者

zend, access app without loading controllers?

开发者 https://www.devze.com 2023-03-24 02:21 出处:网络
if i wanted to have my app load profile names, like 开发者_Python百科this:www.mydomain.com/simonwhere simon isnt a controller, its the username of the user to bring up the profile, is this possible?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消