Views - Best Practices |
[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 "</body></html>"; OR like this: <html> <head> <title>Newsletter Signup</title> </head> <body class="<?= $bodyclass ?>"> <form action="newsletter/signup" id="newsletter_signup_form"> <div class="form_data"> <label for="email">Email:</label> <input type="text" name="email"> </div> <input type="submit" value="Signup"> </form> </body> </html> 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
[eluser]John_Betong[/eluser]
The second script is easier to read. Nicked from http://derekallard.com http://ellislab.com/expressionengine/use...neral.html
[eluser]Roy MJ[/eluser]
The second one will work fine as thats the method used by all i guess..
[eluser]elambert[/eluser]
Nick / Roy, Thank you both for your feedback and for the development guidlines link. |
Welcome Guest, Not a member yet? Register Sign In |