<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Two step view with CodeIgniter</title>
	<link>http://www.avnetlabs.com/php/two-step-view-with-codeigniter</link>
	<description>Accessible web development</description>
	<pubDate>Tue, 06 Jan 2009 15:20:45 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2</generator>

	<item>
		<title>By: Kyleh</title>
		<link>http://www.avnetlabs.com/php/two-step-view-with-codeigniter#comment-905</link>
		<author>Kyleh</author>
		<pubDate>Thu, 11 Dec 2008 17:12:49 +0000</pubDate>
		<guid>http://www.avnetlabs.com/php/two-step-view-with-codeigniter#comment-905</guid>
		<description>Hi Ekerete, 
This looks to be a great solution.  Thanks for putting this together.  A couple of things.  First you may be autoloading the url helper but someone new to CI may be confused when the above code throws a fatal error at the first instance of base_url() or site_url() without loading the helper.  

Also, what are you using the $param var for in MY_controller?  Passing parameters via uri segments seems to work fine as is.

Thanks again Ekerete.</description>
		<content:encoded><![CDATA[<p>Hi Ekerete,<br />
This looks to be a great solution.  Thanks for putting this together.  A couple of things.  First you may be autoloading the url helper but someone new to CI may be confused when the above code throws a fatal error at the first instance of base_url() or site_url() without loading the helper.  </p>
<p>Also, what are you using the $param var for in MY_controller?  Passing parameters via uri segments seems to work fine as is.</p>
<p>Thanks again Ekerete.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ekerete</title>
		<link>http://www.avnetlabs.com/php/two-step-view-with-codeigniter#comment-242</link>
		<author>Ekerete</author>
		<pubDate>Sat, 09 Aug 2008 08:08:01 +0000</pubDate>
		<guid>http://www.avnetlabs.com/php/two-step-view-with-codeigniter#comment-242</guid>
		<description>@Khoa,
You will need to write a custom helper to do this cleanly.
http://codeigniter.com/user_guide/general/helpers.html.

This is not strictly MVC but an implementation of the View Helper Pattern.

In your case, you would pass the array (or each item from the foreach loop - depending on your code) to the helper function and load different partial templates (or use conditionals in one partial template) depending on what category is being displayed.

Hope that helps.</description>
		<content:encoded><![CDATA[<p>@Khoa,<br />
You will need to write a custom helper to do this cleanly.<br />
<a href="http://codeigniter.com/user_guide/general/helpers.html." rel="nofollow">http://codeigniter.com/user_guide/general/helpers.html.</a></p>
<p>This is not strictly MVC but an implementation of the View Helper Pattern.</p>
<p>In your case, you would pass the array (or each item from the foreach loop - depending on your code) to the helper function and load different partial templates (or use conditionals in one partial template) depending on what category is being displayed.</p>
<p>Hope that helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Khoa</title>
		<link>http://www.avnetlabs.com/php/two-step-view-with-codeigniter#comment-241</link>
		<author>Khoa</author>
		<pubDate>Sat, 09 Aug 2008 05:07:19 +0000</pubDate>
		<guid>http://www.avnetlabs.com/php/two-step-view-with-codeigniter#comment-241</guid>
		<description>Hi Ekerete, I got this problem with CI framework about where some logical checking should be performed, which also results from the limitation of CI template system. Please let me explain (a bit long, sorry):

I retrieve a list of items from database, each item has a category. I want to display all of them on the list (mix them all, sorted by create date). However, each of category has its own layout, for example, category A has image on the left, category B has image on the right, category C has an additional field to be shown, and so on.

So, where should the checking "if (category == 'A')...else if (category == 'B')...else..." be included taking best MVC practice, easy maintenance and logic/presentation separation factor into account?

1. Inside the model immidiately after retrieving data and before passing it to the controller?

2. Inside the controller just before sending the list to view (which means I have to render all the category-tempalte at this point and pass all of them as variables)?

3. Or inside the view? This means "raw" data will be sent to the view and the conditional statement will be written here. But this seems to "violate" the MVC model, and especially the CI template system does not allow us to use if statements inside views.

Your article seems to address just this problem, however sorry for my php knowledge, I still cant get how to do this using your 2 step view process. Do you mind to explain a bit more about this? And if you can do this in my context, it will be very appreciated.

Many thanks Ekerete.

Khoa</description>
		<content:encoded><![CDATA[<p>Hi Ekerete, I got this problem with CI framework about where some logical checking should be performed, which also results from the limitation of CI template system. Please let me explain (a bit long, sorry):</p>
<p>I retrieve a list of items from database, each item has a category. I want to display all of them on the list (mix them all, sorted by create date). However, each of category has its own layout, for example, category A has image on the left, category B has image on the right, category C has an additional field to be shown, and so on.</p>
<p>So, where should the checking &#8220;if (category == &#8216;A&#8217;)&#8230;else if (category == &#8216;B&#8217;)&#8230;else&#8230;&#8221; be included taking best MVC practice, easy maintenance and logic/presentation separation factor into account?</p>
<p>1. Inside the model immidiately after retrieving data and before passing it to the controller?</p>
<p>2. Inside the controller just before sending the list to view (which means I have to render all the category-tempalte at this point and pass all of them as variables)?</p>
<p>3. Or inside the view? This means &#8220;raw&#8221; data will be sent to the view and the conditional statement will be written here. But this seems to &#8220;violate&#8221; the MVC model, and especially the CI template system does not allow us to use if statements inside views.</p>
<p>Your article seems to address just this problem, however sorry for my php knowledge, I still cant get how to do this using your 2 step view process. Do you mind to explain a bit more about this? And if you can do this in my context, it will be very appreciated.</p>
<p>Many thanks Ekerete.</p>
<p>Khoa</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.139 seconds -->
