Welcome Guest, Not a member yet? Register   Sign In
The usual tight deadline on a project - Advice would be appreciated
#1

[eluser]Unknown[/eluser]
Hi,

I've done the usual trick of biting off more than I can chew. I need to produce a database driven website on Code Igniter for 1st Jan launch.

Now I've been doing tutorials and such, and understand how to cover most of the development bases but there's one thing I'm not sure about how to approach.

This is the premise:

* The site lists multiple types of events/locations across multiple sections using maps etc
* Sponsors have their own branded (e.g. their logo and blue) version of the site which is called via a specific url


Now the sponsors bit I'm unsure of how to handle. The premise would be to have a url structure like the following:

Code:
/2/ - Homepage
/2/restaurants/ - LIST VIEW
/2/restaurants/1234231 - SINGLE VIEW
/2/shops/ - LIST VIEW
/2/shops/123433 - SINGLE VIEW
...

So the 2 in this case is the ID of the sponsor Joe Bloggs. So /3/ would load the sponsor styling of Jim Bloggs.

It may be a simple question for someone in the know, but should I approach this?

Any help is really appreciated.

Thanks

Michael
#2

[eluser]CroNiX[/eluser]
You can do that with routes.

An example would be:
Code:
//If there is a number in first segment, "restaurants" in 2nd segment and a number in 3rd segment, pass the first and 2nd number to this controller/method for the individual view
$route['(:num)/restaurants/(:num)'] = 'your_controller/your_single_view_method/$1/$2';

//If there is a number in the first segment and "restaurants" in the 2nd segment, pass the number to this controller/method for the list view
$route['(:num)/restaurants'] = 'your_controller/your_list_view_method/$1';

//If there is only a number as the first segment, pass the number to this method for the homepage
$route('(:num)'] = 'your_controller/your_homepage_method/$1';
Routes need to be in order of most segments to fewest. So the first route has 3, the 2nd has 2 and the 3rd has 1, so they should be in this order.

Then in your_controller:
Code:
function your_single_view_method($sponsor_id = 0, $restaraunt_id = 0)  //This is $1 and $2 from the route
{
}
function your_list_view_method($sponsor_id = 0) //This is $1 from the route
{
}
function your_homepage_view($sponsor_id = 0) //This is $1 from the route
{
}
#3

[eluser]Unknown[/eluser]
Hi CroNiX

Many thanks for the quick reply. This is exactly what I was looking for. Now is the time to try and implement everything in double quick time Smile

Thumbs up for this community, hopefully I'll be able to reach a level where I can help out to.

Thanks





Theme © iAndrew 2016 - Forum software by © MyBB