Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-19-2008, 03:55 PM
Senior Member
 
Join Date: Jan 2008
Location: chicago
Posts: 101
Default writing custom routes

On my main index page, there is a blurb of text that describes a client. Currently, if you want to see client 38, you would use this url

http://www.domain.com/index/index/client/38

However, I would prefer if the url could be shorter, like this

http://www.domain.com/client/38

I know that I have to add a custom route, but I am not sure where to start.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-01-2008, 07:18 AM
Junior Member
 
Join Date: Mar 2008
Location: BC
Posts: 6
Default

I can give an untested idea based on index/client/38, should be easy to modify it to work with your situation. This doesn't mean its the best way to go, just a suggestion.

In bootstrap you could do something like:

Code:
$router = $controller->getRouter();
$router->addRoute(
    'client',
    new Zend_Controller_Router_Route('client/:id', array(
        'controller' => 'index',
        'action'     => 'client'));
$controller is the handle to your front controller instance eg: $controller = Zend_Controller_Front::getInstance();

That should change http://url/index/client/38 to just http://url/client/38. 38 being an id.

You can check the manual further, that specific routing concept is under Zend_Controller, section 7.5.2.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:44 PM.