Welcome Guest, Not a member yet? Register   Sign In
newbie need help!
#1

[eluser]Alaa Selim[/eluser]
hello

First I like to say how I'm very happy with CI and how it's easy to learn, i have learned how CI works, how the controllers,models and views works and how to use helpers ..etc

i have only few questions

1- in normal php project i build php file for each page do i have to build controller for each page?

2- i have noticed in some tutorials that they use models to set variables like site title , css file ..etc but i thought models used only for database issues?

Thank you for your time!
#2

[eluser]n0xie[/eluser]
[quote author="Alaa Selim" date="1253194342"]hello

First I like to say how I'm very happy with CI and how it's easy to learn, i have learned how CI works, how the controllers,models and views works and how to use helpers ..etc

i have only few questions

1- in normal php project i build php file for each page do i have to build controller for each page?

2- i have noticed in some tutorials that they use models to set variables like site title , css file ..etc but i thought models used only for database issues?

Thank you for your time![/quote]
You don't have to do anything. You're free to structure your project however you want. Keep in mind a framework is just there to make things easier so your development time goes down (or you do more in the same amount of time, depends on how you look at it).

Now the convention is that a controller groups several pages together which have a common subject. So if you want to group related pages together, it's easier just to put them all in the same controller.

As for your second question, in my opinion a model should only abstract your datalayer away, and not have anything to do with how you represent that data, but there is nothing stopping you from mixing your CSS or setting variables in your model. It might not be 'best' practice or might be less maintainable in the future, but in the end whatever works for you, is usually the best solution.

To give an example: in University you are taught that software should be first designed like an architect designs an house: everything should be designed up front and then it's just basically a matter of building it. This is all fine and dandy in theory but the high level of software development failures seem to contradict this.

The reality of it is, that the latest trend is Agile, which basically preaches the opposite: build exactly the parts you need and fix it later (or as they call it YAGNI and Iterations). So instead of thinking about 'best' practices, design principles and abstraction layers for reusibility, the general consensus nowadays seem to be 'just make it work'. This doesn't mean you should throw all up-front architecture decision making out of the window, it just means that 'whatever makes it work NOW' is usually the best way to go: you can always fix it later.
#3

[eluser]ELRafael[/eluser]
[quote author="Alaa Selim" date="1253194342"]hello

First I like to say how I'm very happy with CI and how it's easy to learn, i have learned how CI works, how the controllers,models and views works and how to use helpers ..etc

i have only few questions

1- in normal php project i build php file for each page do i have to build controller for each page?

2- i have noticed in some tutorials that they use models to set variables like site title , css file ..etc but i thought models used only for database issues?

Thank you for your time![/quote]

1 - Yes and no.
Example:
You can have a controller called Users. Inside it, you can create methods for register, login, profile, etc..
So now you have 3 pages (without the ect...) inside one controller.
You can have another controller called Products, the same logic. Capisce?

2 - Some tutorials do that, others don't. I don't. I use Models only to deal with database/xml/other sources.




Theme © iAndrew 2016 - Forum software by © MyBB