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


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-18-2008, 03:17 PM
Junior Member
 
Join Date: Feb 2008
Posts: 2
Default Simpler variables in URL

I can get my site to work as follows
http://www.site.com/products/view/name/<productName>

But would like it to be
http://www.site.com/products/<productName>

Is there a default param name I can grab from within the product controller's index action? What's a good way of grabbing the product name and having my way with it?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-18-2008, 10:47 PM
Senior Member
 
Join Date: Jan 2008
Location: chicago
Posts: 101
Default

If you don't want to modify the controller (i don't recommend messing with it right off the bat),The URL must follow this pattern:

yoursitehere.com/controller/action/key1/value1/key2/value2/

It sounds like this doesn't suit you though so you should read up on Zend_Controller_Router_Rewrite

Last edited by notrub225 : 02-18-2008 at 10:55 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-19-2008, 01:29 AM
Junior Member
 
Join Date: Feb 2008
Posts: 2
Default

Thanks,
I read up on the router and it seems to work great.

For those who wish to know how I did it, in my public index I added:

PHP Code:
Zend_Loader::loadClass('Zend_Controller_Front');
Zend_Loader::loadClass('Zend_Controller_Router_Rewrite');

$router = new Zend_Controller_Router_Rewrite();
$ctrl Zend_Controller_Front::getInstance();
$router $ctrl->getRouter();

$router->addRoute('product', new Zend_Controller_Router_Route('products/:productName', array('controller'=>'products','action'=>'view'))); 
So, instead of
http://site.com/Products/view/productName/<productName>

you can get the same result with
http://site.com/Products/<productName>
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 02:43 PM.