Welcome Guest, Not a member yet? Register   Sign In
Multiple controllers or multiple functions wtihin each controller? So confused!
#1

[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
#2

[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.
#3

[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.
#4

[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.
#5

[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?
#6

[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
#7

[eluser]ChrisF79[/eluser]
Thanks so much to the both of you. I feel like I'm on track now.




Theme © iAndrew 2016 - Forum software by © MyBB