<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:content="http://purl.org/rss/1.0/modules/content/">

    <channel>
    
    <title>MtheoryX</title>
    <link>http://www.mtheoryx.com/</link>
    <description>Tutorials by Geeks, for Geeks</description>
    <dc:language>en</dc:language>
    <dc:creator>drpoindexter@gmail.com</dc:creator>
    <dc:rights>Copyright 2007</dc:rights>
    <dc:date>2007-11-25T03:41:00-05:00</dc:date>
    <admin:generatorAgent rdf:resource="http://expressionengine.com/" />
    

    <item>
      <title>Multiple views and templating with CodeIgniter: Method 2</title>
      <link>http://www.mtheoryx.com/index.php/site/multiple_views_and_templating_with_codeigniter_method_2/</link>
      <guid>http://www.mtheoryx.com/index.php/site/multiple_views_and_templating_with_codeigniter_method_2/#When:03:41:00Z</guid>
      <description>When we last left off...
In the previous episode, we left off with the basic instructions for setting up a templating system in your CodeIgniter application. The benefits are two&#45;fold:

  It saves you lines of code when using many views

  It helps with future maintenance by abstracting away a great deal of your code

So, onto the new stuff...With that said, lets move onto an interesting situation. Let&apos;s suppose you&apos;ve set up a view which has a header, navigation, content, sidebar, ad unit, and a footer.
So, your view, with all the includes, would look something like this:

  &amp;lt;$this&#45;&amp;gt;load&#45;&amp;gt;view(&apos;partials/header&apos;);&amp;gt;
  &amp;lt;$this&#45;&amp;gt;load&#45;&amp;gt;view(&apos;partials/nav&apos;);&amp;gt;
&amp;lt;div id=&quot;content&quot;&amp;gt;
&amp;lt;h2&amp;gt;Some content here.&amp;lt;/h2&amp;gt;
&amp;lt;p&amp;gt;Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam hendrerit orci commodo tortor. Nam eu lacus in turpis placerat pulvinar. Mauris vehicula nisi posuere magna. Aliquam a purus quis pede volutpat commodo. Fusce rutrum tortor non massa. Quisque non tortor. Duis adipiscing pretium velit. Maecenas a ante. Vivamus id urna. Nulla facilisi.&amp;lt;/p&amp;gt;
&amp;lt;/div&amp;gt;

  &amp;lt;$this&#45;&amp;gt;load&#45;&amp;gt;view(&apos;partials/sidebar&apos;);&amp;gt;
  &amp;lt;$this&#45;&amp;gt;load&#45;&amp;gt;view(&apos;partials/ad&apos;);&amp;gt;
  &amp;lt;$this&#45;&amp;gt;load&#45;&amp;gt;view(&apos;partials/footer&apos;);&amp;gt;

And the controller index function would simply be this:

  function index ()
  {
  &amp;lt;$this&#45;&amp;gt;load&#45;&amp;gt;view(&apos;home&apos;);&amp;gt;
  }

Notice that I obviously am keeping all the sub&#45;views, or partials, in a folder together. This is just for organizational purposes, and you don&apos;t really have to do it...but you should 
Disclaimer!! Important!!
Now, before all you MVC crazies out there start hammering me with complaints like &quot;You shouldn&apos;t have logic in the view&quot; and &quot;You&apos;re breaking MVC and promoting bad programming&quot; let me set one thing straight. The logic that will be in the view is display logic. The &quot;V&quot; in MVC is for the view, or presentation of data. We will be actually making the decision in the controller. So the actually programmatic logic is, in fact, in the controller. However, the result of said logic happens in the view, as it should. So, disclaimer over, lets move on, shall we?
Moving on...
Okay, adding a little logic to our view; here&apos;s the situation: You have this sidebar view and this ad view. We&apos;re going to set up a little logic to let the view decide when the ad gets loaded into the view. The reason could be that you have a public site that serves an ad, but logged&#45;in, registered users get an ad&#45;free experience. Regardless, the point is, you can see how this works with this example.
You can easily extend the logic to say that non&#45;logged in users get an ad and a sidebar, but logged in users get a control panel and a sidebar. Of course, you&apos;d want to make sure for your layout, spacing, and all that you use classes. That way, when you replace something in the sidebar, its fluid and consistent. See how useful this can be?
Something very basic...
Okay, for now, lets start with something basic. We&apos;re going to set up an array called data, and we will assign an item in that array. The key will be &quot;loggedIn&quot; and we will manually set the value to &quot;true.&quot;
In the controller, you&apos;ll have this:

  function index ()
  {
  $data[&apos;loggedIn&apos;] = &apos;true&apos;;
  $this&#45;&amp;gt;load&#45;&amp;gt;view(&apos;home&apos;, $data);
  }

And in the view, you&apos;ll put this around your call for the ad:

  &amp;lt;?if ($loggedIn != &quot;true&quot;) { ?&amp;gt;
  &amp;lt;?=$this&#45;&amp;gt;load&#45;&amp;gt;view(&apos;partials/ad&apos;)?&amp;gt;
  &amp;lt;? }?&amp;gt;

Now, what you&apos;ll notice is since we set the value to &quot;true,&quot; the ad does not load! However, go back in the controller and change the value to &quot;false&quot; or, better yet, leave it empty. Now you will see the ad presented.
Okay, where&apos;s this &quot;extensible&quot; bit? Right here...
Remember I told you we could extend this? Okay, let me show you how to do that.
First, lets add another view file called &quot;admin.php,&quot; and add a call for it in the view:

  &amp;lt;?=$this&#45;&amp;gt;load&#45;&amp;gt;view(&apos;admin&apos;)?&amp;gt;

Now, we&apos;re going to expand on the logic that we put in the view. What we want is instead of a non&#45;logged in user seeing an ad, we want the logged&#45;in users to see their little control panel. It should look like this:

  &amp;lt;?if ($loggedIn != &quot;true&quot;) {?&amp;gt;
  &amp;lt;?=$this&#45;&amp;gt;load&#45;&amp;gt;view(&apos;partials/ad&apos;)?&amp;gt;
  &amp;lt;?} else {?&amp;gt;
  &amp;lt;?=$this&#45;&amp;gt;load&#45;&amp;gt;view(&apos;partials/admin&apos;)?&amp;gt;
  &amp;lt;?}?&amp;gt;

Now, if you have the value set to &quot;true&quot; you will see the sidebar and your admin panel. And if you are not logged in, you will see the sidebar and an ad.
In closing...
So, this concludes our discussion on view logic. As you can see, this method is very flexible. If you use your imagination, I&apos;m confident you can extend this technique much, much further.
In the next article in the series, I&apos;ll describe another method that allows for controlling all this decision logic inside the controller.</description>
      <dc:subject>Instructions</dc:subject>
      <dc:date>2007-11-25T03:41:00-05:00</dc:date>
    </item>

    <item>
      <title>ExpressionEngine Users: RSS Patch required</title>
      <link>http://www.mtheoryx.com/index.php/site/expressionengine_users_rss_patch_required/</link>
      <guid>http://www.mtheoryx.com/index.php/site/expressionengine_users_rss_patch_required/#When:21:06:00Z</guid>
      <description>Special Announcement:
So, as I was trying to set up FeedBurner for this site, I discovered there was an error with the RSS feed. Ugh. I&apos;m using the most recent version of EE, so, I thought maybe I made an error in a template file. No, no. It wasn&apos;t me! If you are using EE 1.6.1 downloaded the EE 1.6.1 version right away (sometime before November 14th, 2007), you need do re&#45;download the package from the site. Replace the following file in your install with the one from this new download:

  system &amp;gt; core &amp;gt; core.output.php file


So, after replacing that file, the feed is valid....except for one thing...
You&apos;ll still get this error:


  line 33, column 4: Missing atom:link with rel=&quot;self&quot;


Just ignore this. Your feed is valid...this is not an error, it&apos;s a recommendation by the authors of the validator. Apparently they are wanting you to use the Atom namespace to get at some features that you can&apos;t get with RSS 2.0. Politics.
Further explanation of this, and discussion can be found in this forum thread on the EE boards.</description>
      <dc:subject>News</dc:subject>
      <dc:date>2007-11-23T21:06:00-05:00</dc:date>
    </item>

    <item>
      <title>Multiple views and templates with Code Igniter: Method 1</title>
      <link>http://www.mtheoryx.com/index.php/site/multiple_views_and_templating_with_code_igniter_method_1/</link>
      <guid>http://www.mtheoryx.com/index.php/site/multiple_views_and_templating_with_code_igniter_method_1/#When:16:48:00Z</guid>
      <description>Why am I writing this?
Over the past couple weeks, I&apos;ve been asked several times what I feel the best method is for managing a template&#45;like system in CodeIgniter. Instead of continually explaining the various different methods each and every time, I eventually started using a copy of a long IRC discussion on the subject to introduce users to the concept.
Well, I still don&apos;t think it gets the point across, so we&apos;ll dive into it with this multi&#45;part series.
The basics:
First, let&apos;s explain some basics: CodeIgniter (CI) is an MVC PHP framework. It is derived from ExpressionEngine and is quite flexible. Not as strict an implementation of MVC as something like CakePHP would be, CI still follows a set of defaults, and understanding the concepts behind these defaults is key.
Let&apos;s take a peek at the CI User Guide for a moment. When you render a view from your controller, what you are doing, essentially, is passing program control from the controller to the view. In the MVC model, this means moving into the presentation and interaction part of the model.
So, in your controller, you would have:


  $this&#45;&amp;gt;load&#45;&amp;gt;view(&apos;yourView&apos;);


And you will have a view named &quot;yourView.php&quot;
Now, how about those time&#45;saving templates?
This is the method to call the view. Now, lets say that you want all your views to have some shared elements. For example, on this site, the header, sidebar, and footer are the same on ever page. It would be silly to actually put that code in every view.
What if you got the site all done, and had 20 different view files. And suppose you realized that one of the links you added to your sidebar was wrong. Yeah, now you see the point of separating your shared code.
So, in your view, instead of all that header stuff, create a file called &quot;header.php&quot; and place all of your header code in there.
After calling the &quot;yourView.php&quot; file, instead of all that header code, you would place this at the top of the view:


  $this&#45;&amp;gt;load&#45;&amp;gt;view(&apos;header&apos;);


This essentially performs an include, but does not pass program control to that view.
In the view you would essentially have this for a pretty standard site:


  $this&#45;&amp;gt;load&#45;&amp;gt;view(&apos;header&apos;);
  $this&#45;&amp;gt;load&#45;&amp;gt;view(&apos;navigation&apos;);
  ...put the content unique to this view here...
  $this&#45;&amp;gt;load&#45;&amp;gt;view(&apos;sidebar&apos;);
  $this&#45;&amp;gt;load&#45;&amp;gt;view(&apos;footer&apos;);


So, this is the basic way to manage a pseudo&#45;templating system with CI. In the next example in the series, I&apos;ll show you how to start adding some decision making for the occasion that you may have views that wont have a sidebar or a footer.</description>
      <dc:subject>Instructions</dc:subject>
      <dc:date>2007-11-23T16:48:00-05:00</dc:date>
    </item>

    
    </channel>
</rss>