Welcome Guest, Not a member yet? Register   Sign In
How to use the asset helper
#1

[eluser]Friedebarth[/eluser]
So, in order to circumvent the trouble with loading CSS via HTML, which, apart from constantly refusing to work also makes it much harder for users to customise the skin, I downloaded the Assets helper.

The question is, once I load the assets in my controller, like so:

Code:
public function index()
{
  // Load the view
  $this->load->view('welcome_message');
  // Load the assets helper
  $this->load->helper('asset');
  // Load the css file from the main asset css folder
  css_asset('style.css');
}

How do I incorporate it into my view? My view currently looks like this:

Code:
<!DOCTYPE html>
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;meta charset="utf-8"&gt;
&lt;title&gt;Welcome to CodeIgniter&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

<div id="container">
<h1>Welcome to CodeIgniter!</h1>

<div id="body">
  <p>The page you are looking at is being generated dynamically by CodeIgniter.</p>

  <p>If you would like to edit this page you'll find it located at:</p>
  <code>application/views/welcome_message.php</code>

  <p>The corresponding controller for this page is found at:</p>
  <code>application/controllers/welcome.php</code>

  <p>If you are exploring CodeIgniter for the very first time, you should start by reading the <a href="user_guide/">User Guide</a>.</p>
</div>

<p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds</p>
</div>

&lt;/body&gt;
&lt;/html&gt;

I tried doing this in the head:

Code:
&lt;link rel="stylesheet" type="text/css" href="&lt;?php $this-&gt;load-&gt;helper('asset'); echo text_output($stylesheet);?&gt;" /&gt;

While doing that in the controller:

Code:
$data['stylesheet'] = css_asset('style.css');

But that just ended up blanking the whole page. So how do I do it properly?




Theme © iAndrew 2016 - Forum software by © MyBB