Jump to content

Carregar CSS (CodeIgniter)


coxosclassic
 Share

Recommended Posts

Boas a todos,

Tenho um projeto em CodeIgniter mas nao consigo carregar css dinamicamente. (?)

Aqui vai um exemplo:

Controller:

class Main_page extends CI_Controller {

 public function index() {
..
$this->load->view('header');
..
 }
}

View:

<div class="header-container">
 <h1>Header Title</h1>
</div>

O que eu queria fazer, seria carregar o css no controlador juntamente com view, algo tipo:

..
$this->load->css('header'); // por exemplo...
$this->load->view('header');
..

Existe alguma maneira de carregar css dinamicamente em CI?

Que alternativas me podem sugerir?

Cumps,

cc

Cumps,

cc

Link to comment
Share on other sites

Obrigado a todos,

Acabei por resolver o problema incluindo os css num head dentro do header (que Ă© o primeiro elemento da pagina):

header_view:

<html>
 <head>
<title>Title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet" href="<?=$this->config->item('css_path');?>header.css" />

 </head>
 <body>
<div class="header-container">
  ...
</div>

O elemento body e html, serao fechados no documento de footer.

Nao sei se isto é uma boa prática, mas funciona.

Cumps,

cc

Edited by coxosclassic

Cumps,

cc

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.