将站点范围的CSS文件与CakePHP链接

时间:2011-07-17 01:47:51

标签: php cakephp stylesheet

我是PHP的新手,只是自定义我的主页。这是我对所有页面的主要布局:

<!DOCTYPE html>
<html>
    <head>
        <title><?php echo $title_for_layout ?></title>
        <?php echo $scripts_for_layout ?>
    </head>
    <body>
        <div id="header">

        </div>
        <div id="content">
            <?php echo $content_for_layout ?>
        </div>
        <div id="footer">

        </div>
    </body>
</html>

我想为我网站上名为“style.css”的所有网页创建一个全局CSS文件,该文件将存储在app/webroot/css/style.css中。我试过这样做:

<!DOCTYPE html>
<html>
    <head>
        <title><?php echo $title_for_layout ?></title>
        <link href="<?php $html->css('style', 'stylesheet', array('media'=>'all' ), false); ?>" rel="stylesheet" type="text/css" />
        <?php echo $scripts_for_layout ?>
    </head>
    <body>
        <div id="header">

        </div>
        <div id="content">
            <?php echo $content_for_layout ?>
        </div>
        <div id="footer">

        </div>
    </body>
</html>

但它没有出现在输出HTML中。有什么想法吗?

谢谢!

1 个答案:

答案 0 :(得分:2)

你绝对是Cake的新手:):

<title><?php echo $title_for_layout ?></title>
  <?php 
    echo $this->Html->css('style');
    echo $scripts_for_layout;
  ?>

这将为您输出完整的链接元素。