Welcome Guest, Not a member yet? Register   Sign In
Missing argument for function
#1

[eluser]ping timeout[/eluser]
Hello,
I would like to know how I can change the error message for a function that needs and argument.

I have something like this:
the controller: menu
function in controller: category
argument for function: category-name
The URL is index.php/menu/category/category-name but if someone changes the URL to something like index.php/menu/category// it gives an ugly warning, instead I would like to redirect that user to index.

Code:
function category($link)
    {
        if(isset($link))
        {
            $this->load->library('form_validation');
            if($this->form_validation->alpha_dash($link))
                return $this->_category($link);
        return $this->load->view('404');
        }
        return $this->index();
    }
#2

[eluser]kyleect[/eluser]
Code:
function category($link = NULL)

Then use the is_null function to check it.
#3

[eluser]ping timeout[/eluser]
That works fine, thank you.
I have another question, if I need to call, inside a function from controller index, a function from controller menu. What is the best practice for that? Right now I use this:
Code:
require_once('menu.php');
Menu::index();
#4

[eluser]jedd[/eluser]
[quote author="ping timeout" date="1258932270"]
I have another question, if I need to call, inside a function from controller index, a function from controller menu. What is the best practice for that? Right now I use this:
[/quote]

It's possible that this question is answered in the [url="/wiki/FAQ"]FAQ[/url] .. specifically the first question in the Design section.




Theme © iAndrew 2016 - Forum software by © MyBB