Code Separation |
[eluser]phybertek[/eluser]
Hello, I've used scaffolding to design an application for my site. It is great for adding testing data, but now I am moving to the user and administration phase. I'm looking into building form inputs. I have one question about this process. How are people seperating code and html with in their projects for forms. I understand the process of controllers and views, but how are people in the CI world keeping their views clean for html designers and their Controllers doing all of the logic? Can someone share an example of one of their controllers or models with form building kept seperated? Or, where can I get this information from. I was looking into pagination, but I can not figure out how to keep all of that out of my view. Phybertek
[eluser]adwin[/eluser]
I use smarty extension. It keep your code clean .... please look at the wiki to know more about how to implement smarty with ci about pagination ... you might use flexigrid (it has ci component as well), you can search about flexigrid in this form or go to this page http://webplicity.net/flexigrid/ ps: I use smarty, freakauth, and flexigrid component for my development. because I dont want to mess up my designer html
[eluser]phybertek[/eluser]
Adwin, I'll check these out. Thank you for the direction. Regards, -Phybertek
[eluser]phybertek[/eluser]
So, basically, there is not way in native CI to separate code logic from the presentation layer? What is the view for really? Pt
[eluser]Majd Taby[/eluser]
take a look at CodeExtinguisher (links in my signature)
[eluser]Lone[/eluser]
phybertek: CI does keep the code logic seperate from the view as long as you program it that way. What you do from your controller is send a set of variables to the view from which the designer can use from there on. IMO using smarty templates is just another layer that isn't needed - it is well worth a designer knowing some very simple PHP eg. a foreach loop and variable output. Below is quick sample: CONTROLLER Code: function view_product() { VIEW Code: <? $this->load->view('header'); ?>
[eluser]xwero[/eluser]
To add to Lone's response you could use php's alternative syntax then you can write the foreach as Code: <? foreach ($images as $image): ?>
[eluser]Michael Wales[/eluser]
Quote:So, basically, there is not way in native CI to separate code logic from the presentation layer? What is the view for really? There is not a native way to pull CI's scaffolding out - no. You would develop your own administrative logic and views.
[eluser]adwin[/eluser]
I prefer to add additional layer because smarty is very usable for me. I don't like to mix my php code with html ... so messy
[eluser]phybertek[/eluser]
Adwin, I'm with you on that. Php programming and HTML works from opposite sides of the brain. If you happen to find an HTML designer that knows PHP, the cost goes up. I like to keep them always separate to keep cost down. Phybertek |
Welcome Guest, Not a member yet? Register Sign In |