php - Kohana: Stylesheets + Routing = Not Working

575

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). 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?

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)

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

Please help.

332

Answer

Solution:

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:

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

People are also looking for solutions to the problem: authentication - nginx server configuration returns php code

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.