Welcome Guest, Not a member yet? Register   Sign In
Simple tips to making your CI application more portable
#11

[eluser]neen[/eluser]
You can override config settings:

$this->config->set_item('config_var', 'value');

I am using this to use a local.php config file in config/ and then I concat the vars in there into another config variable

In this way I can have a config file that gets edited locally (that's not under version control) so I can set the (relative) paths to the CI URL


$this->config->set_item('common_url', $this->config->item('base_url') . $this->config->item('common_path'));
// set the new base url (add local path and site path if needed)
$this->config->set_item('base_url', $this->config->item('base_url') . $this->config->item('site_path'));
#12

[eluser]cyberbuff[/eluser]
sorry for offtopic but how can i separate application and system? Searched the forum but din't get it... Sad
#13

[eluser]neen[/eluser]
Make an application folder outside of system..ie:

outsideapp/
controllers/
models/
config/
etc, etc

Then in your index.php (or whatever it is) change app_path to outsideapp from system/application
#14

[eluser]cyberbuff[/eluser]
thanks for the help
#15

[eluser]Jamie Rumbelow[/eluser]
Nice topic!

I find it helpful to put a few conditionals in the routes file, so that if there is a problem with uploading, the app still runs.
#16

[eluser]neen[/eluser]
The best way to do that would probably be to do that in the _remap function of your controllers...
#17

[eluser]Jonathon Hill[/eluser]
[quote author="Jemgames" date="1219521935"]Nice topic!

I find it helpful to put a few conditionals in the routes file, so that if there is a problem with uploading, the app still runs.[/quote]


Can you provide an example or two? I don't understand what you're talking about here.
#18

[eluser]neen[/eluser]
Code:
/**
         * _remap
         *
         * Intermediary function used to call display->renderPage()
         *
         * @access    public
         */
        public function _remap($method)
        {
            // does the method exist?
            if(method_exists($this, $method))
            {
                // is the end of the string numeric?
                if(is_numeric($this->uri->segment(3)))
                {
                    // set the id
                    $id = $this->uri->segment(3);
                    if($this->uri->total_segments() > 3)
                    {
                        $var = $this->uri->segment(4);
                        // call the function and pass the id and var
                        $this->$method($id, $var);
                    } else {
                        // call the function and pass the id
                        $this->$method($id);
                    }
                } else {
                    // call the function
                    $this->$method();
                }
            }
            // display the page
            // your view here
        }
#19

[eluser]Jonathon Hill[/eluser]
Thanks!

Sooo... what does this do and why would you use it?
#20

[eluser]neen[/eluser]
That function will check to make sure that a function exists before trying to run it...(suppresses the PHP errors, but not the 404)

Also, it lets you wrap your function with pre-function/post-function calls...basically it implements DRY so you can just call a view/display class one time




Theme © iAndrew 2016 - Forum software by © MyBB