<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Getting Started With CodeIgniter &#8211; 5</title>
	<atom:link href="http://www.lizjamieson.co.uk/2008/11/25/getting-started-with-codeigniter-5/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lizjamieson.co.uk/2008/11/25/getting-started-with-codeigniter-5/</link>
	<description>SEO, Internet Marketing and Web Design Thoughts</description>
	<lastBuildDate>Tue, 09 Mar 2010 20:41:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Liz Jamieson</title>
		<link>http://www.lizjamieson.co.uk/2008/11/25/getting-started-with-codeigniter-5/comment-page-1/#comment-1028</link>
		<dc:creator>Liz Jamieson</dc:creator>
		<pubDate>Thu, 04 Dec 2008 11:48:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.lizjamieson.co.uk/?p=367#comment-1028</guid>
		<description>Hi Rebecca
I wrote these posts for the purpose of encouraging (and hopefully not leading astray), other people like me who are learning CI and MVC simultaneously and on their own.  In  &lt;a href=&quot;http://www.lizjamieson.co.uk/2008/12/03/getting-started-with-codeigniter-6/&quot; rel=&quot;nofollow&quot;&gt;the next post&lt;/a&gt;, I&#039;ve extended the controller as suggested by Noah.</description>
		<content:encoded><![CDATA[<p>Hi Rebecca<br />
I wrote these posts for the purpose of encouraging (and hopefully not leading astray), other people like me who are learning CI and MVC simultaneously and on their own.  In  <a href="http://www.lizjamieson.co.uk/2008/12/03/getting-started-with-codeigniter-6/" rel="nofollow">the next post</a>, I&#8217;ve extended the controller as suggested by Noah.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rebecca Skinner</title>
		<link>http://www.lizjamieson.co.uk/2008/11/25/getting-started-with-codeigniter-5/comment-page-1/#comment-1026</link>
		<dc:creator>Rebecca Skinner</dc:creator>
		<pubDate>Thu, 04 Dec 2008 11:01:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.lizjamieson.co.uk/?p=367#comment-1026</guid>
		<description>Just stumbled across this blog post series while searching for answers to the exact same problem - just starting out with CodeIgniter, very little MVC knowledge, lots of static pages to build, a few dynamic ones, what to do about Controllers... 

I feel a lot more enlightened now, especially reading Noah&#039;s comment about extending the base Controller, that seems like a great way to go :)</description>
		<content:encoded><![CDATA[<p>Just stumbled across this blog post series while searching for answers to the exact same problem &#8211; just starting out with CodeIgniter, very little MVC knowledge, lots of static pages to build, a few dynamic ones, what to do about Controllers&#8230; </p>
<p>I feel a lot more enlightened now, especially reading Noah&#8217;s comment about extending the base Controller, that seems like a great way to go <img src='http://www.lizjamieson.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Liz Jamieson</title>
		<link>http://www.lizjamieson.co.uk/2008/11/25/getting-started-with-codeigniter-5/comment-page-1/#comment-985</link>
		<dc:creator>Liz Jamieson</dc:creator>
		<pubDate>Fri, 28 Nov 2008 11:29:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.lizjamieson.co.uk/?p=367#comment-985</guid>
		<description>Noah - I&#039;ve made the changes as you suggested.  I completely misunderstood what you meant by using the MY_Controller technique to *extend* the default controller class. I somehow mistook that MY_  process as how you *re-write* the controller class.  Which of course it isn&#039;t.  You are quite right about the examples and docs.  I will write up another post describing your solution, which now works for me later today if I can.   Thanks again.</description>
		<content:encoded><![CDATA[<p>Noah &#8211; I&#8217;ve made the changes as you suggested.  I completely misunderstood what you meant by using the MY_Controller technique to *extend* the default controller class. I somehow mistook that MY_  process as how you *re-write* the controller class.  Which of course it isn&#8217;t.  You are quite right about the examples and docs.  I will write up another post describing your solution, which now works for me later today if I can.   Thanks again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Noah Botimer</title>
		<link>http://www.lizjamieson.co.uk/2008/11/25/getting-started-with-codeigniter-5/comment-page-1/#comment-984</link>
		<dc:creator>Noah Botimer</dc:creator>
		<pubDate>Fri, 28 Nov 2008 06:04:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.lizjamieson.co.uk/?p=367#comment-984</guid>
		<description>Liz -- I&#039;m glad to chime in.  I&#039;ve been convinced that the folk wisdom archived on blogs is pretty powerful.  The more we discuss in the open, the better off we all are.

Something I think is lacking around all these MVC frameworks is novel strategies and patterns for structuring your app.  The samples are usually trivial and don&#039;t get to any number of the moderately tough problems likely to be the first you hit in an app.  I think the model and controller per table approach in many examples is particularly brainwashing.

Anyway...  The danger is when you start changing a lot of behavior of a base component or replacing it entirely.  In this case, the change is simple, so you would probably choose the path that feels the best -- it&#039;s not going to be hard to change gears later either way.  If you do that asset setup the same on every page, you should really consider putting it in your overall base Controller, whether using MY_ or a standalone library (CI gurus, please chime in.)

However you structure it, you have a set of tools for avoiding code duplication.  Here, it seems like you have commonality across a large section, where it&#039;s likely you&#039;d want all of it to change together.  When you &quot;pull up&quot; this functionality via inheritance so it&#039;s automatic, you reduce your potential maintenance costs.  If there was a lot of variability, or strong likelihood of change in that behavior between controllers, a different approach might be better -- inheritance could end up giving you combinations of behavior that you would have to work against.</description>
		<content:encoded><![CDATA[<p>Liz &#8212; I&#8217;m glad to chime in.  I&#8217;ve been convinced that the folk wisdom archived on blogs is pretty powerful.  The more we discuss in the open, the better off we all are.</p>
<p>Something I think is lacking around all these MVC frameworks is novel strategies and patterns for structuring your app.  The samples are usually trivial and don&#8217;t get to any number of the moderately tough problems likely to be the first you hit in an app.  I think the model and controller per table approach in many examples is particularly brainwashing.</p>
<p>Anyway&#8230;  The danger is when you start changing a lot of behavior of a base component or replacing it entirely.  In this case, the change is simple, so you would probably choose the path that feels the best &#8212; it&#8217;s not going to be hard to change gears later either way.  If you do that asset setup the same on every page, you should really consider putting it in your overall base Controller, whether using MY_ or a standalone library (CI gurus, please chime in.)</p>
<p>However you structure it, you have a set of tools for avoiding code duplication.  Here, it seems like you have commonality across a large section, where it&#8217;s likely you&#8217;d want all of it to change together.  When you &#8220;pull up&#8221; this functionality via inheritance so it&#8217;s automatic, you reduce your potential maintenance costs.  If there was a lot of variability, or strong likelihood of change in that behavior between controllers, a different approach might be better &#8212; inheritance could end up giving you combinations of behavior that you would have to work against.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Liz Jamieson</title>
		<link>http://www.lizjamieson.co.uk/2008/11/25/getting-started-with-codeigniter-5/comment-page-1/#comment-974</link>
		<dc:creator>Liz Jamieson</dc:creator>
		<pubDate>Wed, 26 Nov 2008 12:17:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.lizjamieson.co.uk/?p=367#comment-974</guid>
		<description>Noah - thanks for your input. I&#039;ve tried to see why this is better, but my lack of experience with MVC is a real hindrance to this.   I like the idea of creating a new class that extends the controller class. I think I could do that?  But I don&#039;t want to mess with the core classes by using the MY_ extension because in the user guide it suggests you shouldn&#039;t unless you know what your are doing. At this stage I don&#039;t.  

Perhaps I could write a class that extends the controller class and place my common code in that.  Would that be a step in the right direction away from like you say, scope-free helper functions? Is that what you are describing in your opening sentence?

Your post is valuable as it also helps other beginners who may be able to take your ideas on board more quickly than I can! Thanks once again.</description>
		<content:encoded><![CDATA[<p>Noah &#8211; thanks for your input. I&#8217;ve tried to see why this is better, but my lack of experience with MVC is a real hindrance to this.   I like the idea of creating a new class that extends the controller class. I think I could do that?  But I don&#8217;t want to mess with the core classes by using the MY_ extension because in the user guide it suggests you shouldn&#8217;t unless you know what your are doing. At this stage I don&#8217;t.  </p>
<p>Perhaps I could write a class that extends the controller class and place my common code in that.  Would that be a step in the right direction away from like you say, scope-free helper functions? Is that what you are describing in your opening sentence?</p>
<p>Your post is valuable as it also helps other beginners who may be able to take your ideas on board more quickly than I can! Thanks once again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Noah Botimer</title>
		<link>http://www.lizjamieson.co.uk/2008/11/25/getting-started-with-codeigniter-5/comment-page-1/#comment-971</link>
		<dc:creator>Noah Botimer</dc:creator>
		<pubDate>Wed, 26 Nov 2008 02:01:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.lizjamieson.co.uk/?p=367#comment-971</guid>
		<description>Something you may consider is a base controller for all of your &quot;static&quot; pages.  You can bake in some of your own convention and leave an easy break/migration path if a page needs to get complex.

I prefer to use object-oriented models where I can.  The CI helpers coming in as unscoped methods scares me just a bit.  I&#039;d try making a new (abstract) class in a library file (maybe StaticController, ContentController, BasicController -- something...) and drop it in autoload.

If that setup is truly global, I&#039;d consider making a MY_Controller class in application/libraries that extends CI_Controller (see the user guide for extending core classes).  You&#039;d want to then change your existing controllers to extend MY_Controller, instead.  This, presumably, would be eliminating other duplications, and so, would be valuable.

In the basic/static/content controller, I&#039;d include a render() method and an index() method.  The default implementation of index() would just call $this-&gt;render().  The render() method would use get_class($this) to find the name of the controller (probably lowercased), and load a conventionally named view.

To put this directly into code...

&lt;code&gt;
//application/libraries/MY_Controller.php
class MY_Controller extends Controller {
    function __construct() {
        parent::_construct();
        $this-&gt;setup_assets();
    }

    function setup_assets() { /* ... */ }
}

//application/libraries/ContentController.php
class ContentController extends MY_Controller {
    function index() {
        $this-&gt;_render();
    }

    function _render() {
        if (get_class() !== get_class($this)) {
            $this-&gt;load-&gt;view(strtolower(get_class($this)));
        }
    }
}

//application/controllers/about.php
class About extends ContentController {
    //nothing beyond existence needed here to load the &#039;about&#039; view
}

//application/controllers/history.php
class History extends ContentController {
    function index() {
        //check for some history-specific permission and redirect on failure
        $this-&gt;_render();
    }
}
&lt;/code&gt;

This setup should give you a clean path to customize the needs lightly (at constructor time, with a new action, or just tuning index), while remaining very &quot;automatic&quot;.  This automatic behavior is entirely opt-in even if you extend ContentController.  (Spring folks may disagree with this a bit, since it&#039;s not quite open-closed...)

Another thought is that you could push this behavior up to MY_Controller as the base starting point for all of your controllers.  Unless you do something else with index(), you&#039;re going to load the view of the same name.  I might actually like that a little better...</description>
		<content:encoded><![CDATA[<p>Something you may consider is a base controller for all of your &#8220;static&#8221; pages.  You can bake in some of your own convention and leave an easy break/migration path if a page needs to get complex.</p>
<p>I prefer to use object-oriented models where I can.  The CI helpers coming in as unscoped methods scares me just a bit.  I&#8217;d try making a new (abstract) class in a library file (maybe StaticController, ContentController, BasicController &#8212; something&#8230;) and drop it in autoload.</p>
<p>If that setup is truly global, I&#8217;d consider making a MY_Controller class in application/libraries that extends CI_Controller (see the user guide for extending core classes).  You&#8217;d want to then change your existing controllers to extend MY_Controller, instead.  This, presumably, would be eliminating other duplications, and so, would be valuable.</p>
<p>In the basic/static/content controller, I&#8217;d include a render() method and an index() method.  The default implementation of index() would just call $this-&gt;render().  The render() method would use get_class($this) to find the name of the controller (probably lowercased), and load a conventionally named view.</p>
<p>To put this directly into code&#8230;</p>
<p><code><br />
//application/libraries/MY_Controller.php<br />
class MY_Controller extends Controller {<br />
    function __construct() {<br />
        parent::_construct();<br />
        $this-&gt;setup_assets();<br />
    }</p>
<p>    function setup_assets() { /* ... */ }<br />
}</p>
<p>//application/libraries/ContentController.php<br />
class ContentController extends MY_Controller {<br />
    function index() {<br />
        $this-&gt;_render();<br />
    }</p>
<p>    function _render() {<br />
        if (get_class() !== get_class($this)) {<br />
            $this-&gt;load-&gt;view(strtolower(get_class($this)));<br />
        }<br />
    }<br />
}</p>
<p>//application/controllers/about.php<br />
class About extends ContentController {<br />
    //nothing beyond existence needed here to load the 'about' view<br />
}</p>
<p>//application/controllers/history.php<br />
class History extends ContentController {<br />
    function index() {<br />
        //check for some history-specific permission and redirect on failure<br />
        $this-&gt;_render();<br />
    }<br />
}<br />
</code></p>
<p>This setup should give you a clean path to customize the needs lightly (at constructor time, with a new action, or just tuning index), while remaining very &#8220;automatic&#8221;.  This automatic behavior is entirely opt-in even if you extend ContentController.  (Spring folks may disagree with this a bit, since it&#8217;s not quite open-closed&#8230;)</p>
<p>Another thought is that you could push this behavior up to MY_Controller as the base starting point for all of your controllers.  Unless you do something else with index(), you&#8217;re going to load the view of the same name.  I might actually like that a little better&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Liz Jamieson</title>
		<link>http://www.lizjamieson.co.uk/2008/11/25/getting-started-with-codeigniter-5/comment-page-1/#comment-969</link>
		<dc:creator>Liz Jamieson</dc:creator>
		<pubDate>Tue, 25 Nov 2008 15:39:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.lizjamieson.co.uk/?p=367#comment-969</guid>
		<description>Thank you Jenny. I needed to do something. By the way - I am still laughing about your first vlogg.  I showed it to my husband and he showed it to his friends at work. They all think you are very funny. Any news from LA yet?</description>
		<content:encoded><![CDATA[<p>Thank you Jenny. I needed to do something. By the way &#8211; I am still laughing about your first vlogg.  I showed it to my husband and he showed it to his friends at work. They all think you are very funny. Any news from LA yet?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jennyonthespot</title>
		<link>http://www.lizjamieson.co.uk/2008/11/25/getting-started-with-codeigniter-5/comment-page-1/#comment-968</link>
		<dc:creator>jennyonthespot</dc:creator>
		<pubDate>Tue, 25 Nov 2008 15:11:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.lizjamieson.co.uk/?p=367#comment-968</guid>
		<description>Alright. I have no idea about this Code Igniter-thing, but I do think you have spruced your home here up a bit... yes?

Very nice!</description>
		<content:encoded><![CDATA[<p>Alright. I have no idea about this Code Igniter-thing, but I do think you have spruced your home here up a bit&#8230; yes?</p>
<p>Very nice!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
