Welcome Guest, Not a member yet? Register   Sign In
How to load view if function not exists?
#11

[eluser]jedd[/eluser]
Correct.

From what I understand, this is probably the easiest way to deal with / provide for your dynamic third parameter in the URL.
#12

[eluser]codeworxx[/eluser]
Yeah that's right. I have never thought about it!!! Think i have to do! Smile
#13

[eluser]John_Betong[/eluser]
[quote author="codeworxx" date="1257372504"]@John_Betong
It's a nice start, but the categories may created, changed, added by the owner of the Shop, so i cannot define anything in the routes.php!!

@Jedd
I'm about to create - but the URL "Design" is ready and chosen by the Customer. With "Designed" I just mean how URLs have to look like.

What do you mean with "bring everything down a level"??? Don't understand that?!?![/quote]
 
 
Ok as Jedd mentioned "bring down one more level"

In my latest project I 'hard-code' pre-defined controllers/methods and then have a "catch-all" because I am unable to predict what is being entered.

In the routed controller/index function/method I check every URI parameter and see if there is a match. As you can expect if there is no match then a "Whoops/Sorry..." default is shown.

The beauty about this is that a controller need not be specifed. Your program will catch these URLs and it is up to you what you do with them Smile

http://your_domain.com/acer
http://your_domain.com/pc/sony/v100
http://your_domain.com/laptop/sony/v100
http://your_domain.com/sony/v100-s
http://your_domain.com/hd/
http://your_domain.com/hard-drive
http://your_domain.com/pc/hp
http://your_domain.com/hewlett-packard
http://your_domain.com/mem/1-gig
http://your_domain.com/memory/two-gig

Code:
// ./config/routes.php

// predfined routes
  $routes['category/systems/:any'] = 'category/systems';
  $routes['category/memory/:any']   = 'category/memory';
  $routes['listing/systems/:any']   = 'listings';

// catch-all routes - MUST follow pre-defined routes
// the catch-all route I use
$route['(.*)/?'] = '/controller_name_not_shown/index/$1';

// another catch-all routing method not tried
// $route['(:any)'] = '/controller_name_not_shown/index/$1';
 
Believe me I have and still struggle with routing. I wish there was a more comprehensive explanation to this very powerful technique.
 
 




Theme © iAndrew 2016 - Forum software by © MyBB