Code Igniter noob :) |
[eluser]srpurdy[/eluser]
[quote author="Mr. Gibon" date="1272466728"]can i get answer ?[/quote] It doesn't make much difference in terms of how things function, but I would say it depends mostly on the size of your end project. If you plan on the web-site being quite large, it would be better to have things in different files so you can find what you need a lot easier. This below is a simple function I wrote for templating my system based on controller and database. This allows me to have a completely unique looking website on any page on my site via a database. So it looks in a specific folder for the required files. Code: <?php class MY_Controller extends Controller I took out lot of extra stuff I had for other reasons to keep it simple, but it's not hard to pass a database value to MY_Controller using a model. Main Web Model Code: function get_template() Leagues Model Code: function get_league_temp() At which point you can use a controller file to get that information like below. Code: $league_temp = $this->leagues_model->get_league_temp(); Depending on your folder structure you can do this however you like, but that would give you complete control over the page design. Inside that actual folder you have a file called container.php with Code: <?php As many files as you want to use for your layout. I know it's got some limitations, it does what I need for the project I used it for, but maybe someone can find some of it useful. I know your new and this might be confusing right now, but thought I'd share it anyway. Shawn
[eluser]Bart v B[/eluser]
[quote author="Mr. Gibon" date="1272331287"]Thanks for reply, i will probably use this Parser. Still no answer for this: Is is a good way of building website based on code igniter, all in one controler like this Code: class Welcome extends Controller { You don't want to do it this way Because, when youre webapplication gets lager, then it's to difficult to maintain this. Then it's much easyer to make some sepperate controllers. for example: Main controller-> where you show the main content. offer controller -> where for example there is a webshop. Contact controller -> where you make options to get in contact.
[eluser]Mr. Gibon[/eluser]
Thanks! My problem is i cant find way to build website in CI, i konto it is great framework, and how to build some formas, and single page,but not website, all tutorials are about some other things but not this one
[eluser]Tominator[/eluser]
Hello Mr. Gibon, CI is great because it gives a freedom of choice. It's up to you, if you make 10 controlers or 1 controller with 10 methods. So I think, you can make your website using CI, but you are looking for best way, how to do it, but it is hard to say best way, because everybody of us has another coding style. After all I have one advice to you: If you are making small site, choose 1 controller. If you are making big site, choose more controllers. @srpurdy: you are making it too hard ... Tom.
[eluser]Bart v B[/eluser]
@Tominator, (hehe nice nickname ) and Mr. Gibson I not agree with you sorry. What give you the freedom to just one single controller? For the record i did not reat the whole topic, so maybe i misunderstoot the real problem. If it is a small website you don't want to do everything in one controller. It does not make any sence. For example: If you have one controller and the website has for example some main content, contactpage, and guestbook. how in the world you can understand youre own controller. A contactpage can send some information, but an guestbook also. So a better method would be that there is a understanding how the framework works. The first segment is the controller when it's called. something like this: http://domain.tld/contact/ that should be not to complicated, because youre controller is contact. With some code: Code: <?php some code Code: <?php Hope that helps you
[eluser]Tominator[/eluser]
Yes you are true, but: 1. You can use models 2. You can use routers 3. You can use POST to current page So you can make webpage by one controller or many controllers. Of course, it's up to you ... (I prefer many controllers, but it's just my opinion). Tom. |
Welcome Guest, Not a member yet? Register Sign In |