Welcome Guest, Not a member yet? Register   Sign In
Full Codeignitor Templates
#1

[eluser]crispinatari[/eluser]
For model view and controller site pages. i'm just curious if there are any good templates or prototype templates out there in the wild blue ether?
#2

[eluser]Dam1an[/eluser]
I'm guessing you're refering to code templates, so a basic skeleton class for models and controllers?

I don't know of amny of these, and almost everyone has their own style for these, so really, there's only a few lines which are always there

What I do, i set up some templates in Eclipse, so when I type 'controller' It gives me the basic structure, same for models
#3

[eluser]crispinatari[/eluser]
See i totally get the concept that mvc provides but its just how to handle the controllers that i'm struggling with. For example in a database website i have five seperate tables = 5 pages to output table data. i'm uncertain as to whether its best practice to use one controller or 5 seperate contollers to handle each table view page, and also if i need 5 seperate models or just the one model to handle all 5 pages with functions.
#4

[eluser]jdfwarrior[/eluser]
I bet I can tell you Dam1an's response Smile

Whether to do it with 5 controllers or 1 really isn't a big deal. That all comes down to preference and how you want them accessed. Typically you share a controller for data/views that are related. When it comes to the models, my stance (and I believe it was Dam1an's as well) is to make your models based on the function they perform. For instance, I have a model that handles login related functionality, a model for user related functions, etc.
#5

[eluser]crispinatari[/eluser]
So to be honest the confusion is this: If I create 5 seperate controllers each of them contain a
function index() which calls the res(results) from the model function insertemp.

i would have thought you'd only have one index function with everything inside it for your whole website.

i'm just confused at the moment
#6

[eluser]xwero[/eluser]
you have to look at controllers and models as groups of functions that handle the same data. So 5 controllers and 5 models would be the most correct way to handle 5 tables that show 5 pages where the data is not linked.

If the five tables all have the same action to get the data, for example a select * from table sql statement you better have one model that has the method get_rows where the table is the parameter. This reduces the code.
If the five tables aren't linked but are related, for example a table with the gallery data and a table with the pictures. You can create one controller with two methods that call those separate tables.

There is no strict rule how to build models and controllers because it can vary depending on how data linking should be done in the heads of the people that use it or develop the site.
#7

[eluser]crispinatari[/eluser]
thanks xwero and you've all been a great help, i think i understand it alot more now. Smile
#8

[eluser]crispinatari[/eluser]
just one more question, if we have 5 seperate controllers then in routes it asks for one default controller, is that default controller the one that corresponds with the page you want to view as your homepage first opens? so if i wanted the school table page to open first i'd have the school controller as default?

$route['default_controller'] = "school";

or do i have to link the other 4 controllers into the school controller?
#9

[eluser]Dam1an[/eluser]
[quote author="jdfwarrior" date="1244568995"]I bet I can tell you Dam1an's response Smile

Whether to do it with 5 controllers or 1 really isn't a big deal. That all comes down to preference and how you want them accessed. Typically you share a controller for data/views that are related. When it comes to the models, my stance (and I believe it was Dam1an's as well) is to make your models based on the function they perform. For instance, I have a model that handles login related functionality, a model for user related functions, etc.[/quote]

You trying to say I'm predicatble? (Or have I just answered too many similar questions?) Tongue

You where very close, but lost it on the last sentance. At least the login model is something new to me :-S Thats a library like function Tongue

Edit: crispinatari, you where right the first time. The default controller is basically the home page, so it appears if you have no URI segemtns. That will call the index function in that controller (in your case school), so if you want some other function, redirect or call that function from within index
#10

[eluser]xwero[/eluser]
The default controller is called when the url as no segments. If the controller is found but has no method segment the router class looks for and index method. If that is not present you will get a 404 page.




Theme © iAndrew 2016 - Forum software by © MyBB