简体   繁体   English

用Kohana将CSS,js和图像文件包含到模板中的正确方法是什么?

[英]What is the correct way to include css, js and image files into the template with Kohana?

With Kohana, using a Templating system, what is the correct way to link to the style sheets, javascript files and most importantly images? 使用Kohana,使用模板系统,链接到样式表,javascript文件和最重要的图像的正确方法是什么?

Shall I add <?php echo url::base() ?> in front of links? 我应该在链接前面添加<?php echo url::base() ?>吗? This surely does work but doesn't seem like the correct way to do things. 这确实可以工作,但似乎不是正确的处理方式。

What is the correct way? 正确的方法是什么?

  1. Put the assets in your DOCROOT somewhere: DOCROOT/assets/images/ 将资产放在DOCROOT某个位置: DOCROOT/assets/images/
  2. Use any of the following: 使用以下任何一种:
    • url::base().'assets/images/thing.png
    • url::site('assets/images/thing.png')
    • <base href="<?=url::base()?> (then use normal relative links in your html) <base href="<?=url::base()?> (然后在HTML中使用普通的相对链接)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM