dean jase
dean jase

Reputation: 1161

zend, access app without loading controllers?

if i wanted to have my app load profile names, like 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...

Upvotes: 0

Views: 50

Answers (2)

Vika
Vika

Reputation: 3285

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.

Upvotes: 3

ChrisA
ChrisA

Reputation: 2101

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.

Upvotes: 0

Related Questions