<?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/"
	>

<channel>
	<title>chickenBeak</title>
	<atom:link href="http://www.chickenbeak.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chickenbeak.com</link>
	<description>Design tutorials for the greater good.</description>
	<pubDate>Thu, 18 Jun 2009 05:04:46 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Code your JavaScript to play nice with others</title>
		<link>http://www.chickenbeak.com/uncategorized/code-your-javascript-to-play-nice-with-others/2009/04/</link>
		<comments>http://www.chickenbeak.com/uncategorized/code-your-javascript-to-play-nice-with-others/2009/04/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 13:30:09 +0000</pubDate>
		<dc:creator>chris</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.chickenbeak.com/?p=76</guid>
		<description><![CDATA[Generally speaking, the key to using JavaScript in a website is to do so in a way that keeps it unobtrusive. Not only should the page work at a basic level (if at all possible) without JavaScript, but your code should not conflict with another developers code if dropped into a page.
This means two things&#8230;

Keep [...]]]></description>
			<content:encoded><![CDATA[<p>Generally speaking, the key to using JavaScript in a website is to do so in a way that keeps it unobtrusive. Not only should the page work at a basic level (if at all possible) without JavaScript, but your code should not conflict with another developers code if dropped into a page.</p>
<p>This means two things&#8230;</p>
<ol>
<li>Keep your code contained</li>
<li>Place your code in one location</li>
</ol>
<p>Lets see some examples. Note that I use <a rel="nofollow" href="http://developer.yahoo.com/yui/">YUI (Yahoo User Interface Library)</a> to speed my development. However, the methods here will work with many libraries, or with no library at all.</p>
<h3>Keep your code contained.</h3>
<p>When you include your script into a page, you may do it via an external file or by placing your code inline in the page. If your not careful, your variables will be available to code in other places you did not mean for it to be, or you may overwrite a variables value that another developers code was used for somewhere else.</p>
<pre class="code">
var current_value = "foo";
// do something with current value that should be foo....

//html code ... content... other stuff...

var current_value = "bar";
// do something with current value that should be bar

//html code ... content... other stuff...

// if we try to use the current_value down here, and expect it to be "foo" our code will break
</pre>
<p>How do we fix that leak? We can use an anonymous function to wrap the variables within, that way we don&#8217;t overwrite other peoples code later.</p>
<pre class="code">
var current_value = "foo";
// do something with current value that should be foo....

//html code ... content... other stuff...

// wrap the code
(function(){
  // no when we set "current_value" it will not override the "current_value from above
  var current_value = "bar";
  // do something with current value that should be bar
})();

//html code ... content... other stuff...

// if we try to use the current_value down here, it should be the of value "foo"
</pre>
<p>This is important to understand when working with other peoples code, you&#8217;ll break something quick if you start merging code and leaving variables everywhere unwrapped.</p>
<h3>Place your code in one location</h3>
<p>Example, I need to build a function that lets me click a &#8220;Print&#8221; button and open a new window. I can create one object that will take an element and add all the functionality we need.</p>
<pre class="code">

// this remains globally accessible
var AllMyStuff = {};

(function(){

  var Dom = YAHOO.util.Dom,
      Event = YAHOO.util.Event;

  var PrintPage = function(element)
  {
    this._print_element = element;
    this.init();
  };

  PrintPage.prototype = {

    _print_page_get_var: 'print_view=yes',
    _print_element: null,
    _window_name: 'PrintPage',
    _window_attributes: 'width=800,height=500,resizable=yes,scrollbars=yes,location=no',

    init: function()
    {
      // apply click event to the element
      Event.addListener(this._print_element, 'click', this.onPrintClick, null, this);
    },

    onPrintClick: function(event, args)
    {
      Event.preventDefault(event);
      var url = this.getUrlForNewWindow();
      window.open(url, this._window_name, this._window_attributes);
    }, 

    /**
     * Get the url. If there is a get variable in use, then append a new get variable after a &#038; char
     * to indicate we want the print version. Otherwise, add the ? along with the get var.
     */
    getUrlForNewWindow: function()
    {
      var url = window.location;
      // do we have a search query (get variables)
      if(url.search.length) {
        url = url.pathname + url.search + '&#038;' + this._print_page_get_var;
      } else {
        url = url.pathname + '?' + this._print_page_get_var;
      }
      return url;
    }

  }

// save our object in the global namespace so we can use it later
AllMyStuff.PrintPage = PrintPage;
})();
</pre>
<p>Notice how I&#8217;m using a global object to organize my code. This is one helpful habit that I ended up taking from YUI, they do this a lot and it&#8217;s helpful and keeps code organized.</p>
<p>The real reason for that though is that if I need to use that PrintPage object, I need to be able to do so later in the site. If I want to use this now, I just need to give the PrintPage object an element that will act as a button&#8230; for example&#8230;</p>
<pre class="code">
&lt; a href="printpage.html?thisPageTitle=something" id="printPageButton" &gt; print &lt; /a &gt;

// given that link is on the page somewhere, I can do this to activate the print page button now...
var print_button_element = document.getElementById('printPageButton');
var print_button_object = new AllMyStuff.PrintPage( print_button_element );
</pre>
<p>If you go through the code above, you&#8217;ll notice that the object has an init function that will use that element, and automatically add any event functionality needed for that button to work.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chickenbeak.com/uncategorized/code-your-javascript-to-play-nice-with-others/2009/04/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Anti-aliasing in Illustrator vs. Photoshop</title>
		<link>http://www.chickenbeak.com/photoshop/anti-aliasing-in-illustrator-vs-photoshop/2009/01/</link>
		<comments>http://www.chickenbeak.com/photoshop/anti-aliasing-in-illustrator-vs-photoshop/2009/01/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 13:38:06 +0000</pubDate>
		<dc:creator>ben</dc:creator>
		
		<category><![CDATA[Illustrator]]></category>

		<category><![CDATA[Photoshop]]></category>

		<guid isPermaLink="false">http://www.chickenbeak.com/?p=55</guid>
		<description><![CDATA[I’ve read articles applauding the pixel preview functionality of AI, especially when it comes to designing icons. While it does a good job for higher resolutions, I wouldn&#8217;t use it for 32&#215;32 and below. Compare these two icons:

Both are 16&#215;16 pixel circles drawn with vectors, and snapped to a 1&#215;1 pixel grid. You can hover [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve read articles applauding the pixel preview functionality of AI, especially when it comes to designing icons. While it does a good job for higher resolutions, I wouldn&#8217;t use it for 32&#215;32 and below. Compare these two icons:</p>
<p><a title="illustrator" href="#"><img class="alignnone size-full wp-image-56" src="http://www.chickenbeak.com/wp-content/uploads/2009/01/illustrator.png" alt="illustrator" width="48" height="48" style="border:none;" /></a><a title="photoshop" href="#"><img class="alignnone size-full wp-image-57" src="http://www.chickenbeak.com/wp-content/uploads/2009/01/photoshop.png" alt="photoshop" width="48" height="48" style="border:none;" /></a></p>
<p>Both are 16&#215;16 pixel circles drawn with vectors, and snapped to a 1&#215;1 pixel grid. You can hover over to see which was done in Illustrator and which in Photoshop, but first decide which one looks better-rounder, sharper, use whatever criteria you want.</p>
<p>IMHO, the Photoshop one is better. It&#8217;s not quite as crisp, but it seems rounder. The Illustrator one looks boxy and uneven.</p>
<p>Here&#8217;s a 1600% zoom in on both icons:</p>
<p><div id="attachment_58" class="wp-caption alignnone" style="width: 320px"><img class="size-full wp-image-58" src="http://www.chickenbeak.com/wp-content/uploads/2009/01/ai_closup.png" alt="ai_closup" width="310" height="310" /><p class="wp-caption-text">Illustrator, zoomed to 1600%</p></div></p>
<p><div id="attachment_59" class="wp-caption alignnone" style="width: 320px"><img class="size-full wp-image-59" src="http://www.chickenbeak.com/wp-content/uploads/2009/01/ps_closeup.png" alt="ps_closeup" width="310" height="310" /><p class="wp-caption-text">Photoshop, zoomed to 1600%</p></div></p>
<p>Note how Illustrator adds grey pixels to the left and top of the icon. It&#8217;s got to be a bug in the software. I had been considering using Illustrator for low-res icons, but based on that finding, I&#8217;ll stick with Photoshop.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chickenbeak.com/photoshop/anti-aliasing-in-illustrator-vs-photoshop/2009/01/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Symfony on Dreamhost</title>
		<link>http://www.chickenbeak.com/php/symfony-on-dreamhost/2008/12/</link>
		<comments>http://www.chickenbeak.com/php/symfony-on-dreamhost/2008/12/#comments</comments>
		<pubDate>Sun, 21 Dec 2008 05:36:11 +0000</pubDate>
		<dc:creator>chris</dc:creator>
		
		<category><![CDATA[Framework]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.chickenbeak.com/uncategorized/symfony-on-dreamhost/2008/12/</guid>
		<description><![CDATA[A few notes on getting Symfony 1.2 to run on a Dreamhost server. Dreamhost is perfectly capable of running Symfony, but you need to make sure of a few things. 
You need PHP 5 to run Symfony. It is currently installed by default, but it&#8217;s only the default for the apache user. If you ssh [...]]]></description>
			<content:encoded><![CDATA[<p>A few notes on getting Symfony 1.2 to run on a Dreamhost server. Dreamhost is perfectly capable of running Symfony, but you need to make sure of a few things. </p>
<p>You need PHP 5 to run Symfony. It is currently installed by default, but it&#8217;s only the default for the apache user. If you ssh into your server and try to run &#8217;symfony cc&#8217; or any other command, it bombs or errors out. This is because in the command line under your ssh user for some reason they default to PHP 4. (go ahead, ssh in and run &#8216;php -v&#8217;. you&#8217;ll see.)</p>
<p>I fixed this by doing the following&#8230;</p>
<p>1. edit your ~/.bash_profile and add the line &#8216;alias php=/usr/local/php5/bin/php&#8217;<br />
That will make PHP 5 the default when typing &#8216;php -v&#8217; or any other  php command into the terminal.</p>
<p>2. change how you use the ./symfony command. If your like me, you just type ./symfony cc or whatever when typing. You need to type &#8216;php ./symfony cc&#8217; instead, to make sure you use your alias to run symfony under PHP 5</p>
<p>References<br />
http://wiki.dreamhost.com/Installing_PHP5#Using_DreamHost.27s_PHP_5</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chickenbeak.com/php/symfony-on-dreamhost/2008/12/feed/</wfw:commentRss>
		</item>
		<item>
		<title>YUI - getElementsBy TagName</title>
		<link>http://www.chickenbeak.com/javascript/yui-getelementsby-tagname/2008/06/</link>
		<comments>http://www.chickenbeak.com/javascript/yui-getelementsby-tagname/2008/06/#comments</comments>
		<pubDate>Fri, 20 Jun 2008 13:27:08 +0000</pubDate>
		<dc:creator>chris</dc:creator>
		
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.chickenbeak.com/javascript/yui-getelementsby-tagname/2008/06/</guid>
		<description><![CDATA[Similar to jQuery, MooTools and other Javascript libraries, Yahoo!&#8217;s YUI DOM utility offers upgraded element searches. finding an element by class name is nice, but what if you want to find an element by tag name? 
YUI does not have a function named getElementsByTagName, but the getElementsBy will do just that. 
getElementsBy(method, tag, root, apply)
The [...]]]></description>
			<content:encoded><![CDATA[<p>Similar to jQuery, MooTools and other Javascript libraries, Yahoo!&#8217;s YUI DOM utility offers upgraded element searches. finding an element by class name is nice, but what if you want to find an element by tag name? </p>
<p>YUI does not have a function named getElementsByTagName, but the getElementsBy will do just that. </p>
<p><code>getElementsBy(method, tag, root, apply)</code></p>
<p>The <em>method</em> attribute is the important one here. The <em>tag</em>, and <em>root</em> are mainly there to offer optimization by reducing the possible scope of items the method is ran against.</p>
<p>If all you need is elements by a certain tag name, just pass in a function into the first argument that always returns true, and make sure to pass in a tag name for argument 2 that your looking for.</p>
<p>For example,<br />
<code>var forms = yDom.getElementsBy(function(el){return true;},'form');</code> should return an array of form elements that can be accessed further.</p>
<p>If you need a more specific filter (e.g. only &#8216;<em>a</em>&#8216; tags with <em>class=&#8217;selected&#8217;</em>) you could interact with the el item in the function. If you return true, the item will be added to the list. Otherwise return false and it won&#8217;t be in the array.</p>
<p>A good resource for more YUI Dom fun can be found at <a href="http://klauskomenda.com/archives/2007/10/27/agent-yui-mission-2-magic-of-the-dom/">klauskomenda.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.chickenbeak.com/javascript/yui-getelementsby-tagname/2008/06/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Developer cheat sheets</title>
		<link>http://www.chickenbeak.com/xhtml/developer-cheat-sheets/2008/06/</link>
		<comments>http://www.chickenbeak.com/xhtml/developer-cheat-sheets/2008/06/#comments</comments>
		<pubDate>Fri, 20 Jun 2008 13:19:11 +0000</pubDate>
		<dc:creator>chris</dc:creator>
		
		<category><![CDATA[CSS]]></category>

		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[SQL]]></category>

		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://www.chickenbeak.com/uncategorized/developer-cheat-sheets/2008/06/</guid>
		<description><![CDATA[This is just a link to a great little list of cheat sheets that will probably come in handy. It has a hand full of sheets for Design (CSS / HTML), Programming (PHP, ASP, ROR, JavaScript&#8230;), Database (MySQL, PostgreSQL, SQL Server&#8230;), and others (Vi, htaccess, Regular Expressions).
If you&#8217;ve ever found yourself looking for that exact [...]]]></description>
			<content:encoded><![CDATA[<p>This is just a link to a great little list of cheat sheets that will probably come in handy. It has a hand full of sheets for Design (CSS / HTML), Programming (PHP, ASP, ROR, JavaScript&#8230;), Database (MySQL, PostgreSQL, SQL Server&#8230;), and others (Vi, htaccess, Regular Expressions).</p>
<p>If you&#8217;ve ever found yourself looking for that exact command on Google, one of these might be worth pinning to your workspace wall.</p>
<p><a href="http://www.webmastersbydesign.com/2008/06/19/the-best-developer-cheat-sheets-around/">The Best Developer Cheat Sheets Around (from Webmasters by Design)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.chickenbeak.com/xhtml/developer-cheat-sheets/2008/06/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Tips to optimize your SQL and PHP</title>
		<link>http://www.chickenbeak.com/php/tips-to-optimize-your-sql-and-php/2008/01/</link>
		<comments>http://www.chickenbeak.com/php/tips-to-optimize-your-sql-and-php/2008/01/#comments</comments>
		<pubDate>Thu, 31 Jan 2008 04:48:22 +0000</pubDate>
		<dc:creator>chris</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.chickenbeak.com/php/tips-to-optimize-your-sql-and-php/2008/01/</guid>
		<description><![CDATA[These tips will work for most SQL based server, including but not limited to PostgreSQL and MySQL.
1. Don&#8217;t use the DELETE statement
Instead, use an UPDATE statement to mark a row to be deleted at a later time. Build your database so that the tables have a &#8216;deleted&#8217; column. Then, run the DELETE at a later [...]]]></description>
			<content:encoded><![CDATA[<p>These tips will work for most SQL based server, including but not limited to PostgreSQL and MySQL.</p>
<h3>1. Don&#8217;t use the DELETE statement</h3>
<p>Instead, use an UPDATE statement to mark a row to be deleted at a later time. Build your database so that the tables have a &#8216;deleted&#8217; column. Then, run the DELETE at a later time on all rows marked to be deleted. Just use a small boolean value in the &#8216;deleted&#8217; column, or you could even call it &#8217;status&#8217; and leave room for more status&#8217;s of a row by using an integer or small character value.</p>
<p>This can be big. Put simply, an UPDATE statement is cheeper than a DELETE statement because your DELETE statement will force the entire table to re-index the primary keys and the indexed.</p>
<h3>2. Reduce IO&#8217;s by reducing SELECT calls</h3>
<p>If you use UPDATES a certain way, and your database is also using UNIQUE fields correctly, you can reduce SELECT statements.</p>
<p>For example, if you have a table where you want to decide wether to INSERT or UPDATE, you might try running a SELECT to check for the data first. That will ALWAYS result in two calls.</p>
<pre class="code">
&lt;?php
// this code will always result in two calls !!
$count = functRunQuery(&quot;SELECT COUNT(*) FROM user_table WHERE username=&#x27;john&#x27;;&quot;);
if ($count &gt; 0) // then run UPDATE
else // run INSERT
?&gt;
</pre>
</p>
<p>Instead, run the UPDATE or INSERT first without using a SELECT call if you can&#8230;
<pre class="code">
&lt;?php
// this code could result in one call
$affectedRowCount = functRunQuery(&quot;UPDATE user_table SET username=&#x27;bob&#x27; WHERE username=&#x27;john&#x27;;&quot;);
if ($affectedRowCount &gt; 0) // we&#x27;re done, don&#x27;t need to do anything
else // didn&#x27;t find any rows so run the INSERT here
?&gt;
</pre>
<p>OR, if your table would probably see more successful INSERTs than UPDATEs do it the other way around (PHP5 method here)&#8230;</p>
<pre class="code">
&lt;?php
// this code could result in one call
try {
// try inserting the user without checking possible unique conflicts...
functRunQuery(&quot;INSERT INTO user_table (a_unique_username) VALUES (&#x27;bob&#x27;)&quot;);
} catch {
// catch the error here if &#x27;bob&#x27; is already in the database, and run an UPDATE instead
}
?&gt;
</pre>
<p>If scalability is a possible issue for your application, you should always be looking for ways to reduce database calls and cut down on re-indexing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chickenbeak.com/php/tips-to-optimize-your-sql-and-php/2008/01/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP abstract class (my first impressions)</title>
		<link>http://www.chickenbeak.com/php/php-abstract-class-my-first-impressions/2008/01/</link>
		<comments>http://www.chickenbeak.com/php/php-abstract-class-my-first-impressions/2008/01/#comments</comments>
		<pubDate>Wed, 30 Jan 2008 03:35:50 +0000</pubDate>
		<dc:creator>chris</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.chickenbeak.com/php/php-abstract-class-my-first-impressions/2008/01/</guid>
		<description><![CDATA[I&#8217;ve been using PHP for a while now, but I&#8217;ve never dug too deep into it&#8217;s programming strengths. I&#8217;ve recently been thrown into using abstract classes in PHP. This article is just a first impression of what they are, and how I see them being useful in a project.
First, what is an abstract class? In [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using PHP for a while now, but I&#8217;ve never dug too deep into it&#8217;s programming strengths. I&#8217;ve recently been thrown into using abstract classes in PHP. This article is just a first impression of what they are, and how I see them being useful in a project.</p>
<p>First, what is an abstract class? In not-so-technical terms, they seem to be just like a normal class. You define methods, variables, use a construct function, and can declare items as private or public.</p>
<pre class="code">
abstract class FormBuilder {

	public $method;
	public $action;
	public $name;

	function __construct($name,$action,$method) {
		$this-&gt;name = $name;
		$this-&gt;action = $action;
		$this-&gt;method = $method;
	}
}
</pre>
<p><span id="more-47"></span></p>
<p>However, you cannot create instances of these class&#8217;s directly. You must create another non-abstract class and extend the abstract class.</p>
<pre class="code">
class LoginForm extends FormBuilder {
	function printForm() {
		print &#x27;&lt;form name=&quot;&#x27;.$this-&gt;name.&#x27;&quot; method=&quot;&#x27;.$this-&gt;method.&#x27;&quot; action=&quot;&#x27;.$this-&gt;action.&#x27;&quot;&gt;&#x27;;
		print &#x27;... form body ...&#x27;;
		print &quot;&lt;/form&gt;&quot;;
		return true;
	}
}
$frontPageLoginForm = new LoginForm();
$frontPageLoginForm-&gt;printForm();
</pre>
<p>In this case you could move to creating a info request form, submit story form, or any kind you may need. Then create instances of those class&#8217;s as needed with methods and attributes custom taylored to the data that class handles.</p>
<p>So, why write the abstract class? In this case we could create a lot of form types, and build up the parent class to handle validation, creating form fields and storing variables that are relative to all forms (e.g. a unique id generator or timestamp.)</p>
<p>Then build up the classes that extend the abstract class to define less used and not-so-global features. In this case maybe username and password, along with a password encryption method may only make sense to a login form, not a request info form.</p>
<p>I think this starts to make a lot more sense as you start to use them more. At first, I thought &#8216;why not just build them into the main class?&#8217; But as our team started extending those class&#8217;s more and more, it became obvious why we used that structure when we were able to tweak one validate method in the parent  abstract class to fix a glitch in error handling was one file rather than multiple files.</p>
<p>Check out the <a title="Detailed features of abstract classes in PHP" href="http://us2.php.net/abstract" rel="nofollow">PHP Manual</a> for a much more technical view of PHP abstract classes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chickenbeak.com/php/php-abstract-class-my-first-impressions/2008/01/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP and ASP Includes</title>
		<link>http://www.chickenbeak.com/php/php-and-asp-includes/2006/11/</link>
		<comments>http://www.chickenbeak.com/php/php-and-asp-includes/2006/11/#comments</comments>
		<pubDate>Tue, 07 Nov 2006 03:16:00 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.chickenbeak.com/php/php-and-asp-includes/2006/11/</guid>
		<description><![CDATA[PHP and ASP are both very powerful server side scripting languages (SSL) that can add a lot of versatility and functionality to a website. You don&#8217;t have to understand much programming, however, to make use of one of their most handy components, include statements. Which language you use depends on what type of server your [...]]]></description>
			<content:encoded><![CDATA[<p>PHP and ASP are both very powerful server side scripting languages (SSL) that can add a lot of versatility and functionality to a website. You don&#8217;t have to understand much programming, however, to make use of one of their most handy components, include statements. Which language you use depends on what type of server your site is hosted on.</p>
<p><span id="more-44"></span></p>
<h4>PHP Include</h4>
<p class="code">&lt;?php include(&#8221;header.inc&#8221;); ?&gt;</p>
<h4>ASP include</h4>
<p class="code">&lt;!&ndash;&ndash;#include file=&#8221;info_header.inc&#8221;&ndash;&ndash;&gt;</p>
<p>Include statements allow you to place part of your code into a separate document that can then be included on multiple pages of your website. The advantage is that you can include all you your <head> details, logo, links, and so forth in one file. Then, if you need to update anything in that section, all of the pages including that file are automatically updated. You can also do the same for the footer.</p>
<p>Since these included files are simple text documents, they can have whatever extension you want, but commonly end in .inc. When read by a browser, the included file is read as part of the initial page. That is, the browser sees header.inc, index.php (or .asp), and footer.inc as one document. </p>
<p>The procedure is pretty straightforward, but here are some basic examples to get you started. The following examples are in PHP, but the ASP would work exactly the same with the appropriate include statement.</p>
<h4>header.inc:</h4>
<p class="code">&lt;html&gt;</p>
<p class="code">&lt;head&gt;<br />
	&lt;title&gt;Include Example&lt;/title&gt;<br />
&lt;/head&gt;</p>
<p class="code">&lt;body&gt;<br />
	&lt;div id=&#8221;nav&#8221;"&gt;<br />
		&lt;ul&gt;<br />
			&lt;li&gt;&lt;a href=&#8221;books.php&#8221;&gt;Favorite Books&lt;/a&gt;&lt;/li&gt;<br />
			&lt;li&gt;&lt;a href=&#8221;movies.php&#8221;&gt;Favorite Movies&lt;/a&gt;&lt;/li&gt;<br />
			&lt;li&gt;&lt;a href=&#8221;other.php&#8221;&gt;Other Favorites&lt;/a&gt;&lt;/li&gt;<br />
		&lt;/ul&gt;<br />
	&lt;/div&gt;</p>
<h4>index.php:</h4>
<p class="code">&lt;?php include(&#8221;header.inc&#8221;); ?&gt;</p>
<p class="code">&lt;div id=&#8221;content&#8221;&gt;<br />
		&lt;h1&gt;Title&lt;/h1&gt;<br />
		&lt;p&gt;Some content.&lt;/p&gt;<br />
	&lt;/div&gt;</p>
<p class="code">&lt;?php include(&#8221;footer.inc&#8221;); ?&gt;</p>
<h4>footer.inc:</h4>
<p class="code">&lt;div id=&#8221;footer&#8221;&gt;<br />
		Copyright info<br />
	&lt;/div&gt;</p>
<p class="code">&lt;/body&gt;</p>
<p class="code">&lt;/html&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chickenbeak.com/php/php-and-asp-includes/2006/11/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Accessibility Basics</title>
		<link>http://www.chickenbeak.com/xhtml/accessibility-basics/2006/10/</link>
		<comments>http://www.chickenbeak.com/xhtml/accessibility-basics/2006/10/#comments</comments>
		<pubDate>Mon, 02 Oct 2006 18:33:39 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
		
		<category><![CDATA[CSS]]></category>

		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://www.chickenbeak.com/xhtml/accessibility-basics/2006/10/</guid>
		<description><![CDATA[Most people generally agree that websites should be made usable to the widest audience possible. Web designers are constantly trying to accommodate users with various browsers, but we must also consider a host of other possibilities.
It is likely an impossible task to make a decent website that is usable by everyone, but it is a [...]]]></description>
			<content:encoded><![CDATA[<p>Most people generally agree that websites should be made usable to the widest audience possible. Web designers are constantly trying to accommodate users with various browsers, but we must also consider a host of other possibilities.</p>
<p>It is likely an impossible task to make a decent website that is usable by everyone, but it is a noble effort to try. The major users we need to consider (in addition to those that we consider as &#8220;standard&#8221; users) include those using old browsers, screen readers, and text browsers, those with poor vision, those who are colorblind, users without Javascript, those using cell phones or other mobile device.<span id="more-43"></span></p>
<h3>What needs to be done?</h3>
<h4>1. Design using web standards.</h4>
<ul>
<li>If you do this, then you are already well on your way because you site should already degrade nicely in old browsers and be formatted pretty well for text browsers.</li>
</ul>
<h4>2. Don&#8217;t open links in new windows if you can help it.</h4>
<ul>
<li>New windows are bad news for screen readers. </li>
<li>The target attribute has been deprecated by the W3C and may not be supported by browsers in the future.</li>
</ul>
<h4>3. Avoid using Javascript for links (new windows and otherwise).</h4>
<ul>
<li>Not all users have javascript-enabled browsers. Try to provide an alternate option for these users if the use of Javascript is unavoidable.</li>
</ul>
<h4>4. Use descriptive links</h4>
<ul>
<li>Use descriptive wording that will not mislead users. Avoid the phrase &#8220;click here.&#8221;</li>
<li>Make use of the title attribute  to support or extend link description.</li>
<li>If you are going to open a link in a new window, let the user know in some way.</li>
</ul>
<h4>5. Describe you images thoroughly for screen readers and text browsers</h4>
<ul>
<li>Make sure that you describe the image in the alt attribute.</li>
<li>Make sure any and all text conveyed in the image is described in the alt tag.</li>
<li>Use the longdesc attribute for complex images such as graphs and charts.</li>
<li>Added bonus: search engine crawlers look at alt tags, so good descriptions can help your optimization.</li>
</ul>
<h4>6. Consider the near-sighted</h4>
<ul>
<li>Make sure your text is big enough to read for all.</li>
<li>Use relative units for text so that the size can be increased.</li>
</ul>
<h4>7. Use contrasting colors for text and background</h4>
<ul>
<li>One of the keys to accessibility is legibility. See my last article for more on this subject.</li>
</ul>
<p>This tutorial really just covers the basics, the stuff that is easy and that everyone should do. This should get you started, but to truly understand the reaches of accessibility, check out these links:</p>
<h4>About Accessibility</h4>
<ul>
<li><a href="http://alistapart.com/articles/wiwa/" title="A List Apart Article by Trenton Moss">What Is Web Accessibility? by Trenton Moss</a></li>
<li><a href="http://www.w3.org/WAI/" title="Web Accessibility Initiative homepage">W3C WAI</a></li>
<li><a href="http://www.section508.gov/" title="Section 508 homepage">Section 508 homepage</a></li>
</ul>
<h4>Developing Accessible websites</h4>
<ul>
<li><a href="http://www.w3.org/TR/WAI-WEBCONTENT/full-checklist.html" title="Web Content Accessibility Guidelines full checklist">W3C&#8217;s WCAG Checklist</a></li>
<li><a href="http://www.diveintoaccessibility.org/" title="Everything you could possibly need to know about Accessibility">Dive Into Accessibility</a></li>
</ul>
<h4>Validation</h4>
<ul>
<li><a href="http://www.contentquality.com/" title="Test your website for WCAG and Section 508 validity">Cynthia Says Accessibility Validation</a> (basic)</li>
<li><a href="http://www.contentquality.com/" title="Thoroughly test your website's accessibility and much more">Bobby Quality, Accessibility, and Privacy Validation</a> (advanced)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.chickenbeak.com/xhtml/accessibility-basics/2006/10/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Javascript Cookies</title>
		<link>http://www.chickenbeak.com/javascript/javascript-cookies/2006/09/</link>
		<comments>http://www.chickenbeak.com/javascript/javascript-cookies/2006/09/#comments</comments>
		<pubDate>Fri, 08 Sep 2006 01:21:25 +0000</pubDate>
		<dc:creator>chris</dc:creator>
		
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.chickenbeak.com/javascript/javascript-cookies/2006/09/</guid>
		<description><![CDATA[Using a cookie with JavaScript is easy. With the cookie, you can save small bits of information that will allow you to create a customized experience for the user. Remember though, you should never save personal information in a cookie, like a social security number, a password, or a credit card number. Cookies are not [...]]]></description>
			<content:encoded><![CDATA[<p>Using a cookie with JavaScript is easy. With the cookie, you can save small bits of information that will allow you to create a customized experience for the user. Remember though, you should never save personal information in a cookie, like a social security number, a password, or a credit card number. Cookies are not a very secure way of transferring information. Also, don&#8217;t rely too heavily on JavaScript cookies since a viewer can turn them off. If you need to track viewer information or pass personal information, use server-side session variables.<span id="more-35"></span></p>
<h2>How To Set a Cookie</h2>
<p>JavaScript has a built in object called the &#8220;cookie&#8221; object. You can access it simply with the following call.</p>
<pre class="code">alert(document.cookie)</pre>
<p><a href="javascript:alert(document.cookie)">Click Here</a> to see what is in your browsers doument.cookie.</p>
<p>If you want to save something as a cookie, you have to URL encode it. This means you should use the same syntax that you see when people pass information in the address bar of a web address (the GET method, to be exact.) For example, www.chickenbeak.com?site=chickenbeak or www.chickenbeak.com?name=chris&#038;site=chicken.</p>
<pre>document.cookie = "site=chickenbeak"
document.cookie = "name=chris"</pre>
<p><a href="javascript:document.cookie='site=chickenbeak';document.cookie='name=chris'">Click Here</a> to set your browsers cookie like above.<br />
Then <a href="javascript:alert(document.cookie)">Click Here</a> to see what is in your browsers doument.cookie.</p>
<p>As you can see, the cookies are stored in the same format that you write them as, which is again URL encoded. You will want a JavaScript function that sifts through the document.cookie object and picks out the information you need. We will do this by splitting the long string saved in the document.cookie, and take the one bit of info we need.</p>
<p>What if we wanted to display a JavaScript message box to a visitor the first time they visit your homepage, but not every time they browse back to your homepage from a sub page of the site. We will set a cookie telling us that they have been there. Let&#8217;s start with a JavaScript function.</p>
<pre class="code">function getCookie(cookieName) {}</pre>
<p>The way we want this function to work is to pass the function a cookie name, and it returns the cookie value. We will mainly be using the JavaScript &#8220;split&#8221; function, storing the separate values into an array, and for each spot in that array running the split again. See, this is the pattern of a long cookie.</p>
<p>&#8220;varName=varValue;varName=varValue;varName=varValue&#8221;</p>
<p>So, let&#8217;s do the first split.</p>
<pre class="code">cookieInfo = document.cookie
cookieInfo = cookieInfo.split(";")</pre>
<p>This leaves us with an array &#8220;cookieInfo&#8221; which would contain values looking like &#8220;varName=varValue&#8221; for each cookie. We need to loop through this array one time and split it again.</p>
<pre class="code">cookieCount = cookieInfo.length
for(i = 0; i < cookieCount; i++) {
tempCookieInfo = cookieInfo[i].split("=")
//next we look at the [0] spot, which is the "varName"
//and look to see if it match's the "cookieName"
if(unescape(tempCookieInfo[0]) == cookieName
return tempCookieInfo[1]
}
}</pre>
<p>Note the comment above in the code. That is where we get the actual value based on the name of the cookie. Notice the use of the &#8220;unescape&#8221; JavaScript function? Remember that the cookies are URL encoded, which means you&#8217;ll get the codes like %20 instead of a space. That unescape will help in keeping the information formatted best for your JavaScript comparisons.</p>
<h2>Let&#8217;s put it all together</h2>
<p>We have a function now that will pull a value out of the document.cookie object. We would use it something like this&#8230;</p>
<pre class="code">if(getCookie("mySiteVisited") == "yes") {
//do nothing
} else {
document.cookie = "mySiteVisited=yes"
alert("Welcome!")
}</pre>
<p>And that would of course require our full function from above&#8230;</p>
<pre class="code">function getCookie(cookieName) {
if(document.cookie) {
cookieInfo = document.cookie
cookieInfo = cookieInfo.split(";")
cookieCount = cookieInfo.length
for(i = 0; i < cookieCount; i++) {
tempCookieInfo = cookieInfo[i].split("=")
if(unescape(tempCookieInfo[0]) == cookieName) {
return tempCookieInfo[1] } } }
else { return null }
}</pre>
<p>Oh, don&#8217;t forget that big &#8220;if&#8221; block around most of the functions code. If the document.cookie object is not used by their browser, the function returns null. That way you can see if the viewer use&#8217;s cookies or not. That can be helpful because you can write code to react the lack of cookie support.</p>
<p>There you have it, set cookies, get cookies and a bit of use from the &#8220;split&#8221; JavaScript function.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chickenbeak.com/javascript/javascript-cookies/2006/09/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

