Welcome Guest, Not a member yet? Register   Sign In
Best place to put a method that prepare the views ?
#1

[eluser]Rushino[/eluser]
Hello,

I have a method in my controller called renderViews. It actually take 3 views to render to the user.

I am afraid that this method get repeated in each controller.. the problem is that this method use the load function. So it may be needed in the controller.. but i try to find a way to relocalize this method.

So what is the best place to put this method ?

Here a sample of this method..

Code:
private function _renderView($titrePage, $curPage, $contentData, $headerHTML = 'headers/default', $footerHTML = 'footers/default')
    {
        // Create data object for the header        
                $headerData['titre'] = $titrePage;
        $headerData['navigation'] = $this->_generateNavigation($curPage);
        
        // Create data object for the footer
        $footerData['copyright'] = "APP_COPYRIGHT";
        
        // Render to views
        $this->load->view('headers/default', $headerData);
        $this->load->view($curPage, $contentData);
        $this->load->view('footers/default', $footerData);
    }

Thanks.


Messages In This Thread
Best place to put a method that prepare the views ? - by El Forum - 04-23-2011, 10:31 AM
Best place to put a method that prepare the views ? - by El Forum - 04-23-2011, 02:47 PM
Best place to put a method that prepare the views ? - by El Forum - 04-23-2011, 03:00 PM
Best place to put a method that prepare the views ? - by El Forum - 04-23-2011, 09:19 PM
Best place to put a method that prepare the views ? - by El Forum - 04-24-2011, 08:58 AM
Best place to put a method that prepare the views ? - by El Forum - 04-24-2011, 09:45 AM
Best place to put a method that prepare the views ? - by El Forum - 04-24-2011, 09:46 AM
Best place to put a method that prepare the views ? - by El Forum - 04-24-2011, 10:22 AM
Best place to put a method that prepare the views ? - by El Forum - 04-24-2011, 10:25 AM



Theme © iAndrew 2016 - Forum software by © MyBB