• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
$route[':any'] issue

#31
[eluser]Pascal Kriete[/eluser]
@eesam extending core classes.

In this case you will need to override the whole function since the 404 stops the script. There are times when you just want to add something to the end, in which case you would user parent::function_name() to call the parent function.

Here's how you would go about doing it for this example. Create a file called MY_Router.php in the application/libraries folder:
Code:
class MY_Router extends CI_Router {
    
    /**
     * Constructor
     *
     * @access    public
     */
    function MY_Router()
    {
        parent::CI_Router();
    }
    
    // --------------------------------------------------------------------
    
    /**
     * Validate Routing Request
     *
     * @access    public
     */
    function _validate_request($segments)
    {
        /* Copy the original function in here and change that last line: */
        
        return array('welcome', 'show_page', $segments[0]);
    }
}

And since you're not changing any core files this is pretty worry free and usually upgrades nicely.

Steve Wright's method is easiest if you only have a few other pages, but it does get tedious with a lot of them.

#32
[eluser]Randy Casburn[/eluser]
@inparo - soon we will have written it for EEssam, but hey, I'm having fun ;-)


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.