Welcome Guest, Not a member yet? Register   Sign In
Best location to store css & img
#9

[eluser]ebot[/eluser]
you css and images files should be where you have the index.php file; that is at the root.
yeah on you config.php file add this code:
for your css add this
Code:
$config['css'] = "default.css";
; default.css is the name of my css file, so you can have any name for that. on you controller add this codes
Code:
$this->base = $this->config->item('base_url');
    $this->css = $this->config->item('css');
at function like this one:
Code:
function Blog()
  {
    parent::Controller();
    $this->base = $this->config->item('base_url');
    $this->css = $this->config->item('css');
    $this->load->model('Blog_model');
    
    
  }

or let give you one of my controllers so as you to know what to do:
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Blog extends Controller{

    var $base;
    var $css;

  function Blog()
  {
    parent::Controller();
    $this->base = $this->config->item('base_url');
    $this->css = $this->config->item('css');
    $this->load->model('Blog_model');
    
    
  }
  
  function index()
  {
    $data['css'] = $this->css;
    $data['base'] = $this->base;
    $data['title']="Welcome to My Blog | ebottabi.com";
    $data['entries']=$this->Blog_model->get_last_ten_entries(20);
    $data['comments']=$this->Blog_model->commentnum();
    $this->load->view('view', $data);
  }
  
  function gotopost($post_id)
  {
    $this->load->library('validation');
    $data['css'] = $this->css;
    $data['base'] = $this->base;
    $data['title']="Blog Post";
    $data['heading']="Post";
    $data['posts']= $this->Blog_model->getpost($post_id);
    
     $data['getcomments'] = $this->Blog_model->getcomments($post_id);
    $this->load->view('post',  $data);

    
  }
  function add()
  {
    $this->load->library('validation');
    
    $data['css'] = $this->css;
    $data['base'] = $this->base;
    $data['title']="Add Post | ebottabi.com";
    $this->load->view('addpost', $data);
  }
  
  function logout()
    {
        $this->load->model('Admin_model');
        $this->load->library('session');
        $this->load->helper('url');
        
        $user_id = $this->session->userdata('user_id');
        $session_id = $this->session->userdata('session_id');
        $user_id = $this->Admin_model->checkID($user_id, $session_id);
        
        if($user_id != 0)
        {
            $this->Admin_model->logout($user_id);
            $this->session->sess_destroy();
        }
        redirect('/admin', 'refresh');
    }
    
    function insert()
    {
        $this->load->library('validation');
        $data['css'] = $this->css;
        $data['base'] = $this->base;
        $data['title']="Add Post | ebottabi.com";
        $data['heading']="Add Post";
        $rules['title']    = "required";
        $rules['postdate']    = "required";
        $rules['summary']    = "required";
        $rules['post']    = "required";
                
        $this->validation->set_rules($rules);
        
        if ($this->validation->run() == FALSE)
        {  
            $data['message']="Add Post Incomplete!";
            $this->load->view('addpost', $data);
        }
        else{
            $data['message']="Add Post was Successfully ";
            $this->db->insert('posts', $_POST);
            $this->load->view('addpost',$data);
        }
        
    }
    
    function nav()
    {  
        
        $data['css'] = $this->css;
        $data['base'] = $this->base;      
         $data['title']="My Blog CMS Navigation Page";
        $data['heading']="Blog CMS";
        $data['entries']=$this->Blog_model->get_last_ten_entries(20);
        $this->load->view('nav_view', $data);
    }
    
    function comments()
    {
        
        $data['css'] = $this->css;
        $this->load->library('validation');
        $data['base'] = $this->base;      
         $data['title']="Post your comments";
        $this->load->view('comments', $data);
    }
    
    function comment_insert($post_id)
    {
        $this->load->library('validation');
        $data['css'] = $this->css;
        $data['base'] = $this->base;
        $data['title']="Post Your Comments | ebottabi.com";
        $data['heading']="Post Your Comments";
        $rules['name']    = "trim|required|min_length[6]|max_length[12]|xss_clean";
        $rules['email']    = "trim|required|valid_email|xss_clean";
        $rules['comments']    = "trim|required|min_length[6]|max_length[80]";
        $this->validation->set_rules($rules);
        if ($this->validation->run() == FALSE)
        {  
            $data['message']="Your comments Incomplete!";
            $goto=$this->gotopost($_POST['post_id']);
        }
        else{
            
            $comment = $this->Blog_model->insertcomm($_POST);
            $data['message']="Your comments has been Posted!";
            $this->load->view('comments', $data);
            
        
    }    
    
                
}

    
    }
    



?>

these are the codes i used in developing my blog and personal site. at the view section use these for the header:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;&lt;?php echo $title?&gt;&lt;/title&gt;
&lt;link href="&lt;?php echo base_url();?&gt;default.css" rel="stylesheet" type="text/css" /&gt;
&lt;/head&gt;
. i think this is all you need for the css and for the image use this, note that your image folder should be at the root, where you have your index.php, so this is the code for the images:
Code:
<img src='&lt;?=base_url()."image(folder where the images are found)/name of the image.png"?&gt;'>


Messages In This Thread
Best location to store css & img - by El Forum - 08-06-2008, 01:44 PM
Best location to store css & img - by El Forum - 08-06-2008, 04:21 PM
Best location to store css & img - by El Forum - 08-07-2008, 02:36 AM
Best location to store css & img - by El Forum - 08-07-2008, 03:12 AM
Best location to store css & img - by El Forum - 08-07-2008, 10:03 AM
Best location to store css & img - by El Forum - 08-13-2008, 10:13 AM
Best location to store css & img - by El Forum - 08-14-2008, 10:10 AM
Best location to store css & img - by El Forum - 08-14-2008, 11:24 AM
Best location to store css & img - by El Forum - 08-15-2008, 10:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB