ytsejam
ytsejam

Reputation: 3429

Codeigniter CSS and Javascript files usage

I am writing a webpage with CI.I use the latest version. I need to learn how to imply CSS and Javascript files. I use nivoslider , jquery and many css files. I use application directory as

+application
  +views
    +pages
     -home.php
    +templates
     -header.php
     -footer.php
+system
+user_guide. 

Can you explain how to enable js and Css files. I made a research but my mind is blown away with the versions of codeigniter. this is my header.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN
     ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Kırmızı Eğitim Merkezi</title>
        <meta name="description" content="Empire - XHTML Template" />
    <!-- CSS -->
    <link href='./fonts/sansation.css' rel="stylesheet" type="text/css" />
    <!-- Get any font from here easily: http://www.google.com/webfonts -->
    <link href="./css/style.css" rel="stylesheet" type="text/css" />
    <link href="./fancybox/jquery.fancybox-1.3.4.css" rel="stylesheet" 
          type="text/css" />
    <link href="./css/nivo-slider.css" rel="stylesheet" type="text/css" />

    <!-- UPDATE BROWSER WARNING IF IE 7 OR LOWER -->
    <!--[if lt IE 8]><link href="css/stop_ie.css" rel="stylesheet" 
         type="text/css" /><![endif]--><!-- JAVASCRIPTS -->
    <script type="text/javascript" src="./js/jquery.min.js">
    </script><script type="text/javascript" 
         src="./js/jquery-ui-1.8.17.custom.min.js">
    </script><script type="text/javascript" 
         src="./fancybox/jquery.fancybox-1.3.4.pack.js">
    </script><script type="text/javascript" src="./js/jquery.nivo.slider.js">
    </script><script type="text/javascript" src="./js/jquery.bgslider.js">
    </script><script type="text/javascript" src="./js/preloader.js">
    </script><script type="text/javascript" src="./js/farbtastic.js">
    </script><script type="text/javascript" src="./js/basic.js">

    </script>

Can you advice me a way to use them ?

Upvotes: 1

Views: 3911

Answers (1)

Alaa Badran
Alaa Badran

Reputation: 1858

First, you need to place JS and CSS files somewhere like:

+ assets
   + js
   + css

Then you need to call them:

<link href='<?php echo base_url(); ?>assets/css/cssfile.css' rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/jquery.min.js">

Upvotes: 3

Related Questions