Welcome Guest, Not a member yet? Register   Sign In
css render
#1
Question 

Hi

I'm new here and plagued myself much too long with another product from the US.
I find it amazing - in particular the docs, the whole philosophy of CI is simply great.
No curlicue, no distractions, pure white meat. I love it.

However I'm quite stuck with my first steps in using an applying CI.
I can't get an external css file rendered while inline rendering in particular with <style></style> tags works flawless.

Here my very basic code, a bit modded from the tutorial.
I am pretty sure that I overlooked something and that the answer is literally laying in front of mine but I don't see it:

config settings and database settings are cool, don't want to cite em here...

Controller:
Code:
<?php
class Pages extends CI_Controller {

    public function __construct() {
        parent::__construct();

        $this->load->helper('url'); //needed in markup
        $this->load->helper('html');
       //$this->load->model('[optional_path]model_name');// add our custom model(s)
    }

   

    public function view($page = 'home') {
                                 
        if ( ! file_exists(APPPATH.'views/pages/'.$page.'.php')) {

                show_404(); // no page, show 404
        }

        $data['title'] = ucfirst($page);

        $this->load->view('markup/header', $data,'',FALSE);
        $this->load->view('pages/'.$page, $data,'',FALSE);
        $this->load->view('markup/footer', $data,'',FALSE);
    }
}
header.php
PHP Code:
<html>
<
head>
<
title><?php echo ($title); ?></title> <!-- browser-tab title -->
<?php echo link_tag('myProject/css/styles.css'); ?>
</head>
<body>


<div id="menu_links">
    <a href="<?php echo site_url('home'); ?>">Home</a>
    <a href="<?php echo site_url('user/login/register'); ?>">Register</a>
    <a href="<?php echo site_url('user/login/login'); ?>">Login</a>
    <a href="<?php echo site_url('about'); ?>">About</a>
</div>

<?php echo br(3); ?>
<?php 
echo heading('Welcome!'3); ?>
<?php 
echo br(1); ?>
footer is very basic and closes the body and html tags.

styles.css
PHP Code:
body {
  background-colorblack;

The directory structure is like this:

  .git
    |
application
    |
    |
myProject
    |
    |------css
    |         |
    |          styles.css
    |
    |------public
    |          |
    |          index.php
    |
    |
system
    |
    |
vendor


Any help is very appreciated as I invested already too much time in such a tiny affair.

Greets
Reply
#2

Your css folder should be in your public folder.
PHP Code:
<?php echo link_tag('css/styles.css'); ?>
Reply
#3

YES!

that's it, great, thanks a lot.
Reply
#4

Your welcome, glad it worked out. Welcome to the CI family btw! :-)
Reply




Theme © iAndrew 2016 - Forum software by © MyBB