<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>um what now?</title>
	
	<link>http://umwhatnow.com</link>
	<description>stupid-easy code snippets</description>
	<lastBuildDate>Sat, 07 Aug 2010 05:11:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/um-what-now" /><feedburner:info uri="um-what-now" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>um-what-now</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Ruby: For loop</title>
		<link>http://feedproxy.google.com/~r/um-what-now/~3/AvKVsEkR8AM/</link>
		<comments>http://umwhatnow.com/ruby-for-loop/#comments</comments>
		<pubDate>Sat, 07 Aug 2010 05:11:00 +0000</pubDate>
		<dc:creator>Arwhy Eighen</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[collection]]></category>
		<category><![CDATA[for]]></category>
		<category><![CDATA[for loop]]></category>
		<category><![CDATA[hash]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://umwhatnow.com/?p=427</guid>
		<description><![CDATA[Could it be any simpler? This is FOR-ing through a collection, array, hash, zoo, snorkel, what have you. &#60;% for book in books %&#62; &#60;%= book %&#62; &#60;% end %&#62; Related posts SQL: While Loop (0) RubyNoob: The Genesis (0) Ruby: Embedded Ruby (ERb) (0) Ruby: Convert to String (0) Ruby: Convert to Integer (0)]]></description>
			<content:encoded><![CDATA[<p>Could it be any simpler? This is FOR-ing through a collection, array, hash, zoo, snorkel, what have you.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">for</span> book <span style="color:#9966CC; font-weight:bold;">in</span> books <span style="color:#006600; font-weight:bold;">%&gt;</span>
     <span style="color:#006600; font-weight:bold;">&lt;%</span>= book <span style="color:#006600; font-weight:bold;">%&gt;</span>
<span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>


	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://umwhatnow.com/sql-while-loop/" title="SQL: While Loop (July 15, 2010)">SQL: While Loop</a> (0)</li>
	<li><a href="http://umwhatnow.com/rubynoob-the-genesis/" title="RubyNoob: The Genesis (July 20, 2010)">RubyNoob: The Genesis</a> (0)</li>
	<li><a href="http://umwhatnow.com/ruby-embedded-ruby-erb/" title="Ruby: Embedded Ruby (ERb) (August 6, 2010)">Ruby: Embedded Ruby (ERb)</a> (0)</li>
	<li><a href="http://umwhatnow.com/ruby-convert-to-string/" title="Ruby: Convert to String (July 26, 2010)">Ruby: Convert to String</a> (0)</li>
	<li><a href="http://umwhatnow.com/ruby-convert-to-integer/" title="Ruby: Convert to Integer (July 26, 2010)">Ruby: Convert to Integer</a> (0)</li>
</ul>

<img src="http://feeds.feedburner.com/~r/um-what-now/~4/AvKVsEkR8AM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://umwhatnow.com/ruby-for-loop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://umwhatnow.com/ruby-for-loop/</feedburner:origLink></item>
		<item>
		<title>Ruby: Embedded Ruby (ERb)</title>
		<link>http://feedproxy.google.com/~r/um-what-now/~3/FUHeqaFPaJ4/</link>
		<comments>http://umwhatnow.com/ruby-embedded-ruby-erb/#comments</comments>
		<pubDate>Sat, 07 Aug 2010 05:07:55 +0000</pubDate>
		<dc:creator>Arwhy Eighen</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[embedded ruby]]></category>
		<category><![CDATA[ERb]]></category>
		<category><![CDATA[Kate]]></category>
		<category><![CDATA[Nate]]></category>
		<category><![CDATA[output]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[structure]]></category>

		<guid isPermaLink="false">http://umwhatnow.com/?p=425</guid>
		<description><![CDATA[Time.now is a ruby function to display the current time. The]]></description>
			<content:encoded><![CDATA[<p>Time.now is a ruby function to display the current time. The <%= signifies this is a value being output from ruby.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span>= <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p>This uses the <% (no equals sign) which doesn't output anything on the ruby lines itself, unless you tell it to in the middle of the structure.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span> 5.<span style="color:#9900CC;">times</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
I will not con Kate and Nate in class
<span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p>The minus sign with the ending tag gets rid of unsightly line breaks and takes 10 years off your code. Free trial today!</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span>= <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span> <span style="color:#006600; font-weight:bold;">-%&gt;</span></pre></div></div>


	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://umwhatnow.com/rubynoob-the-genesis/" title="RubyNoob: The Genesis (July 20, 2010)">RubyNoob: The Genesis</a> (0)</li>
	<li><a href="http://umwhatnow.com/ruby-for-loop/" title="Ruby: For loop (August 6, 2010)">Ruby: For loop</a> (0)</li>
	<li><a href="http://umwhatnow.com/ruby-convert-to-string/" title="Ruby: Convert to String (July 26, 2010)">Ruby: Convert to String</a> (0)</li>
	<li><a href="http://umwhatnow.com/ruby-convert-to-integer/" title="Ruby: Convert to Integer (July 26, 2010)">Ruby: Convert to Integer</a> (0)</li>
	<li><a href="http://umwhatnow.com/php-output-data-with-var_dump/" title="PHP: Output Data with var_dump (July 16, 2010)">PHP: Output Data with var_dump</a> (0)</li>
</ul>

<img src="http://feeds.feedburner.com/~r/um-what-now/~4/FUHeqaFPaJ4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://umwhatnow.com/ruby-embedded-ruby-erb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://umwhatnow.com/ruby-embedded-ruby-erb/</feedburner:origLink></item>
		<item>
		<title>Ruby: Convert to Integer</title>
		<link>http://feedproxy.google.com/~r/um-what-now/~3/HHci_rmIzy4/</link>
		<comments>http://umwhatnow.com/ruby-convert-to-integer/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 19:57:49 +0000</pubDate>
		<dc:creator>Arwhy Eighen</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Convert]]></category>
		<category><![CDATA[integer]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://umwhatnow.com/?p=421</guid>
		<description><![CDATA[To convert a string or other object into an integer (number) do this: &#34;23&#34;.to_i This will produce 23 (as a number) If you do something like this: &#34;Hello&#34;.to_i You will get 0 returned, because Ruby can&#8217;t understand that object ans translate it into a number. Related posts Ruby: Convert to String (0) RubyNoob: The Genesis [...]]]></description>
			<content:encoded><![CDATA[<p>To convert a string or other object into an integer (number) do this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#996600;">&quot;23&quot;</span>.<span style="color:#9900CC;">to_i</span></pre></div></div>

<p>This will produce 23 (as a number)</p>
<p>If you do something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#996600;">&quot;Hello&quot;</span>.<span style="color:#9900CC;">to_i</span></pre></div></div>

<p>You will get 0 returned, because Ruby can&#8217;t understand that object ans translate it into a number.</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://umwhatnow.com/ruby-convert-to-string/" title="Ruby: Convert to String (July 26, 2010)">Ruby: Convert to String</a> (0)</li>
	<li><a href="http://umwhatnow.com/rubynoob-the-genesis/" title="RubyNoob: The Genesis (July 20, 2010)">RubyNoob: The Genesis</a> (0)</li>
	<li><a href="http://umwhatnow.com/ruby-for-loop/" title="Ruby: For loop (August 6, 2010)">Ruby: For loop</a> (0)</li>
	<li><a href="http://umwhatnow.com/ruby-embedded-ruby-erb/" title="Ruby: Embedded Ruby (ERb) (August 6, 2010)">Ruby: Embedded Ruby (ERb)</a> (0)</li>
	<li><a href="http://umwhatnow.com/asp-net-c-datatable-compute/" title="ASP.NET C#: DataTable Compute (July 16, 2010)">ASP.NET C#: DataTable Compute</a> (0)</li>
</ul>

<img src="http://feeds.feedburner.com/~r/um-what-now/~4/HHci_rmIzy4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://umwhatnow.com/ruby-convert-to-integer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://umwhatnow.com/ruby-convert-to-integer/</feedburner:origLink></item>
		<item>
		<title>Ruby: Convert to String</title>
		<link>http://feedproxy.google.com/~r/um-what-now/~3/alA84zPfyFk/</link>
		<comments>http://umwhatnow.com/ruby-convert-to-string/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 19:52:00 +0000</pubDate>
		<dc:creator>Arwhy Eighen</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Conversion]]></category>
		<category><![CDATA[lang]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://umwhatnow.com/?p=419</guid>
		<description><![CDATA[To convert a number to a string in Ruby, do this: 40.to_s Related posts Ruby: Convert to Integer (0) RubyNoob: The Genesis (0) Ruby: For loop (0) Ruby: Embedded Ruby (ERb) (0) ASP.NET C#: DataTable Compute (0)]]></description>
			<content:encoded><![CDATA[<p>To convert a number to a string in Ruby, do this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">40.<span style="color:#9900CC;">to_s</span></pre></div></div>


	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://umwhatnow.com/ruby-convert-to-integer/" title="Ruby: Convert to Integer (July 26, 2010)">Ruby: Convert to Integer</a> (0)</li>
	<li><a href="http://umwhatnow.com/rubynoob-the-genesis/" title="RubyNoob: The Genesis (July 20, 2010)">RubyNoob: The Genesis</a> (0)</li>
	<li><a href="http://umwhatnow.com/ruby-for-loop/" title="Ruby: For loop (August 6, 2010)">Ruby: For loop</a> (0)</li>
	<li><a href="http://umwhatnow.com/ruby-embedded-ruby-erb/" title="Ruby: Embedded Ruby (ERb) (August 6, 2010)">Ruby: Embedded Ruby (ERb)</a> (0)</li>
	<li><a href="http://umwhatnow.com/asp-net-c-datatable-compute/" title="ASP.NET C#: DataTable Compute (July 16, 2010)">ASP.NET C#: DataTable Compute</a> (0)</li>
</ul>

<img src="http://feeds.feedburner.com/~r/um-what-now/~4/alA84zPfyFk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://umwhatnow.com/ruby-convert-to-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://umwhatnow.com/ruby-convert-to-string/</feedburner:origLink></item>
		<item>
		<title>CakePHP: Layouts</title>
		<link>http://feedproxy.google.com/~r/um-what-now/~3/t20bhHy3O3Y/</link>
		<comments>http://umwhatnow.com/cakephp-layouts/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 16:44:13 +0000</pubDate>
		<dc:creator>Arwhy Eighen</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[HTML 4]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Layouts]]></category>
		<category><![CDATA[pageTitle]]></category>
		<category><![CDATA[static elements]]></category>

		<guid isPermaLink="false">http://umwhatnow.com/?p=304</guid>
		<description><![CDATA[photo credit: Vagabond Shutterbug If there are things you want to appear on every page of your website, built in CakePHP, you will want to use a layout. I generally use one layout for header, footer, search, and other static elements. You can use multiples, but most of the time you won&#8217;t need more than [...]]]></description>
			<content:encoded><![CDATA[<div class="alignright" style="margin: 4px;"><a title="Kevin and Michelle lay out" href="http://www.flickr.com/photos/33636891@N00/3278574756/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/33636891_N00/3278574756/?referer=');"><img style="margin: 4px; border: 1px solid black;" src="http://farm4.static.flickr.com/3501/3278574756_2c00a86b98_m.jpg" border="0" alt="Kevin and Michelle lay out" width="240" height="180" /></a><br />
<small><a title="Attribution-NoDerivs License" href="http://creativecommons.org/licenses/by-nd/2.0/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/creativecommons.org/licenses/by-nd/2.0/?referer=');"><img src="http://umwhatnow.com/wp-content/plugins/photo-dropper/images/cc.png" border="0" alt="Creative Commons License" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.photodropper.com/photos/?referer=');">photo</a> credit: <a title="Vagabond Shutterbug" href="http://www.flickr.com/photos/33636891@N00/3278574756/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/33636891_N00/3278574756/?referer=');">Vagabond Shutterbug</a></small>
</div>
<p>If there are things you want to appear on every page of your website, built in CakePHP, you will want to use a layout. I generally use one layout for header, footer, search, and other static elements. You can use multiples, but most of the time you won&#8217;t need more than one.</p>
<p>Layouts are created in the app/views/layouts folder, and are named with .ctp at the end, just like regular view files. The only difference with layouts is that they are applied to every view, as a sort of wrapper or warm blanket. This makes views truly just the content portion of your page. If you have ever used a header file in PHP, or a Master Page in ASP.NET, a layout is the same idea. </p>
<p>You need to name your first layout &#8220;default.ctp&#8221; as this is a special name that Cake &#8212; in it&#8217;s all knowing wisdom &#8212; will automatically pick up and use, without you telling it to do so.  </p>
<h2>Creating A Layout</h2>
<p>Once you&#8217;ve created the file, you&#8217;ll need to add the basic contents of an HTML file, doctype, header, body, etc. It is, after all, just an HTML page with strange innards. I think I just made views equal to endtrails, but hey, this is a family blog, right? This will get you started, and I will explain after:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;title&gt;sitename here - <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$title_for_layout</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/title&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">css</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'styles'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$scripts_for_layout</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> 
&lt;/head&gt;
&lt;body&gt;
header html would go here
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$content_for_layout</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
footer html would go here
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p>You may have noticed a few things Cakeish and not ordinary HTML or PHP here, and if you haven&#8217;t well, get to noticing already! </p>
<h2>$title_for_layout</h2>
<p>This is the page title set in the controller action. So in app/controllers/posts_controller.php (replace posts with whatever your controller is named)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> PostsController <span style="color: #000000; font-weight: bold;">extends</span> AppController<span style="color: #009900;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
          <span style="color: #666666; font-style: italic;">// this line sets $title_for_layout</span>
          <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pageTitle</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'User Homepage'</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h2>$html->css() link</h2>
<p>This is the way to include a CSS file in the page, not unique to layouts, but useful none the less. Your css file needs to be in app/webroot/css/ and named whatever you want. In this case, $html->css(&#8216;styles&#8217;); is linked to my css file named styles.css, so you leave off the .css when linking.</p>
<h2>$scripts_for_layout</h2>
<p>This acts as a pass-through, so any javascript files added to views will be loaded in the layout, so you can use them. This allows different views to have different sets of javascript files. To add a javascript file to a certain view, you&#8217;d want to use this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$javascript</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">link</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'scriptname'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The false tells the script to load in the layout, not inline in the view.</p>
<p>If you want a javascript file to be used in all pages (that use this layout), simply add it directly to the header portion of the layout, like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$javascript</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">link</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'scriptname'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h2>$content_for_layout</h2>
<p>This is the actual view content that will be rendered inside your layout. This is usually your content area that changes based on what page you&#8217;re on. This is the meat of the page, where the action happens. The layout is all on the outside looking in, going &#8220;wow, I&#8217;m boring, wish I did more than just held the content.&#8221; Meanwhile the content is all jumping up and down in the bouncy castle going &#8220;woo hoo!&#8221;</p>
<h2>Using more than one layout</h2>
<p>If you have more than one layout file, you will need to tell each controller action what layout it should be using. </p>
<p>To set a different layout file for an action, other than default:<br />
In app/controllers/posts_controller.php (replace posts with whatever your controller is named)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> PostsController <span style="color: #000000; font-weight: bold;">extends</span> AppController<span style="color: #009900;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
          <span style="color: #666666; font-style: italic;">// this line sets the layout</span>
          <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">layout</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'portal'</span><span style="color: #339933;">;</span>
&nbsp;
         <span style="color: #666666; font-style: italic;">// if not set, it uses the layout file named &quot;default.ctp&quot;</span>
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>That, probably too simply, is a layout and how to use it. </p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://umwhatnow.com/cakephp-html-link/" title="CakePHP: HTML Link (July 19, 2010)">CakePHP: HTML Link</a> (0)</li>
	<li><a href="http://umwhatnow.com/cakephp-find-all-records/" title="CakePHP: find all records (July 15, 2010)">CakePHP: find all records</a> (0)</li>
</ul>

<img src="http://feeds.feedburner.com/~r/um-what-now/~4/t20bhHy3O3Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://umwhatnow.com/cakephp-layouts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://umwhatnow.com/cakephp-layouts/</feedburner:origLink></item>
		<item>
		<title>RubyNoob: The Genesis</title>
		<link>http://feedproxy.google.com/~r/um-what-now/~3/4P3NCPX98QU/</link>
		<comments>http://umwhatnow.com/rubynoob-the-genesis/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 15:55:44 +0000</pubDate>
		<dc:creator>Arwhy Eighen</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[genesis]]></category>
		<category><![CDATA[learning]]></category>
		<category><![CDATA[noob]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[rubynoob]]></category>

		<guid isPermaLink="false">http://umwhatnow.com/?p=356</guid>
		<description><![CDATA[Ruby Logo by hongiiv Today I am starting to learn Ruby, and that so I can next learn Ruby on Rails. I have flirted with the RoR language, been a long-time fan, but today I become a first-time caller. I am tired of being on the outside looking into the red-tinted party in the hizouse. [...]]]></description>
			<content:encoded><![CDATA[<div class="wp-caption alignright" style="width: 206px; margin: 4px;"><a href="http://www.flickr.com/photos/hongiiv/2937154327/" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/hongiiv/2937154327/?referer=');"><img src="http://farm4.static.flickr.com/3162/2937154327_50039eaee4_m.jpg" title="Ruby Logo" alt="Ruby Logo" width="196" height="240" ></a>
<p class="wp-caption-text"><a href="http://www.flickr.com/photos/hongiiv/2937154327/" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/hongiiv/2937154327/?referer=');">Ruby Logo</a> by <a href="http://www.flickr.com/photos/hongiiv/" onclick="pageTracker._trackPageview('/outgoing/www.flickr.com/photos/hongiiv/?referer=');">hongiiv</a></p>
</div>
<p>Today I am starting to learn Ruby, and that so I can next learn Ruby on Rails. I have flirted with the RoR language, been a long-time fan, but today I become a first-time caller. I am tired of being on the outside looking into the red-tinted party in the hizouse. It is time for me to take up the banner of gemmed goodness.</p>
<p>This is the start of something new. RubyNoob will be my attempt to document my journey from Ruby Noob to somewhere past the gates of proficiency, and perhaps into expertise one day in the distant future. Join me won&#8217;t you?</p>
<p>I will be posting RubyNoob posts with all my notes and what I learned that day in Ruby. It may not be every day, as I may not have the time to focus on Ruby much, depending on deadlines and family stuff. Let me know what you think of what will be repeated struggle and incredulousity as I learn. If you are a Ruby guru, by all means, let me have it, tell me what I am doing wrong or what it is I need to do. I&#8217;m all ears for the best advice. Thanks, and I hope you enjoy this jaunt into the gun fight with a letter opener. Maybe you will learn along with me, and be able to write Ruby and/or Rails at the end of this.</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://umwhatnow.com/ruby-for-loop/" title="Ruby: For loop (August 6, 2010)">Ruby: For loop</a> (0)</li>
	<li><a href="http://umwhatnow.com/ruby-embedded-ruby-erb/" title="Ruby: Embedded Ruby (ERb) (August 6, 2010)">Ruby: Embedded Ruby (ERb)</a> (0)</li>
	<li><a href="http://umwhatnow.com/ruby-convert-to-string/" title="Ruby: Convert to String (July 26, 2010)">Ruby: Convert to String</a> (0)</li>
	<li><a href="http://umwhatnow.com/ruby-convert-to-integer/" title="Ruby: Convert to Integer (July 26, 2010)">Ruby: Convert to Integer</a> (0)</li>
	<li><a href="http://umwhatnow.com/ruby-on-rails-rake-commands-list/" title="Ruby on Rails: Rake commands list (July 20, 2010)">Ruby on Rails: Rake commands list</a> (0)</li>
</ul>

<img src="http://feeds.feedburner.com/~r/um-what-now/~4/4P3NCPX98QU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://umwhatnow.com/rubynoob-the-genesis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://umwhatnow.com/rubynoob-the-genesis/</feedburner:origLink></item>
		<item>
		<title>Ruby on Rails: Rake commands list</title>
		<link>http://feedproxy.google.com/~r/um-what-now/~3/XksCUbQwOaQ/</link>
		<comments>http://umwhatnow.com/ruby-on-rails-rake-commands-list/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 06:54:23 +0000</pubDate>
		<dc:creator>Arwhy Eighen</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[commands list]]></category>
		<category><![CDATA[rake]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://umwhatnow.com/?p=342</guid>
		<description><![CDATA[For a list of rake commands, fire up the command line and type: rake -t Related posts RubyNoob: The Genesis (0)]]></description>
			<content:encoded><![CDATA[<p>For a list of rake commands, fire up the command line and type:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;">rake <span style="color:#006600; font-weight:bold;">-</span>t</pre></div></div>


	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://umwhatnow.com/rubynoob-the-genesis/" title="RubyNoob: The Genesis (July 20, 2010)">RubyNoob: The Genesis</a> (0)</li>
</ul>

<img src="http://feeds.feedburner.com/~r/um-what-now/~4/XksCUbQwOaQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://umwhatnow.com/ruby-on-rails-rake-commands-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://umwhatnow.com/ruby-on-rails-rake-commands-list/</feedburner:origLink></item>
		<item>
		<title>WordPress: Enable New 3.0 Menus in Older Themes</title>
		<link>http://feedproxy.google.com/~r/um-what-now/~3/d9yPInTue6s/</link>
		<comments>http://umwhatnow.com/wordpress-enable-new-3-0-menus-in-older-themes/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 06:52:25 +0000</pubDate>
		<dc:creator>Arwhy Eighen</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Appearance]]></category>
		<category><![CDATA[custom menus]]></category>
		<category><![CDATA[Menus]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[setup]]></category>
		<category><![CDATA[theme]]></category>

		<guid isPermaLink="false">http://umwhatnow.com/?p=346</guid>
		<description><![CDATA[Enabling 3.0 Menu Support If you have WordPress 3.0 installed, but your theme is older and doesn&#8217;t support it, here&#8217;s how to make those fancy awesome new menus work in your theme&#8230; First, sign into the admin. This is located at www.yoursitehere.com/wp-admin Next, click on the Appearance Section. Click Editor Click Theme Functions (functions.php) on [...]]]></description>
			<content:encoded><![CDATA[<h2>Enabling 3.0 Menu Support</h2>
<p>If you have WordPress 3.0 installed, but your theme is older and doesn&#8217;t support it, here&#8217;s how to make those fancy awesome new menus work in your theme&#8230;</p>
<ol>
<li>First, sign into the admin. This is located at www.yoursitehere.com/wp-admin</li>
<li>Next, click on the <em><strong>Appearance</strong></em> Section.</li>
<li>Click <em><strong>Editor</strong></em></li>
<li>Click <em><strong>Theme Functions (functions.php)</strong></em> on the right.</li>
<li>Scroll down to the bottom of the file, and just before the closing tag &#8220;?>&#8221; copy this code:

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> navMenusEnable<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	add_theme_support<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'menus'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'after_setup_theme'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'navMenusEnable'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This will make sure your theme can use the menu system new in WordPress 3.0.
</li>
<li>Click <em><strong>Update File</strong></em></li>
</ol>
<p></p>
<h2>Retrofit Your Theme Files</h2>
<ol>
<li>While in this screen click <em><strong>Header</strong></em> (header.php) on the right</li>
<li>Find the line (in almost all themes) where it looks like this:

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_list_pages<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title_li='</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>It may not match this exactly, but you will see the <em><strong>wp_list_pages()</strong></em> function in there, with some random stuff in between the (). That is fine, don&#8217;t worry. All you do is place 2 slashes in front of the <em><strong>wp_list_pages()</strong></em> portion, like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">//wp_list_pages('title_li='); ?&gt;</span></pre></div></div>

<p>This disables the old pages menu. You do this with slashes so that if anything goes wrong or you don&#8217;t like the new feature, you can always just go back and take the slashes out, and it will work like normal again.
</li>
<li>Just above the line you just added slashes to, add this code:

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_nav_menu<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'sort_column=menu_order'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

</li>
<li>Click <em><strong>Update File</strong></em></li>
</ol>
<p>The final code in the header should look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_nav_menu<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'sort_column=menu_order'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">//wp_list_pages('title_li='); ?&gt;</span></pre></div></div>

<p>You should now be able to go to <em><strong>Appearance</strong></em> then <em><strong>Menus</strong></em> and create custom menus that will automatically show up in your site. Cool huh?</p>
<p>WordPress 3.0 rocks for this and a ton of other reasons. Let me know if you&#8217;d like to see more on WordPress programming. I enjoy it, and I hope I can help you enjoy it too.</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li>No related posts.</li>
	</ul>

<img src="http://feeds.feedburner.com/~r/um-what-now/~4/d9yPInTue6s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://umwhatnow.com/wordpress-enable-new-3-0-menus-in-older-themes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://umwhatnow.com/wordpress-enable-new-3-0-menus-in-older-themes/</feedburner:origLink></item>
		<item>
		<title>CakePHP: HTML Link</title>
		<link>http://feedproxy.google.com/~r/um-what-now/~3/ZdwoSNHfd5Y/</link>
		<comments>http://umwhatnow.com/cakephp-html-link/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 15:12:06 +0000</pubDate>
		<dc:creator>Arwhy Eighen</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[HTML 4]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[action]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[htmlHelper]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://umwhatnow.com/?p=302</guid>
		<description><![CDATA[The HTML helper is pretty useful, here&#8217;s how you write a link in a view file: &#60;?php echo $html-&#62;link&#40;'click me', array&#40; 'controller'=&#62;'users', 'action'=&#62;'index' &#41; &#41;; ?&#62; The parameters in this are: title (what you actually click on) link location array(controller, action, id (if needed for edit)) (optional) attributes array Related posts CakePHP: find all records [...]]]></description>
			<content:encoded><![CDATA[<p>The HTML helper is pretty useful, here&#8217;s how you write a link in a view file:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">link</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'click me'</span><span style="color: #339933;">,</span>
     <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
          <span style="color: #0000ff;">'controller'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'users'</span><span style="color: #339933;">,</span>
          <span style="color: #0000ff;">'action'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'index'</span>
     <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>The parameters in this are:</p>
<li>title (what you actually click on)</li>
<li>link location array(controller, action, id (if needed for edit))</li>
<li>(optional) attributes array</li>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://umwhatnow.com/cakephp-find-all-records/" title="CakePHP: find all records (July 15, 2010)">CakePHP: find all records</a> (0)</li>
	<li><a href="http://umwhatnow.com/cakephp-layouts/" title="CakePHP: Layouts (July 20, 2010)">CakePHP: Layouts</a> (0)</li>
</ul>

<img src="http://feeds.feedburner.com/~r/um-what-now/~4/ZdwoSNHfd5Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://umwhatnow.com/cakephp-html-link/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://umwhatnow.com/cakephp-html-link/</feedburner:origLink></item>
		<item>
		<title>ASP.NET C#: DataTable Compute</title>
		<link>http://feedproxy.google.com/~r/um-what-now/~3/47FpLbC1I2o/</link>
		<comments>http://umwhatnow.com/asp-net-c-datatable-compute/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 18:40:28 +0000</pubDate>
		<dc:creator>Arwhy Eighen</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Compute]]></category>
		<category><![CDATA[DataTable]]></category>
		<category><![CDATA[OBJECT]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[ToString]]></category>

		<guid isPermaLink="false">http://umwhatnow.com/?p=295</guid>
		<description><![CDATA[If you want to perform a sum or count on the records in a DataTable, you can, very simply. You&#8217;ll have to have a DataTable with something in it, like results from a database, then you do this: // my DataTable is full of customer data and is named &#34;dt&#34; object newCustomerCount = dt.Compute&#40;&#34;count(id)&#34;,&#34;CustomerID &#62; [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to perform a sum or count on the records in a DataTable, you can, very simply.</p>
<p>You&#8217;ll have to have a DataTable with something in it, like results from a database, then you do this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// my DataTable is full of customer data and is named &quot;dt&quot;</span>
<span style="color: #FF0000;">object</span> newCustomerCount <span style="color: #008000;">=</span> dt.<span style="color: #0000FF;">Compute</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;count(id)&quot;</span>,<span style="color: #666666;">&quot;CustomerID &gt; 100&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>Parameters are both strings, (expression,filter)</p>
<p>The Compute function will return as an object, so it is a good idea to have your variable be an object too. The problem is that you often need an integer (number) or a text string to put into a label or textbox. Here&#8217;s how you get it there:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// this casts to an integer</span>
<span style="color: #FF0000;">int</span> var1 <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span><span style="color: #000000;">&#41;</span> newCustomerCount<span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">//this converts to a string</span>
lblNewCustomerTotal.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span> newCustomerCount.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>As my ASP.NET instructor Dana taught us, everything derives from OBJECT, and everything has a ToString() method. Moo Dana, good form.</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://umwhatnow.com/ruby-convert-to-string/" title="Ruby: Convert to String (July 26, 2010)">Ruby: Convert to String</a> (0)</li>
	<li><a href="http://umwhatnow.com/ruby-convert-to-integer/" title="Ruby: Convert to Integer (July 26, 2010)">Ruby: Convert to Integer</a> (0)</li>
	<li><a href="http://umwhatnow.com/using-datatable/" title="ASP.NET C#: Using DataTable (April 5, 2010)">ASP.NET C#: Using DataTable</a> (0)</li>
</ul>

<img src="http://feeds.feedburner.com/~r/um-what-now/~4/47FpLbC1I2o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://umwhatnow.com/asp-net-c-datatable-compute/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://umwhatnow.com/asp-net-c-datatable-compute/</feedburner:origLink></item>
	</channel>
</rss>
