Welcome Guest, Not a member yet? Register   Sign In
To much functions!
#1

[eluser]WebbHelp[/eluser]
Hi!

I am making a adminpanel, a pretty simple one.
But I just saw that it is pretty many functions and I need to scroll a bit to find a function.

I just wonder... In my controller file, can I "include" other functions from a file in a smart way?

or maybe I just should create more pages?
The thing I don't like is that the adressfield got a big length:
http://www.webbhelp.se/cms/index.php/adm...el/addpage
Maybe this isn't that long, but it is pretty long hehe, the thing is, if a use a new page, I need to put 1 segments more like:
http://www.webbhelp.se/cms/index.php/adm.../sumbitted

Thanks //WebbHelp
#2

[eluser]überfuzz[/eluser]
Sounds like a clear case of overkill.

Give us a clips of the code. Otherwise it's hard to say anything about your code.
#3

[eluser]WebbHelp[/eluser]
Here is a little bit of code...

Code:
function editpage()
    {
        
        if($this->uri->segment(4) == true)
        {
            //Select menu name in the table pages
            $query = $this->db->query("SELECT * FROM pages WHERE id = ". $this->uri->segment(4) ." LIMIT 1");
        
            if($query->num_rows() > 0)
            {
                //Select all data from table pages
                $data['page_query'] = $query->row();
                //Title of the page
                $data['title'] = 'Redigera '. $data['page_query']->menu;
                //The load the editcontent file
                $this->load->view('admin/editcontent', $data);
            }
            else
            {
                $this->redirectindex('editpage/'. $this->db->insert_id());
            }
    
        }
        else
        {
            $this->redirectindex();
        }
    }
    
    
    function submitedit()
    {
                
        //Include the form_validation class
        $this->load->library('form_validation');
        //Check if the id field isn't empty(ignore space)
        $this->form_validation->set_rule

I think I know the problem hehe, in another thread in this forum, a user told me to use models...
I saw a tutorial, a movie-tutorial, he sad that models was the old way, so… I have never used it :S

Maybe that is the problem?

Thanks Smile


EDIT: Maybe it is all the comments to Tongue
#4

[eluser]jedd[/eluser]
Can you elucidate on what your actual problem is?
#5

[eluser]WebbHelp[/eluser]
yes, it was a problem before, but now I know, I need to learn about models Smile

like I sade before: I saw a tutorial, a movie-tutorial, he sad that models was the old way, so… I have never used it :S

My question was why I got so much function, because I heard that codeigniter would be very clean and things like that and I thought I did wrong!
#6

[eluser]mattpointblank[/eluser]
If your editpage() function uses the validation rules in submitedit(), you may as well combine them into one function and have the form submit to itself - the validation class is built to work like this.

And yeah, use models. Keep your database code separate from your processing code (and keep your views/styling separate from these as well).




Theme © iAndrew 2016 - Forum software by © MyBB