官术网_书友最值得收藏!

Summary

The MVC pattern is a widely used and is a very effective way of organizing a complex website. CI uses it to help you sort your own code, but it is also fairly flexible about how it does so.

The crucial thing is to understand what the different type of files are, and how they relate to each other. Then, you can decide whether to write your code in library or model files, or as helpers or plugins.

We've looked at the CI file structure, and seen how you can, if you want, inspect all the CI code, but (thankfully!) you don't have to. We did tinker with one of the original files—the config file, which holds critical site information in one place to make it easy for us to upgrade or change later.

We've seen the basic object structure of a controller, and used a simple constructor to get some data from our config file and put it into a class property. We've dynamically passed information from a new controller we wrote, to a new view. So far, the main thing CI has done for us is to encourage us to use a basic structure as we start to define our site. As we go on, it will become clear just how important that structure is.

Also, we looked at the way in which CI's components pass data and control between themselves. It's useful to understand this when you start to write your code.

Lastly, we looked at CI's own URL helper as a good example of a chunk of code, and we wrote our own rudimentary menu library class. Now continue to Chapter 4, where we will see how CodeIgniter will help us improve the way we work with databases, don't wait!

主站蜘蛛池模板: 西充县| 嵊州市| 额敏县| 靖江市| 高要市| 金阳县| 渭源县| 万源市| 额济纳旗| 婺源县| 和林格尔县| 宁蒗| 桐梓县| 广宁县| 门头沟区| 扬中市| 杂多县| 商城县| 罗城| 宜阳县| 汾西县| 沐川县| 澄城县| 五寨县| 荥阳市| 兴义市| 双辽市| 广德县| 香格里拉县| 颍上县| 库车县| 辽宁省| 莲花县| 阜南县| 农安县| 兰溪市| 临西县| 沽源县| 玉田县| 介休市| 东乌珠穆沁旗|