0

I have set up a controller called links, i have the routes to several pages being directed to this controller and within this controller I have a number of different functions for accessing different parts of the page through ajax calls. Here is a sample from my routes config:

    $route['games'] = "links";   
    $route['games/ajax_pager'] = "links/ajax_pager";
    $route['games/ajax_dbr/(:any)'] = "links/ajax_dbr/$1";
    $route['games/linkinfo/(:num)'] = "links/linkinfo/$1";
    $route['games/linkobj/(:num)'] = "links/linkobj/$1";
    $route['links'] = "links";
    $route['links/ajax_pager'] = "links/ajax_pager";
    $route['links/ajax_dbr/(:any)'] = "links/ajax_dbr/$1";
    $route['links/linkinfo/(:num)'] = "links/linkinfo/$1";

what I would like to do now is have a variable from the second segment of the url passed to the index function if it doesnt match up with any of the functions routed to above. So something like this:

$route['games/(:any)'] = "links/$1";

but this isn't working is there any way to do this without creating a new function. Hope this is clear - please let me know if any clarification is required. An dthanks in advance for any help.

2
  • what error/"isn't working" symptoms are you seeing? Commented Mar 16, 2012 at 16:17
  • Well I was getting a lot of undefined variable errors but I have just realised that is because it is following the 404 override route (which I havent set up yet) - wondering if I can use this. Commented Mar 16, 2012 at 16:31

1 Answer 1

1

The first segment is the controller, the second segment is the function and the third can be your variable. So if you whish to send a variable to the index function of the links controller this would look like this:

$route['games/(:any)'] = "links/index/$1";

No when someone browses to index.php/games/atestvariable the index function of the links controller with variable atestvariable will be called.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.