Welcome Guest, Not a member yet? Register   Sign In
How to simplify a controller?
#1

[eluser]Juan Velandia[/eluser]
Hello Everyone, I'm looking for a way to avoid repeat all the repeated lines in this controller, Any Ideas?

Code:
function section($section)
    {
        $data['meta_title'] = $query_row->meta_title;
        $data['meta_description'] = $query_row->meta_description;
        $data['meta_keywords'] = $query_row->meta_keywords;
        $data['item_placeholder_1'] = $this->item_placeholder_model->show_item_placeholder_1();
        $data['product_placeholder'] = $this->item_placeholder_model->show_product_placeholder();
        $data['section_articles'] = $this->section_content_model->get_section_articles();
        $data['section_content'] = $this->section_content_model->get_section_content();
        $data['article_header'] = $this->article_content_model->get_article_header($section);

        $partials = array('top_logo'=>'view_top_logo','top_menu'=>'view_top_menu', 'top_banner'=> 'view_top_banner','mid_banner'=> 'view_mid_banner' ,'main_container'=> 'view_main_section','left_menu'=> 'view_left_menu','credit_nemo'=> 'view_credit_nemo', 'meta_head'=> 'view_meta_head');
        $this->template->load('master_section', $partials, $data);
    }

    function product($section)
    {
        $data['meta_title'] = $query_row->meta_title;
        $data['meta_description'] = $query_row->meta_description;
        $data['meta_keywords'] = $query_row->meta_keywords;
        $data['item_placeholder_1'] = $this->item_placeholder_model->show_item_placeholder_1();
        $data['product_placeholder'] = $this->item_placeholder_model->show_product_placeholder();
        $data['section_articles'] = $this->section_content_model->get_section_articles();
        $data['section_content'] = $this->section_content_model->get_section_content();
        $data['article_header'] = $this->article_content_model->get_article_header($section);
        $data['product_content'] = $this->product_content_model->get_product_content();
        $data['product_component'] = $this->product_content_model->get_product_component();
        
        $partials = array('top_logo'=>'view_top_logo','top_menu'=>'view_top_menu', 'top_banner'=> 'view_top_banner','main_container'=> 'view_main_product','left_menu'=> 'view_left_menu','credit_nemo'=> 'view_credit_nemo', 'meta_head'=> 'view_meta_head');
        $this->template->load('master_section', $partials, $data);
    }


    function article()

{
        $data['meta_title'] = $query_row->meta_title;
        $data['meta_description'] = $query_row->meta_description;
        $data['meta_keywords'] = $query_row->meta_keywords;
        $data['item_placeholder_1'] = $this->item_placeholder_model->show_item_placeholder_1();
        $data['product_placeholder'] = $this->item_placeholder_model->show_product_placeholder();
        $data['section_content'] = $this->section_content_model->get_section_content();
        $data['section_articles'] = $this->section_content_model->get_section_articles();
        $data['article_content'] = $this->article_content_model->get_article_content();

        $partials = array('top_logo'=>'view_top_logo','top_menu'=>'view_top_menu','top_banner'=> 'view_top_banner','main_container'=> 'view_main_article','left_menu'=> 'view_left_menu','credit_nemo'=> 'view_credit_nemo','meta_head'=> 'view_meta_head', 'contact_container'=> 'view_contact_form');
        $this->template->load('master_section', $partials, $data);

    }

Thanks a lot!


Messages In This Thread
How to simplify a controller? - by El Forum - 11-13-2010, 10:35 AM
How to simplify a controller? - by El Forum - 11-13-2010, 11:59 AM
How to simplify a controller? - by El Forum - 11-13-2010, 01:04 PM
How to simplify a controller? - by El Forum - 11-13-2010, 02:21 PM
How to simplify a controller? - by El Forum - 11-14-2010, 10:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB