Welcome Guest, Not a member yet? Register   Sign In
How to create a common controller type? Does it makes sense?
#1

Hello,

first, thanks for this fine framework.
I'll still starting, but feel fine.

I've create a controller which can load several pages as parameter.

Code:
    public function view($page = "dashboard")
    {
        if ( ! file_exists(APPPATH.'/views/page/'.$page.'.php'))
        {
            show_404();
        }
        
        $this->load->model('pages_nav');
        
        $data = array();
        $data['nav_list'] = $this->pages_nav->getNavArray();
        $data['titles'] = $this->pages_nav->getTitlesForPage($page);
        $data['base_url'] = base_url();
        $data['page_title'] = "Mail2Log";
        $data['current_user'] = "Stefan Kittel";
        $data['logout_url'] = base_url() . "logout";
        
        $this->load->view('page/_header', $data);
        $this->load->view('page/_nav', $data);
        $this->load->view('page/_top_header', $data);
        $this->load->view('page/_content_pre', $data);
        $this->load->view("page/" . $page);
        $this->load->view('page/_content_post', $data);
        $this->load->view('page/_footer1', $data);
        $this->load->view('page/_list', $data);
        $this->load->view('page/_footer2', $data);
    }

I use a modul to dynamic create an array getNavArray().

This works fine, but I'm unsure how to work on with this.
I want to add JSQuery datatables and more to several pages.

So I can select here which page to show and load the data I need.
But I think this will look awefull and I will loose the overview.

I could create one controller for each sections.
But than I must add this block to alle controllers.
If I change the theme, I must modify all controllers.

Can I extend the controller to my own version?
Or should I create a library where I call GetPageInfos and GetAllPageViews?

Thanks

Stefan
Reply


Messages In This Thread
How to create a common controller type? Does it makes sense? - by StefanKittel - 01-25-2016, 11:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB