Welcome Guest, Not a member yet? Register   Sign In
Views - Best Practices
#1

[eluser]elambert[/eluser]
I am new to CI and had a question about Views. Should I create them using HTML and just embed the CI calls as needed or should they be created completely with CI/PHP calls?

For example, it is better to create a view like this:

echo "<html><head><title>Newsletter Signup</title></head><body class='" . $bodyclass . "'>";
echo form_open('do/send',array("id" => "newsletter_signup_form"));
echo "<div class='form_data'>";
echo form_label("Email:", "email");
echo form_input(array("name" => "Email"));
echo "</div>";
echo form_submit("submit", "Signup");
echo form_close();
echo "&lt;/body&gt;&lt;/html>";

OR like this:

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Newsletter Signup&lt;/title&gt;
&lt;/head&gt;
&lt;body class="&lt;?= $bodyclass ?&gt;"&gt;
&lt;form action="newsletter/signup" id="newsletter_signup_form"&gt;
<div class="form_data">
<label for="email">Email:</label>
&lt;input type="text" name="email"&gt;
</div>
&lt;input type="submit" value="Signup"&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

What are the pros and cons of each method? Is there a performance hit with the second method? How about error handling? Any feedback would be appreciated.

Thanks
#2

[eluser]John_Betong[/eluser]
The second script is easier to read.

Nicked from
http://derekallard.com
&nbsp;
&nbsp;

http://ellislab.com/expressionengine/use...neral.html
&nbsp;
&nbsp;
&nbsp;
#3

[eluser]Roy MJ[/eluser]
The second one will work fine as thats the method used by all i guess..
#4

[eluser]elambert[/eluser]
Nick / Roy, Thank you both for your feedback and for the development guidlines link.




Theme © iAndrew 2016 - Forum software by © MyBB