0

I need to make an action method that will receive a parameter in the url, perform a search and return an array. Anyway, that's not the problem. My problem is that I want a url like 'baseurl/frontname/param'. I don't know how to do this. I've already seem a Magento site performimg same operation with a url like 'baseurl/frontname/index.php?/param'. It's good for me too.

Can someone help me to realize it?

0

I assume you have a module and a controller that performs the search.
If so, you can get the url like this:

 Mage::getUrl('module/controller/action', array('param_name1'=>'value1', 'param_name2'=>'value2', ....));

This will generate something like this:

 BASE_URL/module/controller/action/param_name1/value1/param_name2/value2/...

If you want the params to be in the query string do this:

Mage::getUrl('module/controller/action', array('_query'=>'param_name1=value1&param_name2=value2'));  

This will generate:

BASE_URL/module/controller/action?param_name1=value1&param_name2=value2

If you don't want the controller name and action name in the url, then name your controller IndexController and your action indexAction and get the url like this:

Mage::getUrl('', array('_direct'=>'module', '_query'=>'param_name1=value1&param_name2=value2'))

This will generate

 BASE_URL/module?param_name1=value1&param_name2=value2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.