2011-11-29 07:59



I am new to PHP and today I was able to display my first list of items using CakePHP yay! but, whatever I display always shows with the default format. How can I override my view to show the page how I had it in html? Where do I put the css, javascript and images? Before this my HTML had this in the header

<link rel="stylesheet" href="css/stylestopmenu.css" type="text/css" />
<link rel="stylesheet" href="css/stylessidemenu.css" type="text/css" />
<link rel="stylesheet" href="css/jquery.rating.css" type="text/css" />
<link rel="stylesheet" href="css/specialtablemenu.css" type="text/css" />
<link rel="stylesheet" href="css/admintable.css" type="text/css" />
<script type="text/javascript" src="javascript/jquery.min.js"></script>

I have no idea how to style it so that it displays as before. Right now it shows like this

enter image description here

I wouldn't like to totally get rid of this as it tells me errors but, how can i do it so that I can style the page, maybe somewhere else?, please forgive me, I am new to PHP and its been hard for me to understand the tutorials. I would appreciate any help.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dongwei6457 dongwei6457 10年前

    CakePHP lets you override pretty much anything, you just need to understand its structure. The best thing to do is to copy the default.ctp file from your cake folder in APP_DIR\cake\libs\view\layouts\default.ctp.

    Once you've copied this, place it in APP_DIR\app\views\layouts\ and cake will start using that file. To customize it, simply open up that file and change it in your editor.

    点赞 评论 复制链接分享
  • dqvj51875 dqvj51875 10年前

    You need to define your custom layout in your controller to override default layout:

    //in controller say in beforeFilter
    function beforeFilter() {
     $this->layout = "your_layout_name";

    Hope it helps

    点赞 评论 复制链接分享