doufan3958 2012-01-26 03:57
浏览 32
已采纳

CakePHP和MVC [关闭]

So I just installed CakePHP and I'm VERY excited to work with it.

However, the MVC model is BLOWING MY MIND. I looked at the docs and am very impressed, but completely baffled at what to do.

The tutorials and docs show creation of applications that reflect database interaction and etc, but all I want to do right now is create a simple index page. I've already coded it (html, some style sheets, and basic javascript), but I would like to convert it to fit with the CakePHP model.

Does anyone know of good tutorials to begin the process of translating pages to fit the CakePHP model? Also, I would like to start translating my mindset into the MVC model.

  • 写回答

4条回答 默认 最新

  • dty97501 2012-01-26 04:45
    关注

    Sure. Here's how to roll your simple index page live without messing around with models, tables, etc:

    1. Create a view -> /app/views/pages/index.ctp and plop in your markup, etc.
    2. Place your stylesheet in app/webroot/css/whateveryouwanttocallit.css.
    3. Pull up app/views/layouts/default.ctp and look for a line in the head that starts with Html->css(...); ?> - change it to echo $this->Html >css(array('whateveryouwanttocallit')); - note, no filetype .css on that, just the name. (Also, you can keep the default stylesheet if you want, just add stylesheets to the array to load them in the layout.)
    4. Browse to localhost/index and you should see your static page.

    Cake rolls with a single default controller already in place - the PagesController. It does not use a model (the $uses = false; property.) You can use to that property to disable models if you just want a controller, no database / model functionality. The pages controller and the Cake router are set up to route any request to cake's webroot/:action through the Pages controller without needing to specify /pages/:action. Meaning, localhost/index will route sneakily through pages. (So will localhost/pages/index, but I digress.)

    That should get you pointed in the right direction. HTH :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助