开发者

Path Question for Kohana

I am ne开发者_如何转开发wbie to Kohana (v3 used). When I run the Hello World example. If I link to another css file, the css doesn't work.

Original example works well.

Let's go and make the view file application/views/site.php for our message:

<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>

I changed the Css to another file like this. and I placed the default.css at the same directory of application/views/default.css Instead the current ... with default.css. It doesn't work! ? Could you tell me why and how to fix it. Thanks.

<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>

update.

The Logo.gif also can't show up. And i created a new folder 'images' and placed a Logo.gif in it. like ths application/views/images/Logo.gif

application/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>

What's wrong with it? Thanks for reading and replies.


The way kohana works may take some getting used to. First, place your css in a directory under the root like this:

   media/css/default.css

Next, edit the template file: application/views/template.php

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

You do not need to add the link to the HTML. The framework will add the link for you using the template.

This page gives a few more details about this.


I think this has changed to

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

On newer Kohana versions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜