Welcome Guest, Not a member yet? Register   Sign In
Dynamic page
#18

[eluser]jdfwarrior[/eluser]
That is where you get into using the _remap function like I showed you earlier.

The way CI is set up, it load/calls things in this manner.
http://www.example.com/controller-name/f.../arg2/etc/

So if you entered example.com/country/France in the url, it would load the Country controller, and call the France function. In your situation, you do not want to have to create a function for all the possibilities. You would use the _remap function, which overrides calling functions by the name specified in the url. You catch the name in the url with the _remap function and from there, determine how to handle the data. So, in the example I gave you earlier.

Code:
function _remap($func) {
    switch ($func) {
        case "index": $this->index();
                default: {

                        //Your code would go here.

                        //Initiate database query to check and see if a page named $func
                        //exists in the database. If it does, retrieve the information for
                        //that page and store it in variables as you did in the index function.
                        //Once you have that information, load the view you want, and pass the
                        //data you got from the database, to the view for display.

                        //If the page is not found to exist in the database, then use show_404()
                        //function to display an error to the user.
                }
    }
}


Messages In This Thread
Dynamic page - by El Forum - 04-21-2009, 07:43 AM
Dynamic page - by El Forum - 04-21-2009, 07:51 AM
Dynamic page - by El Forum - 04-21-2009, 07:59 AM
Dynamic page - by El Forum - 04-21-2009, 08:49 AM
Dynamic page - by El Forum - 04-21-2009, 10:54 AM
Dynamic page - by El Forum - 04-21-2009, 11:48 AM
Dynamic page - by El Forum - 04-21-2009, 11:54 AM
Dynamic page - by El Forum - 04-22-2009, 03:51 AM
Dynamic page - by El Forum - 04-22-2009, 05:44 AM
Dynamic page - by El Forum - 04-22-2009, 07:24 AM
Dynamic page - by El Forum - 04-22-2009, 08:01 AM
Dynamic page - by El Forum - 04-22-2009, 08:44 AM
Dynamic page - by El Forum - 04-22-2009, 08:53 AM
Dynamic page - by El Forum - 04-22-2009, 09:16 AM
Dynamic page - by El Forum - 04-22-2009, 09:22 AM
Dynamic page - by El Forum - 04-22-2009, 09:32 AM
Dynamic page - by El Forum - 04-22-2009, 11:47 AM
Dynamic page - by El Forum - 04-22-2009, 12:00 PM
Dynamic page - by El Forum - 04-22-2009, 12:04 PM
Dynamic page - by El Forum - 04-22-2009, 12:09 PM



Theme © iAndrew 2016 - Forum software by © MyBB