New to code igniter and the view(s) are killing me

#1
[eluser]Unknown[/eluser]
I checked out ruby on rails but decided to go for CI since I already php. I rebuilt an application I had originally created with smarty in CI and everything was good until I got to a complicated view that required me to write <?php echo ?> a million times, as well as a good amount of loops and operators. I realize there is a template parser but the documentation says that it will slow apps down and it seems as if the creators aren't really in favor of us using it. Is there something I am missing here. Should I rely on some community template solutions to reduce the amount of code I'm writing? If so, which is best? I realize that most people here prefer no template system as it's just one more thing to learn but sometimes I feel like it would be worth the effort.

#2
[eluser]Bas Vermeulen[/eluser]
Hi, check: http://ellislab.com/codeigniter/user-gui...e_php.html

I used to use Smarty, my vars looked like <!--{$var}-->, with the alternative PHP syntax this would be <?=$var?>, which is even shorter Smile If you used {$var} (the Smarty default) your syntax will be a little bit longer, but I think it's worth it. I liked my Smarty templates but now I really prefer my CI plain PHP views!

#3
[eluser]sprise[/eluser]
Currently building my first CI app and I too use <?= whenever possible. I also have my common elements (e.g., header and footer) separated out, leaving the page's unique content in its own view.

#4
[eluser]WanWizard[/eluser]
Dwoo is a good and fast alternative to Smarty. Phil Sturgeon has done all the footwork...

#5
[eluser]stuckinphp[/eluser]
[quote author="kenyabob" date="1283813538"]it seems as if the creators aren't really in favor of us using it. Is there something I am missing here.[/quote]

Yes you are missing the fact that CI creators love to impose all kinds of crazy on unsuspecting developers.

If you don't like it and can't get used to it, start looking for a new framework because this kind crap is freaking everywhere in CI. Everywhere.

Edit:

Wanted to add something to the discussion, the mere thought that templating engines are slow and produce too much overhead is absurd and or incredibly outdated (especially for a framework that completely throws out the POST/COOKIE/GET arrays and re-implements them every page load). Smarty is insanely quick and its caching features speed things up a lot more.

It is much more likely CI simply couldn't build a fast templating engine themselves and to save face started spreading FUD into the community about how crappy templating was.

#6
[eluser]John_Betong[/eluser]
I use this debugging technique in my form that gives an easy option do either show or hide partial content:

to show change the 0 (ZERO) to any numeric value:
Code:
<?php if(0) { include '_partial_footer.php'; } ?>

// OR even better so that the page validates and does not show empty divs:

<?php if (0) { ?>
<div id='my_footer'>
   &lt;?php include '_partial_footer.php'; ?&gt;
</div>
&lt;?php } ?&gt;
&nbsp;
&nbsp;
&nbsp;


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.