简体   繁体   English

Kohana:Stylesheets + Routing =不工作

[英]Kohana: Stylesheets + Routing = Not Working

I'm trying to set up v3.2.0 of Kohana and I'm having a problem with stylesheets (and probably javascript files and images as well but I haven't tested those yet). 我正在尝试设置Kohana的v3.2.0并且我遇到了样式表的问题(可能还有javascript文件和图像,但我还没有测试过那些)。 Looking at the source code of my page I can see that it's going to the correct file path for the stylesheet however the page does not load as styled. 查看我的页面的源代码,我可以看到它将转到样式表的正确文件路径,但页面不会像样式一样加载。 If I view the stylesheet directly I get the error that there is no matching route for the file. 如果我直接查看样式表,我会得到错误,即该文件没有匹配的路由。 Is there a way I can make an exception to my routes to allow stylesheets and even javascript and images to be accessed? 有没有办法可以让我的路线例外,以允许访问样式表甚至javascript和图像?

This is my Template Controller file (well the only lines dealing with stylesheets) 这是我的模板控制器文件(只有处理样式表的行)

$this->template->styles = array('application/themes/1/style/style.php' => 'all');

(not sure what the "all" does but I got this from a tutorial and since it links to the correct stylesheet, I know there isn't any issue with it). (不确定“全部”是什么,但我从教程中得到了这个,因为它链接到正确的样式表,我知道它没有任何问题)。 The issue is most certainly from the routing. 问题肯定来自路由。

Routing in Boostrap (all of the variables are previously defined and work with other pages) Boostrap中的路由(所有变量先前已定义并与其他页面一起使用)

Route::set(
    'custom',
    '(<controller>(/<action>(/<param1>)(/<param2>(/<param3>(/<param4>(/<param5>(/<param6>)))))))'
    )->defaults(array(
    'controller' => $controller,
    'action'     => $action,
    'param1'     => $param1,
    'param2'     => $param2,
    'param3'     => $param3,
    'param4'     => $param4,
    'param5'     => $param5,
    'param6'     => $param6,
));

Also, I'm sure this comes into play...I have my style located in my application folder instead of "media" or "assets" in the document root. 此外,我确信这会发挥作用...我的样式位于我的应用程序文件夹中,而不是文档根目录中的“media”或“assets”。 Note that even when I did move my files to the document root, they were still unable to be accessed. 请注意,即使我将文件移动到文档根目录,它们仍然无法访问。

Is there a way I can match the url for the word "style" and if there is a match, DO NOT look for a route? 有没有办法可以匹配“风格”这个词的网址,如果匹配,不要寻找路线? This perhaps might have to be done through modrewrite in htaccess, I'm not sure. 这可能必须通过htaccess中的modrewrite来完成,我不确定。

Please help. 请帮忙。

Routes don't have anything to do with assets. 路线与资产无关。 Put them somewhere in DOCROOT, and link to them in your html like you normally would without a framework: 把它们放在DOCROOT的某个地方,并在你的html中链接到它们,就像你通常没有框架一样:

<link src="<?=url::base()?>assets/css/layout.css" />

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

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