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

[eluser]smilie[/eluser]
Sure, easy...

Code:
function show($what='',$section='')
{
        # This is always same
        $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 ? $section : ''));

        # This is extra, only in case type = product
        ($what=='product' ? $data['product_content'] = $this->product_content_model->get_product_content() : '');
        ($what=='product' ? $data['product_component'] = $this->product_content_model->get_product_component() : '');
}

Maybe I missed something, double check it.

Idea is, you always call same controller (show) and tell it $what to show and in case $section is present to use it.

Cheers,
Smilie


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