【问题标题】:Path Question for KohanaKohana的路径问题
【发布时间】:2010-01-23 15:50:50
【问题描述】:

我是 Kohana 的新手(使用了 v3)。 当我运行 Hello World 示例时。 如果我链接到另一个 css 文件,则 css 不起作用。

原始示例效果很好。

让我们为我们的消息创建视图文件 application/views/site.php:

<html>
    <head>
        <title>We've got a message for you!</title>
        <style type="text/css">
            body {font-family: Georgia;}
            h1 {font-style: italic;}

        </style>
    </head>
    <body>
        <h1><?php echo $message; ?></h1>
        <p>We just wanted to say it! :)</p>
    </body>
</html>

我将 Css 更改为像这样的另一个文件。我将 default.css 放在 application/views/default.css 的同一目录中 取而代之的是当前 ... 与 default.css。它不起作用! ?你能告诉我为什么以及如何解决它。谢谢。

<html>
    <head>
        <title>We've got a message for you!</title>
        <LINK href="default.css" rel="stylesheet" type="text/css">
    </head>
    <body>
        <h1><?php echo $message; ?></h1>
        <p>We just wanted to say it! :)</p>
    </body>
</html>

更新。

Logo.gif 也无法显示。 我创建了一个新文件夹“images”并在其中放置了一个 Logo.gif。 比如 application/views/images/Logo.gif

应用程序/views/site.php

 <div id="header">
  <div id="logo">
   <p><img src="../index.php/images/Logo.gif" alt=""/></p>
   <h1><?php echo $message; ?></a></h1>
   <h2>We just wanted to say it! :)</h2>
  </div>
 </div>

它有什么问题?感谢阅读和回复。

【问题讨论】:

  • default.css 相对于您的 php 文件在哪里?
  • 嗨文森特,我刚刚更新了帖子。 default.css 与 site.php 位于同一文件夹中。谢谢。

标签: php frameworks kohana


【解决方案1】:

kohana 的工作方式可能需要一些时间来适应。首先,将您的 css 放在根目录下,如下所示:

   media/css/default.css

接下来,编辑模板文件:application/views/template.php

  <?php echo html::stylesheet(
  array
  (
    'media/css/default',
  ),
  array
  (
    'screen',
   )
 );
 ?>

您不需要将链接添加到 HTML。框架将使用模板为您添加链接。

This page 提供了一些关于此的更多细节。

【讨论】:

    【解决方案2】:

    我认为这已更改为

    echo html::style('/media/css/styles.css');
    

    在较新的 Kohana 版本上。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多