Welcome Guest, Not a member yet? Register   Sign In
Noob question: base url
#1

[eluser]Unknown[/eluser]
So i am just starting out with OOP and i thought why not convert my current project to OOP with codeigniter. That way i can always expand and learn at the same time Big Grin

Now i came across my first hurdle.

I've got the view of my main page under views/icarus/index.php

This includes my style as well. How do i point my style href to my style.css?

This is probably an uber noob question Tongue
#2

[eluser]CroNiX[/eluser]
You can't with that structure because the view folder isn't publicly accessible via url.

Personally I create an assets directory within the root web folder
-public_html (usually my web root)
--assets/
---css/
---js/
---images/

Then just use '/assets/css/your-css-file.css' for the url, or '/assets/images/logo.png' for an image source, etc. I never use the full url, like "http://www.yoursite.com/assets/images/logo.png". This way it works the same on my local dev site and public dev site and public live site and saves a few kb on some pages with intensive assets like a photo gallery might have, and unless your asset is located on another domain, there is no need to include it.

Heres a simple article:
http://webdesign.about.com/od/beginningt...40502a.htm
#3

[eluser]Unknown[/eluser]
ahh! that's very smart! I was thinking of making the views folder somewhat like a template folder. But i guess your way of doing it is much better! Thanks! Smile
#4

[eluser]CroNiX[/eluser]
You can still do that.
maybe have a folder in your assets named for a different template. If you are loading a certain template for your view then get the assets from the same named template folder in your assets folder.

/assets/blue-theme/css/main.css
/assets/blue-theme/images/banner.jpg

/assets/green-theme/css/main.css
/assets/green-theme/images/banner.jpg

Then in your template you would just have
Code:
$theme_name = "green-theme"; //this would probably be in your controller passed to your view
<img src="/assets/$theme_name/image/banner.jpg" alt="" />  //in your views...




Theme © iAndrew 2016 - Forum software by © MyBB