Welcome Guest, Not a member yet? Register   Sign In
Need some advice to start building a new project
#1

[eluser]iive[/eluser]
Hi, I am new to CI and MVC concept. Previously, I was building my own PHP classes to handle all the coding in PHP. And currently I am going to port my previous application into CI.

But I have some queries in my mind currently, and I hope to get some advice from all of you here. I have read through the user manual and get the basic understanding on MVC.

My application is a Flash gaming portal and the homepage will have some general information and a panel that show up all the current games available.

I wonder how would my pages structure are in this homepage?

Obviously I need a HomeController, and I need to call a GameController somewhere in the function of my HomeController to pull out all the games and display them in a seperate view?

I hope I am on the right track...
#2

[eluser]Unknown[/eluser]
I would make a GameController with 'list' method, a Games model with 'GetGames($number?)' method that pulls game information from database and a GameList view to show it. index.php/game/list (list method of GameController) would call GetGames (from Games model) and load view GameList to display it. Thats how I code, but maybe someone uses better way.
#3

[eluser]iive[/eluser]
Thanks for your reply. Yes.. I will do the same as yours.

that is when I access from index.php/game/list

my problem is when I want to access from the homepage of my site(index.php/home/) where the game listing will just apprear inside 1 part of the page....

I have a HomeController with method index().. is it possible I can call GameController to help me to pull the data from db inside my HomeController::index() function?
#4

[eluser]binlid[/eluser]
You can set up a default route to the controller + method you want on your home page
#5

[eluser]ballen[/eluser]
[quote author="binlid" date="1193321911"]You can set up a default route to the controller + method you want on your home page[/quote]

He just wants the data from it on the homepage, not the game list to be the homepage.

I would put all the database stuff in the model, then load the Game model into the homepage, and access it that way.

Hope that helps.
#6

[eluser]iive[/eluser]
thanks for all the helps..

Ballen, I am doing exactly what you said, I have a GameModel and loaded by my HomeController. But is it a good practise? I was thinking to have GameController to load GameModel and finally I load GameController within my HomeController... Can load another Controller inside a controller in CI ?




Theme © iAndrew 2016 - Forum software by © MyBB