Welcome Guest, Not a member yet? Register   Sign In
Opinions on how far to take MVC
#1

[eluser]jamie young[/eluser]
I have just started using CI and find myself questioning what is the 'right' way to do things, which I think is really deciding how far to take the MVC methodology. This is basically an example of using a custom config of a 'site title' to generate a page title to put on a page. Any feedback you can offer on which method you prefer is appreciated. I am only including the most minimal of code to show these examples.

Example 1
Config
Code:
$config['site_title'] = 'Generic Site Title';

View
Code:
<title><?= $this->config->item('site_title'); ?> - Page</title>


Example 2
Config
Code:
$config['site_title'] = 'Generic Site Title';

Controller
Code:
$data['page_title'] = "{$this->config->item('site_title')} - Page";

View
Code:
<title><?= $page_title; ?></title>


Example 3
Config
Code:
$config['site_title'] = 'Generic Site Title';

Controller
Code:
$data['page_title'] = "{$this->Page_model->getSiteTitle()} - Page";

Model
Code:
function getSiteTitle()
{
    return $this->config->item('site_title')
}

View
Code:
<title><?= $page_title; ?></title>


Messages In This Thread
Opinions on how far to take MVC - by El Forum - 10-30-2008, 07:02 PM
Opinions on how far to take MVC - by El Forum - 10-30-2008, 08:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB