March 10, 2012

Send params in URL in different way?

Question by Student

I don’t know how to write title for this question. Anyway this is the scenario ..

I have a table like this


id | username | firstname | lastname
 1 |    ab    |     Aaaa  |    Bbbb
 2 |    yz    |     Yyyy  |    Zzzz

I use following URL to show person profile:   // Show person 1 profile   // Show person 2 profile

Here: person is module, profile is controller and index is action used to get and show user profile using param id

Above scenario is working perfectly.


Now I want to use following URLs to get user profile using usernames   // Show person 1 profile   // Show person 2 profile

Any idea ??


Answer by Starx

By default you don’t need to do anything. Just add /name/THENAME to the last of the url.


  1. Get the value of the name

    $name = $this -> _request -> getParam('name');
  2. Use that values to extract the id from the database

  3. And use it as you want

Please fill the form - I will response as fast as I can!