Welcome Guest, Not a member yet? Register   Sign In
Doubt about the basics [maybe?]
#1

[eluser]FrancoNoronha[/eluser]
Sorry if it sounds stupid but I just got to know the framework, I've been researching a lot and some scripts that made me confuse... anyway... I'm building a website and I'm using a template system... the basic structure of this site is located all on the same controller class. Example: controller = Pages, Methods = home, contact, about me, news, etc... Is this the right way to do?? Or should I use 1 controller per page? Thanks!
#2

[eluser]Buso[/eluser]
When I build a small site I do the same, I write a simple controller named Pages

If the site grows, or if you know each page will have many subpages, you can have one controller for each.
#3

[eluser]pickupman[/eluser]
If you are working with a DB, it's not that much more effort to create a pages controller with one method index. Pass a page id or slug (page title), lookup in DB, and send it to the browser. This way you can easily add as many pages you need to as the site grows.

By the way, this type of feature would look better using routes.php
Code:
$route['pages/(:any)'] = 'pages/index/$1';

This will pass www.site.com/pages/home to www.site.com/pages/index/home. Then you look up "home" in the DB, and load content into view and display page. If a page is not found than you can have a 404 page not found view, and suggest something else. Then users won't see the generic 404 page.
#4

[eluser]FrancoNoronha[/eluser]
THANK U VERY MUCH GUYS!!! The site is working fine but I thought I could have done everything wrong...
Thanks for answering my question! regards!




Theme © iAndrew 2016 - Forum software by © MyBB