Multiple controllers or multiple functions wtihin each controller? So confused! |
[eluser]ChrisF79[/eluser]
New to codeigniter and I want to make my real estate site using the framework to learn. I have mysite.com and I'll show some properties, a search form, etc. Very standard real estate stuff... but, I want mysite.com/property/123-main-street/ as an example. So, should I make a new function in the same controller that I use for my root URL? Or, do I create a new class within the same controller file? Or, third, do I create a new controller all together? I know this sounds like a very remedial question (and it is) but I want to know the correct way of doing this before I do it the incorrect way (my way). Thanks
[eluser]InsiteFX[/eluser]
If it is related to that controller then create a new function to handle it. So if I had a Property Controller then I would create all my property methods in that Controller. Do not forget that you can also create a library for other property methods.
[eluser]ChrisF79[/eluser]
Thanks for the reply. Stupid question here but when you say to create a new method in that controller, are we talking about another class or function? I guess I don't understand the difference.
[eluser]Samus[/eluser]
[quote author="ChrisF79" date="1338294240"]Thanks for the reply. Stupid question here but when you say to create a new method in that controller, are we talking about another class or function? I guess I don't understand the difference.[/quote] In OOP we refer to a 'function' as a 'method'. They're exactly the same thing.
[eluser]ChrisF79[/eluser]
Perfect, thank you. So in my example, to bring this full circle, I'd have my controller (called Site) and I'd have an index function and a property function. The property function would be at http://mysite.com/site/property/ but I could make it just /property by using a route. Is that correct?
[eluser]Samus[/eluser]
[quote author="ChrisF79" date="1338303310"]Perfect, thank you. So in my example, to bring this full circle, I'd have my controller (called Site) and I'd have an index function and a property function. The property function would be at http://mysite.com/site/property/ but I could make it just /property by using a route. Is that correct?[/quote] Very correct
[eluser]ChrisF79[/eluser]
Thanks so much to the both of you. I feel like I'm on track now. |
Welcome Guest, Not a member yet? Register Sign In |