0

I cannot get my CSS stylesheet to work with the Kohana framework that I downloaded and am using. I have been Googling nonstop for an hour now, and the solutions that others have suggested do not seem to fix my problem. This is the line of code that I have in my index.php file:

<?php echo HTML::style('/Applications/MAMP/htdocs/MOOCinator/media/css/bootstrap.css'); ?>

I have tried plain HTML as well as using the relative path for the CSS file. The CSS file's permissions allow it to be read by everyone. My webpage displays exactly as it should in the browser except for the CSS. Suggestions on how to fix this, please?

Thanks!

2 Answers 2

2

As falinsky stated all css resource files should be included as

<?php echo HTML::style('media/css/bootstrap.css'); ?>

From the comments under the other answer we 'debugged' the problem.

Your site url is not set correctly. This is how I got things .gitignore friendly.

// File application/bootstrap.php
$config = include(APPPATH .'config/environment.php');

Kohana::init(array(
    'base_url'    => $config['base_url'],
    'index_file'  => $config['index_file'],
));

Config file

// File application/config/environment.php
return array(
    'base_url'   => 'http://localhost/project/',
    'index_file' => FALSE,
);

I made a copy of this file as example.environment.php. In my gitignore I have

*
!.gitignore
!example.*

As to ignore all files except anything starting with example and the .gitignore file itself.

This is how I manage all my environment specific settings. Cookie, session, encryption hash, database, etc.

Sign up to request clarification or add additional context in comments.

5 Comments

So, to clarify, I should add the first block of code to application/bootstrap.php and then create a file application/config/environment.phpand add the second block of code to it. Also, could you clarify what you mean by .gitignore. I appreciate your help a lot, but I'm not exactly sure what you're suggesting I do. Thanks.
Yes. The application/bootstrap.php block should replace the existing block you have for Kohana::init. You mentioned github so I assumed you knew what git is. If you don't know it I can only suggest to read about it and try it out: git-scm.com In short: version management system.
Okay, I got your workaround to work. I do know what git is, but I haven't used .gitignore files before; however, I see from a quick Google search that this is a topic that I can easily learn about. Out of curiosity, do you think this issue will go away once I have the website on an actual web server? Or is this a bug that needs to be reported to Kohana?
It is not a bug, or an issue. Kohana leaves that control to you. And if it is, I'd say it's not worth to fix it. Also, if this answered your question, please mark the answer as such :)
I was able to make the original bootstrap.php code work simply by adding http:// in front of localhost:888/MOOCinator. Thank you so much for your help and patience.
2
<?php echo HTML::style('media/css/bootstrap.css'); ?>

please read documentation carefully

17 Comments

I've already tried that, unfortunately -- it still doesn't work. (That's what I meant by "relative path.")
HTML::Style uses the URL::base function so you need to use a relative path to the root of your domain. Can't you just check what HTML::style('media/css/bootstrap.css'); prints and check if it's the right URL.
That is the correct way to do it. If it does not work you have not set your environment settings properly.
@AmazingDreams Okay, I suspected that. PECL HTTP Enabled was the only test that my Kohana didn't pass -- it's message was Kohana can use the http extension for the Request_Client_External class. Could this be causing my issue? @Manuras
Nope, it is the site url that would be causing issues with these kinds of things. If that is not set properly you'd for example see something like http://localhost/media/css/bootstrap.css instead of the proper http://localhost/<PROJECT>/media/css/bootstrap.css. Check your bootstrap.php and see if it is set correctly.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.