Welcome Guest, Not a member yet? Register   Sign In
Easier Way to Load Stylesheets?
#8

[eluser]John_Betong[/eluser]
[quote author="Colin Williams" date="1255144895"]1.) Don't put your stylesheets in the views folder (you application files should be outside the root anyway)
2.) Use absolute paths like "/style.css" leaving the domain out of it
3.) Get over the "pain" of typing out 30+ char strings
[/quote]
 
Hi Colin,
I failed to understand why the CSS file should not be in the views folder.
 
With each new application I have adopted the programming style of having a common MY_Controller.php but renamed to MY_APPPATH.php to avoid confusion. One of the functions in my common controller is:
 
./libaries/MY_[b]APPPATH.php[/b]
Code:
function  load_partials( $data=array() )
  {
    $data['doctype'] = doctype();      
    $data['header']  = $this->load->view('_header', $data, TRUE);
    ...
    ...
    return $data;
  }
 
 
./views/_header.php // prefixed with an underscore to denote a partial view
Code:
<link
     type='text/css'
     href='<?php echo APPPATH ?>views/style_04.css'
     rel='stylesheet'
     media='all'
  />
 
 

 
./views/v_mainview.php // prefixed with v_ to denote a view page
Code:
<?php echo $doctype ?>
<head>
  <?php echo $header ?>
  <style type='text/css'>
    div {border:dotted 0px #f00}
  </style>
<head>  
<body
...
...
...
</body
</html>
 
 
edit: added view


Messages In This Thread
Easier Way to Load Stylesheets? - by El Forum - 10-09-2009, 03:29 PM
Easier Way to Load Stylesheets? - by El Forum - 10-09-2009, 03:38 PM
Easier Way to Load Stylesheets? - by El Forum - 10-09-2009, 03:48 PM
Easier Way to Load Stylesheets? - by El Forum - 10-09-2009, 03:54 PM
Easier Way to Load Stylesheets? - by El Forum - 10-09-2009, 04:13 PM
Easier Way to Load Stylesheets? - by El Forum - 10-09-2009, 04:21 PM
Easier Way to Load Stylesheets? - by El Forum - 10-09-2009, 06:07 PM
Easier Way to Load Stylesheets? - by El Forum - 10-09-2009, 07:04 PM
Easier Way to Load Stylesheets? - by El Forum - 10-09-2009, 07:07 PM
Easier Way to Load Stylesheets? - by El Forum - 10-09-2009, 07:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB