<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hugh Fletcher &#187; HTML/CSS</title>
	<atom:link href="http://hughfletcher.com/blog/category/htmlcss/feed/" rel="self" type="application/rss+xml" />
	<link>http://hughfletcher.com</link>
	<description>What Can The Web Do For You?</description>
	<lastBuildDate>Sun, 07 Feb 2010 04:13:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Linking External Style Sheets In CodeIgniter</title>
		<link>http://hughfletcher.com/blog/linking-external-style-sheets-in-codeigniter/</link>
		<comments>http://hughfletcher.com/blog/linking-external-style-sheets-in-codeigniter/#comments</comments>
		<pubDate>Sun, 21 Oct 2007 21:47:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://hughfletcher.com/?p=71</guid>
		<description><![CDATA[Having been working with CodeIgniter for about two years now,  I have always struggled with how to structure my themes.  This past week I came up with what seems to be such an obvious solution for external css handling in CodeIgniter, that I was surprised I haven&#8217;t read about it elsewhere.  Perhaps [...]]]></description>
			<content:encoded><![CDATA[<p>Having been working with <a title="CodeIgniter" href="http://codeigniter.com">CodeIgniter</a> for about two years now,  I have always struggled with how to structure my themes.  This past week I came up with what seems to be such an obvious solution for external css handling in CodeIgniter, that I was surprised I haven&#8217;t read about it elsewhere.  Perhaps it&#8217;s so obvious that most felt it need not to be mentioned, however I would have loved to come across something like this long ago.</p>
<p><span id="more-71"></span></p>
<p>Before I start, credit must be given for my inspiration to the <a title="Rapyd For CodeIgniter" href="http://www.rapyd.com">Rapyd</a> dev team.  A lot of where I got this process from was due to how Rapyd has it&#8217;s samples set up in it&#8217;s distribution.  The Rapyd samples pre-load a view filled with css and then plants it inline into the final view that is outputted.  I liked the idea of having my css organized with my views, but didn&#8217;t want it inline with the rest of the html.  Here&#8217;s how linking it externally can simply be done&#8230;</p>
<p>First set up a controller, maybe say named &#8216;themes&#8217;, and inside that controller we will set up a &#8217;style&#8217; function. First in that style function were going to set the header and tell the browser that this will be a style sheet.  It&#8217;s very important you do this, otherwise the browser should disregard it, or at least I know in <a class="zem_slink" title="Firefox" rel="homepage" href="http://www.mozilla.com/en-US/firefox/">Firefox</a> it will.  Next we&#8217;ll call the view containing the css.</p>
<pre class="brush: php;">class Themes extends Controller {
   function index () {
      //do something
   }

   function style() {
      $this-&gt;output-&gt;set_header(&quot;Content-type: text/css&quot;);
      $this-&gt;load-&gt;view('themes/style');
   }
}</pre>
<p>Now we will just call this controller from our final output view,  or however you have your views embedded, in a link statement in your head area like so&#8230;</p>
<pre class="brush: xml;">&lt;link href=&quot;http://mysite.com/themes/style&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;</pre>
<p>An alternate way of doing this&#8230;</p>
<pre class="brush: php;">function style() {
   header(&quot;Content-type: text/css&quot;);
   echo $this-&gt;load-&gt;view('themes/style', null, true);
}</pre>
<p>However this method seems a little redundant to just use only a part of <a class="zem_slink" title="CodeIgniter" rel="homepage" href="http://www.codeigniter.com">CodeIgniter</a>&#8217;s abilities.  But it might show someone how to apply this method in an regular php application.  Douglas Clifton has a good article at <a title="Generating Dynamic CSS with PHP" href="http://www.digital-web.com/articles/generating_dynamic_css_with_php/">Digital Web Magazine</a> on doing it the non-CodeIgniter &#8220;style&#8221;.</p>
<p>Of course their is much more functionality you could add to your themes controller, but going into all that is beyond what I wanted to do here.  Theme changing and adding dynamic variables within your &#8216;css&#8217; views are just a start, and my meager little mind is thinking of many others, if I play with it more I&#8217;ll let ya know how it goes.</p>
]]></content:encoded>
			<wfw:commentRss>http://hughfletcher.com/blog/linking-external-style-sheets-in-codeigniter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
