Welcome Guest, Not a member yet? Register   Sign In
A better way to handle params?
#4

[eluser]mddd[/eluser]
If I get you correctly, there are basically 3 pages:
1- a page to show info about a city
2- a page to show a list of packages
3- a page to show info about a specific package.

I would make the urls as short as possible, like so:
/stag-do/bristol : show page type 1
/stag-do/bristol/packages : show page type 2
/stag-do/bristol/2 : show page type 3 (if you like this could also be /stag-do/bristol/packages/2 but why make it longer than neccessary)

You could do all the checking in your _remap function in the stag_do class:
Code:
function _remap()
{
  $city = $this->uri->segment(2);
  $package = $this->uri->segment(3);  // i'm using url like /stag-do/bristol/2 here

  // if $city=='index' then there was no city given
  if ($city=='index')
    $this->not_found();

  // if $package is not set, show the city info
  else if (!$package)
    $this->show_city($city);

  // package is set. is it 'packages'? then show the list
  else if ($package=='packages')
    $this->show_packages($city);

  // it's not 'packages'. display the package with this number from this city.
  else
    $this->show_package($city, $package);
}
Of course you need to check if the given city exists, and if a given package exists. But the idea is clear I hope?


Messages In This Thread
A better way to handle params? - by El Forum - 07-30-2010, 05:32 AM
A better way to handle params? - by El Forum - 07-30-2010, 06:07 AM
A better way to handle params? - by El Forum - 07-30-2010, 06:27 AM
A better way to handle params? - by El Forum - 07-30-2010, 06:31 AM
A better way to handle params? - by El Forum - 07-30-2010, 06:38 AM



Theme © iAndrew 2016 - Forum software by © MyBB