CodeIgniter Forums
My Ultra Admin Goal [issue #1] -> editing multiple blog posts at the same time - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: My Ultra Admin Goal [issue #1] -> editing multiple blog posts at the same time (/showthread.php?tid=9222)



My Ultra Admin Goal [issue #1] -> editing multiple blog posts at the same time - El Forum - 06-17-2008

[eluser]Dagobert Renouf[/eluser]
Hello guys, hope you're doing great right now (I do care).

I'm in the process of creating my first web-app (ehhhaaaa) with C.I, as it's ambitious i'm running into numerous problem.
The project is an ultimate blog system, that will become a great basis for future projects of mine.
Here's the first thing I want to ask about it :


My blog_post admin controller display posted articles with a checkbox next to it. The user can then check some and choose an action (currently edit and delete) to do with all items; as I already handled the delete part, I wonder how I can create a function in my blog_post controller that would allow the user to edit in the same time all the selected blog posts.

I already tried a few solutions of mine, but I must say I'm still a mediocre developer, so it wasn't very efficient.

Below I show you the "add" code to add an article, I believe the "edit" function will be much of the same thing, but I didn't manage to put things right (as the main issue is to handle multiple articles editing at the same time).

Code:
function add()
    {
        // load helpers, model and libraries
        $this->load->helper(array('form', 'url'));
        $this->load->library('validation');
        $this->load->model('admin/blog_post_model');
        //

        // page informations
        $data['title'] = 'Ajouter un article';
        $data['query_articles'] = $this->blog_post_model->get_all_entries();
        $data['articles_options'] = array('edit' => 'Edit', 'delete' => 'Delete');
        //

        // set validation rules
        $rules['title'] = "required|min_length[5]|max_lenght[128]";
        $rules['article'] = "required|min_length[5]";
        $this->validation->set_rules($rules);
        //

        // allow repopulation if a validation error occurs
        $fields['title'] = 'Title';
        $fields['article'] = 'Article';
        $this->validation->set_fields($fields);
        //

        $this->title_value = $this->validation->title;
        $this->article_value = $this->validation->article;

        // run the validation process to make sure everything is ok
        if($this->validation->run() == FALSE)
        {
            // validation prints out errors by itself, see view file
        }
        else
        {
            // insert entry
            $this->blog_post_model->insert_entry();
        }
        //

        // load view
        $this->load->view('admin/blog_post_add_view', $data);
        //
    }



I hope you'll be able to help me out with this, also feel free to comment my add code, I'm sure it sucks somewhere :-D.