<?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>hokuten.net</title>
	<atom:link href="http://hokuten.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://hokuten.net</link>
	<description>Personal Blog</description>
	<lastBuildDate>Mon, 08 Mar 2010 00:59:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<atom:link rel='hub' href='http://hokuten.net/?pushpress=hub'/>
		<item>
		<title>My Experience with MasterRental Insurance</title>
		<link>http://hokuten.net/2010/my-experience-with-masterrental-insurance/</link>
		<comments>http://hokuten.net/2010/my-experience-with-masterrental-insurance/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 00:57:47 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[life]]></category>
		<category><![CDATA[accident]]></category>
		<category><![CDATA[avis]]></category>
		<category><![CDATA[car]]></category>
		<category><![CDATA[insurance]]></category>
		<category><![CDATA[mastercard]]></category>
		<category><![CDATA[masterrental]]></category>
		<category><![CDATA[rental]]></category>

		<guid isPermaLink="false">http://hokuten.net/?p=170</guid>
		<description><![CDATA[MasterRental is a service provided by MasterCard when you rent a vehicle and pay for all rental related expenses with your MasterCard. It serves as &#0133;]]></description>
			<content:encoded><![CDATA[<p>MasterRental is a service provided by MasterCard when you rent a vehicle and pay for all rental related expenses with your MasterCard. It serves as a supplemental insurance if you are already insured by another plan (i.e., it may cover things your car insurance, the primary insurance, did now). If you aren&#8217;t, MasterRental will serve as your primary insurance (that&#8217;s what I did).</p>
<h3>Disclaimer</h3>
<p>There are specific conditions you must follow in order to qualify for MasterRental, so make sure you check the terms and conditions that came with your card. They should be similar (likely identical) to <a href="http://www.mastercard.com/us/personal/en/cardholderservices/guidetobenefits/pdf/11660_rent_save_2006.pdf">the MasterRental terms on the MasterCard site</a>, but check with your card provider to be sure. The benefits pamphlet is actually a really great read and may enlighten you to the other benefits of using a credit card (e.g., free extended warranties and refunds for things that the store may not accept).</p>
<h3>Deadlines</h3>
<ol>
<li>Report accident to rental company and police within 24 hours</li>
<li>File insurance claim within 30 days of the incident</li>
<li>Submit required documentation within 180 days of the incident</li>
</ol>
<p><span id="more-170"></span></p>
<h3>My Circumstances</h3>
<p>I rented a car with Avis using my HSBC MasterCard, and declined the Collision/Damage Waiver (<abbr title="Collision/Damage Waiver">CDW</abbr>). Well, after some driving on the open road, I ended up in a guardrail (I won&#8217;t go into the details of that). Thankfully, there were no other cars involved in the accident.</p>
<h4>Documents received:</h4>
<ol>
<li>All rental forms (receipt, rental agreement)</li>
<li>Rental car insurance information (Avis&#8217; insurance, in glove compartment)</li>
<li>Rental car registration (also in glove compartment)</li>
</ol>
<h3>Post-Accident Actions</h3>
<p>Some passer-bys called the police for me and came by to see if everything was alright (nice people). After the traffic officer came, we all had a chat about the situation and the people left. An accident report was written up and I was given a summary (in MA you have to request the report by mailing a request and processing fee to a police station). The officer called the local towing facility and soon I was sitting in the waiting room there, with my car in the lot. I had to fill out forms for the towing station. Rather than have the towing station tow the car back to Avis, I called Avis&#8217; roadside assistance line (which took FOREVER and a million call transfers). This call constituted a report of the accident on Avis&#8217; side. I payed the release fee for the towing facility. Unfortunately, the accident happened after 5pm on Friday, so the car couldn&#8217;t be towed until Monday. A friend picked me up from the towing facility.</p>
<h4>Documents received:</h4>
<ol>
<li>Accident report summary</li>
<li>Towing facility receipt</li>
</ol>
<h3>Rental and Report Charge</h3>
<p>On Monday, I went to the Avis facility to check on the status of the car. The car was towed on Monday and arrived at the Avis repair facility. Because it took all weekend, the rental contract wasn&#8217;t closed until Avis received the car again. I was charged for the full term of the rental (I only rented it for the weekend anyway). This showed up on my credit card activity online, and in my statement at the end of the month. I also sent in a check and request for the official police accident report to be sent to MasterCard.</p>
<h4>Documents received:</h4>
<ol>
<li>Credit card statement showing rental charges (end of month)</li>
<li>Police report (sent to MasterCard)</li>
</ol>
<h3>Filing the Insurance Claim</h3>
<p>I called 1-800-MC-ASSIST the Monday after the accident. Within a week I received a packet with details and the required forms from MasterCard (sent to my credit card billing address!) I filled out the forms and sent them out with a copy of my Driver&#8217;s License and copies of all of the documents I received above.<br />
An Avis representative called me within a week for a follow-up about the accident and for information about my insurance (MasterRental). They initiated the contact with MasterCard and supplied their documentation.</p>
<h3>Checking the Claim Status and Lessons Learned</h3>
<p>I was able to check the status of my claim and see what documents they had and still needed at any given time by going to their claim website: <a href="http://www.yourclaimstatus.com/">http://www.yourclaimstatus.com/</a>. The entire ordeal was resolved within four months (~120 days. The final deadline was 180 days). Overall this was an ordeal I hope to never repeat again. If it did happen, I would call MasterCard&#8217;s roadside assistance for the towing service, since they cover towing. It won&#8217;t happen because I was able to get a corporate <a href="http://www.zipcar.com/">ZipCar</a> membership through my employer, and accident-related issues are <a href="http://www.zipcar.com/cities?return_url=/how/faqs/one-faq%3ffaq_number%3d28">handled by ZipCar</a> entirely (the car and authorized driver are covered through Liberty Mutual).</p>
<h3>References</h3>
<ul>
<li><a href="http://www.mastercard.com/us/personal/en/cardholderservices/guidetobenefits/pdf/11660_rent_save_2006.pdf">MasterCard Guide to Benefits</a></li>
<li><a href="http://www.zipcar.com/cities?return_url=/how/faqs/one-faq%3ffaq_number%3d28">ZipCar Insurance Information</a></li>
</ul>



Share this article:


	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhokuten.net%2F2010%2Fmy-experience-with-masterrental-insurance%2F&amp;title=My%20Experience%20with%20MasterRental%20Insurance&amp;notes=MasterRental%20is%20a%20service%20provided%20by%20MasterCard%20when%20you%20rent%20a%20vehicle%20and%20pay%20for%20all%20rental%20related%20expenses%20with%20your%20MasterCard.%20It%20serves%20as%20a%20supplemental%20insurance%20if%20you%20are%20already%20insured%20by%20another%20plan%20%28i.e.%2C%20it%20may%20cover%20things%20your%20ca" title="del.icio.us"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhokuten.net%2F2010%2Fmy-experience-with-masterrental-insurance%2F&amp;title=My%20Experience%20with%20MasterRental%20Insurance" title="StumbleUpon"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhokuten.net%2F2010%2Fmy-experience-with-masterrental-insurance%2F&amp;title=My%20Experience%20with%20MasterRental%20Insurance&amp;bodytext=MasterRental%20is%20a%20service%20provided%20by%20MasterCard%20when%20you%20rent%20a%20vehicle%20and%20pay%20for%20all%20rental%20related%20expenses%20with%20your%20MasterCard.%20It%20serves%20as%20a%20supplemental%20insurance%20if%20you%20are%20already%20insured%20by%20another%20plan%20%28i.e.%2C%20it%20may%20cover%20things%20your%20ca" title="Digg"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fhokuten.net%2F2010%2Fmy-experience-with-masterrental-insurance%2F&amp;title=My%20Experience%20with%20MasterRental%20Insurance" title="Reddit"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fhokuten.net%2F2010%2Fmy-experience-with-masterrental-insurance%2F&amp;title=My%20Experience%20with%20MasterRental%20Insurance" title="DZone"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/dzone.png" title="DZone" alt="DZone" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fhokuten.net%2F2010%2Fmy-experience-with-masterrental-insurance%2F&amp;title=My%20Experience%20with%20MasterRental%20Insurance" title="Mixx"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=My%20Experience%20with%20MasterRental%20Insurance%20-%20http%3A%2F%2Fhokuten.net%2F2010%2Fmy-experience-with-masterrental-insurance%2F" title="Twitter"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=My%20Experience%20with%20MasterRental%20Insurance&amp;body=http%3A%2F%2Fhokuten.net%2F2010%2Fmy-experience-with-masterrental-insurance%2F" title="email"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://hokuten.net/2010/my-experience-with-masterrental-insurance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Regarding IE6</title>
		<link>http://hokuten.net/2010/regarding-ie6/</link>
		<comments>http://hokuten.net/2010/regarding-ie6/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 17:37:08 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[compatibility]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[ie6]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[statistics]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://hokuten.net/?p=203</guid>
		<description><![CDATA[Dear Client,
Internet Explorer 6 is dead. We recommend not focusing resources and time on IE6 compatibility unless your target audience is based in South Korea &#0133;]]></description>
			<content:encoded><![CDATA[<p>Dear Client,</p>
<p><a href="http://news.google.com/news?sourceid=chrome&#038;q=ie6+funeral&#038;um=1&#038;ie=UTF-8&#038;hl=en&#038;ei=KJKSS4qPMcmUtgfO9cDUCg&#038;sa=X&#038;oi=news_group&#038;ct=title&#038;resnum=1&#038;ved=0CA4QsQQwAA">Internet Explorer 6 is dead</a>. We recommend not focusing resources and time on IE6 compatibility unless your target audience is based in South Korea (under 50% market share) or China (60%). This still amounts to less than 25% of internet users in Asia. In North America and Europe, IE6 currently has under 7% market share. In the United States, the percentage is under 6%. This is sure to drop even further when YouTube drops support for it on March 13, 2010. Also, <a href="http://googleenterprise.blogspot.com/2010/01/modern-browsers-for-modern-applications.html">Google no longer supports IE6 in its applications.</a> On a final note, your audience is more likely to have a better browser at home than at work because they are not restricted by corporate security policies and may update and install any software they wish.</p>
<p>For statistics on browser usage by country please <a href="http://gs.statcounter.com/">visit this StatCounter page</a>.</p>
<p>Thank you,<br />
<kbd>YOURNAMEHERE</kbd></p>



Share this article:


	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhokuten.net%2F2010%2Fregarding-ie6%2F&amp;title=Regarding%20IE6&amp;notes=Dear%20Client%2C%0D%0A%0D%0AInternet%20Explorer%206%20is%20dead.%20We%20recommend%20not%20focusing%20resources%20and%20time%20on%20IE6%20compatibility%20unless%20your%20target%20audience%20is%20based%20in%20South%20Korea%20%28under%2050%25%20market%20share%29%20or%20China%20%2860%25%29.%20This%20still%20amounts%20to%20less%20than%2025%25%20of%20interne" title="del.icio.us"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhokuten.net%2F2010%2Fregarding-ie6%2F&amp;title=Regarding%20IE6" title="StumbleUpon"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhokuten.net%2F2010%2Fregarding-ie6%2F&amp;title=Regarding%20IE6&amp;bodytext=Dear%20Client%2C%0D%0A%0D%0AInternet%20Explorer%206%20is%20dead.%20We%20recommend%20not%20focusing%20resources%20and%20time%20on%20IE6%20compatibility%20unless%20your%20target%20audience%20is%20based%20in%20South%20Korea%20%28under%2050%25%20market%20share%29%20or%20China%20%2860%25%29.%20This%20still%20amounts%20to%20less%20than%2025%25%20of%20interne" title="Digg"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fhokuten.net%2F2010%2Fregarding-ie6%2F&amp;title=Regarding%20IE6" title="Reddit"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fhokuten.net%2F2010%2Fregarding-ie6%2F&amp;title=Regarding%20IE6" title="DZone"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/dzone.png" title="DZone" alt="DZone" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fhokuten.net%2F2010%2Fregarding-ie6%2F&amp;title=Regarding%20IE6" title="Mixx"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Regarding%20IE6%20-%20http%3A%2F%2Fhokuten.net%2F2010%2Fregarding-ie6%2F" title="Twitter"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Regarding%20IE6&amp;body=http%3A%2F%2Fhokuten.net%2F2010%2Fregarding-ie6%2F" title="email"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://hokuten.net/2010/regarding-ie6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tips for Faster PSD to HTML Conversions</title>
		<link>http://hokuten.net/2010/tips-faster-psd-html-conversions/</link>
		<comments>http://hokuten.net/2010/tips-faster-psd-html-conversions/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 02:33:38 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[firebug]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[photoshop]]></category>
		<category><![CDATA[psd]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://hokuten.net/?p=207</guid>
		<description><![CDATA[Ever wonder how those PSD to HTML services do the job with such a quick turnaround, sometimes guaranteeing valid code in 24 hours on even &#0133;]]></description>
			<content:encoded><![CDATA[<p>Ever wonder how those PSD to HTML services do the job with such a quick turnaround, sometimes guaranteeing valid code in 24 hours on even the most complex PSDs? The task is roughly 40% breaking up the PSD logically, 20% coding, and 40% moving elements around until everything fits together. Here are some tips I&#8217;ve learned from years of experience and trying to find new techniques in those tutorials the web has too many of.</p>
<h3>Contents</h3>
<ol>
<li><a href="#tffpthc_1">Photoshop Techniques</a></p>
<ol>
<li><a href="#tffpthc_2">Save for Web</a></li>
<li><a href="#tffpthc_3">Convert to Smart Object</a></li>
<li><a href="#tffpthc_4">Selecting Layers</a></li>
<li><a href="#tffpthc_5">Copy merged</a></li>
<li><a href="#tffpthc_6">Slicing’s other use</a></li>
<li><a href="#tffpthc_7">Actions</a></li>
<li><a href="#tffpthc_8">Text</a></li>
<li><a href="#tffpthc_9">Flattened Versions</a></li>
</ol>
</li>
<li><a href="#tffpthc_10">Creating the HTML and CSS</a>
<ol>
<li><a href="#tffpthc_11">Frameworks and Resets</a></li>
<li><a href="#tffpthc_12">Quickly get Image Dimensions</a></li>
</ol>
</li>
<li><a href="#tffpthc_13">Design in Firefox</a>
<ol>
<li><a href="#tffpthc_14">HTML Validator</a></li>
<li><a href="#tffpthc_15">Web Developer</a></li>
<li><a href="#tffpthc_16">Computed Sizes with Firebug</a></li>
<li><a href="#tffpthc_17">In Place CSS Editing with Firebug and the Arrow Keys</a></li>
<li><a href="#tffpthc_18">Pixel Perfect and Inverted Overlays</a></li>
</ol>
</li>
<li><a href="#tffpthc_19">Closing</a></li>
<li><a href="#tffpthc_20">References</a></li>
</ol>
<p><span id="more-207"></span></p>
<h3 id="tffpthc_1">Photoshop Techniques</h3>
<p>I usually start a conversion by preparing the assets. Working with the design first (as opposed to starting with the framework) also gives me a better sense of where everything goes.</p>
<h4 id="tffpthc_2">Save for Web</h4>
<p><a href="http://hokuten.net/wordpress/wp-content/uploads/saveforweb.jpg" rel="lightbox[207]"><img src="http://hokuten.net/wordpress/wp-content/uploads/saveforweb-350x300.jpg" alt="Save For Web Dialog"  width="350" height="300" class="aligncenter size-thumbnail wp-image-217" /></a> Alt+Ctrl+Shift+S, or on Macs, Cmd+Opt+Shift+S. This is the key combination you&#8217;ll use to save every piece of the PSD you&#8217;re going to use for your design. From the Save for Web window, you can choose the best filetype for the image you&#8217;re saving based on quality and size.</p>
<h4 id="tffpthc_3">Convert to Smart Object</h4>
<p><img src="http://hokuten.net/wordpress/wp-content/uploads/converttosmartobject.png" alt="Convert to Smart Object" title="Convert to Smart Object" width="199" height="66" class="alignright size-full wp-image-218" /> For groups of layers (including text) that doesn&#8217;t use layer blending options and aren&#8217;t affected by adjustment layers, select the layers and/or groups involved and convert them to a Smart Object. A Smart Object is a temporary vector object that you can modify as a separate file (a PSB file). The modifications will appear in the original PSD. Double click on the smart object in the layers menu to edit it as if it were a new image. From the Smart Object edit window, you can Save for Web.</p>
<h4 id="tffpthc_4">Selecting Layers</h4>
<p>Ctrl+Click on the layer thumbnail to select the contents of the layer. This beats using the wand tool or something to select the transparent pixels around it. You can also do Ctrl-shift and Ctrl-Alt clicks on additional layer thumbnails to add and subtract them from the selection.</p>
<h4 id="tffpthc_5">Copy merged</h4>
<p>A godsend of a shortcut. Ctrl+(Macs: Command)+Shift+C. I use this for layers that have blending options set or are affected by adjustment layers. After you&#8217;ve copied it, do a Ctrl+(Macs: Command)+N and paste to the new file. Then Save for Web.</p>
<h4 id="tffpthc_6">Slicing&#8217;s other use</h4>
<p>I feel that slicing is an outdated method to chop up a PSD because complex designs will use overlays of all kinds. Slicing has other uses, though. Sometimes I&#8217;ll slice the document and have Photoshop generate HTML for me. I then open the generated document in Firefox and use Firebug to get the computed sizes for block elements later on.</p>
<h4 id="tffpthc_7">Actions</h4>
<p>Actions are so underused! These are macros that you can create simply by recording what you do. You can create an action that does any of the things I&#8217;ve listed above for you. For instance, next time you make a selection, start recording an action as you Copy Merged -> Create a New File -> Paste -> Save for Web. Stop recording and save your action (you might have to delete the steps after the Save for Web dialog appears). Next time you make a selection that needs to be Copy Merged and saved into a new file, just run the action and save as a new name! Here is a more in-depth <a href="http://morris-photographics.com/photoshop/tutorials/actions.html">tutorial on creating Photoshop Actions</a>.</p>
<h4 id="tffpthc_8">Text</h4>
<p>Take note of the font-face and font-sizes in pixels used before you dive into the HTML. It&#8217;s okay to use pixel font sizes these days, but if you&#8217;re old-school like I am at least you can find the relative size now that you have them all.</p>
<h4 id="tffpthc_9">Flattened Versions</h4>
<p><a href="http://hokuten.net/wordpress/wp-content/uploads/invert.jpg" rel="lightbox[207]"><img src="http://hokuten.net/wordpress/wp-content/uploads/invert.jpg" alt="Normal and inverted flattened designs"  width="500" height="315" class="aligncenter size-full wp-image-219" /></a> Save a flattened version of the site. Print it out if you want. This will be useful for reference by eye, and for working with the Pixel Perfect Firebug extension. Finally, invert the colors of a flattened version and save it as a new file. You&#8217;ll also want this for Pixel Perfect.</p>
<h3 id="tffpthc_10">Creating the HTML and CSS</h3>
<p>This part should be simple&mdash;it just involves creating the <code>&lt;div></code>, <code>&lt;span></code>, headers, and paragraphs you need. If you took note of the font information like I told you to above, now is a good time to define it in your CSS. Besides putting a body background color/image in, the font stack really helps everything look like it&#8217;s nearing completion.</p>
<h4 id="tffpthc_11">Frameworks and Resets</h4>
<p>If you haven&#8217;t already formed your own, try adopting the popular ones (not if you&#8217;re on a deadline, though). Fluency with pre- or self-built, HTML and CSS frameworks means you already have the groundwork complete and only need to add more block elements as needed. You shouldn&#8217;t waste any time finding a reset or creating the same <code>&lt;div id="wrapper"></code> you do for every layout.</p>
<h4 id="tffpthc_12">Quickly get Image Dimensions</h4>
<p><a href="http://hokuten.net/wordpress/wp-content/uploads/imagedimensions.jpg" rel="lightbox[207]"><img src="http://hokuten.net/wordpress/wp-content/uploads/imagedimensions-350x300.jpg" alt="Image Dimensions Column"  width="350" height="300" class="aligncenter size-thumbnail wp-image-216" /></a><br />
For Windows users, in Explorer you can add a Dimensions column to the detail view. Right click on the column names and Dimensions should be one of the options available.</p>
<h3 id="tffpthc_13">Design in Firefox</h3>
<p><a href="http://hokuten.net/wordpress/wp-content/uploads/firefox.png" rel="lightbox[207]"><img src="http://hokuten.net/wordpress/wp-content/uploads/firefox.png" alt="Firefox"  width="128" height="128" class="alignleft size-full wp-image-223" /></a>The number of development tools in Firefox makes it the single, indisputably best browser for web development. This is not to say it is the best at rendering, or fastest browser (both of which are Opera 10.5 beta at the time of this writing), but it is close enough and will make your job easier.</p>
<h4 id="tffpthc_14">HTML Validator</h4>
<p>If you&#8217;re on a PC this instant validation cue on the bottom right of the browser is incredibly helpful. Just make sure it&#8217;s always green. Double click it to see the errors if it isn&#8217;t. If you&#8217;re on a Mac, you can use the shortcut provided in the Web Developer extension for quick validation.</p>
<h4 id="tffpthc_15">Web Developer</h4>
<p><a href="http://hokuten.net/wordpress/wp-content/uploads/webdeveloper.png" rel="lightbox[207]"><img src="http://hokuten.net/wordpress/wp-content/uploads/webdeveloper.png" alt="Element information from Web Developer"  width="402" height="297" class="aligncenter size-full wp-image-229" /></a><br />
The designer and framework you&#8217;re using and should have covered most things this extension would be used to debug, but there are a few things left that it can help with.<br />
One thing I do is test visited link status by going to Miscellaneous -> Visited Links to test the style of visited links.<br />
I also do a Forms -> Populate Form Fields to test form field fonts.<br />
Again, you can access a quick shortcut to HTML validation with this extension. Use it for both regular and generated source validation. Validate your CSS as well!<br />
Finally, Ctrl+(Macs: Command)+Shift+F will is a quick and lightweight alternative to Firebug for finding out computed styles. Just hover over your element. Press the keys again to finish.</p>
<h4 id="tffpthc_16">Computed Sizes with Firebug</h4>
<p>As I mentioned before in the Photoshop Slicing section, sometimes I&#8217;ll slice the document and have Photoshop generate HTML for me. I then open the generated document in Firefox and use <a href="http://getfirebug.com/">Firebug</a> to get the computed sizes for block level elements.</p>
<h4 id="tffpthc_17">In Place CSS Editing with Firebug and the Arrow Keys</h4>
<p><a href="http://hokuten.net/wordpress/wp-content/uploads/firebug_css.png" rel="lightbox[207]"><img src="http://hokuten.net/wordpress/wp-content/uploads/firebug_css.png" alt="Editing CSS in place with Firebug"  width="424" height="317" class="aligncenter size-full wp-image-231" /></a><br />
One of the best things about Firebug is the ability to edit CSS in place. From either the HTML or CSS tab, you can add and edit rules and properties by clicking on them. If you put the cursor on a numeric property you can use the up and down arrow keys to increment and decrement the value (tip: use Shift+Arrow to increment by 10). In this way, you can move and resize block elements and change margins and paddings. Don&#8217;t forget to copy the final value into your CSS document.</p>
<h4 id="tffpthc_18">Pixel Perfect and Inverted Overlays</h4>
<p>Firebug is much more useful with <a href="http://www.pixelperfectplugin.com/">Pixel Perfect</a>. This extension lets you place elements on the browser screen and adjust their position and opacity. Drag the overlaid image to reposition it. Use the panel to hide or adjust opacity. I usually add a flattened version of the design and an inverted color flattened version. With the inverted version, set the opacity to 0.5. If your block level elements are in the correct place, the screen should turn gray. Anything that doesn&#8217;t match up to the PSD exactly will be in color (this works similar to the Photoshop &#8220;Difference&#8221; blending mode). You can use this with the Firebug technique described earlier to quickly get everything in the exact pixel location.<br />
Here&#8217;s an example of the inverted overlay on top of this post, one pixel off:<br />
<a href="http://hokuten.net/wordpress/wp-content/uploads/overlay_off.png" rel="lightbox[207]"><img src="http://hokuten.net/wordpress/wp-content/uploads/overlay_off-465x400.png" alt="Pixel Perfect inverted overlay, 1px off"  width="465" height="400" class="aligncenter size-medium wp-image-233" /></a><br />
And here is the same overlay when the elements are in the exact positions (I shifted the overlay, but for designing you should shift the elements):<br />
<a href="http://hokuten.net/wordpress/wp-content/uploads/overlay_on.png" rel="lightbox[207]"><img src="http://hokuten.net/wordpress/wp-content/uploads/overlay_on-465x400.png" alt="Pixel Perfect inverted overlay, correct position"  width="465" height="400" class="aligncenter size-medium wp-image-234" /></a><br />
Using Firefox and Firebug to do your design, you&#8217;re just moving blocks around with the arrow keys. It&#8217;s WYSIWYG editing without the pitfalls!</p>
<h3 id="tffpthc_19">Closing</h3>
<p>I&#8217;m not a fan of those rapid PSD to HTML shops only because I am wary of the quality of work they produce. I&#8217;m sure there are a few good ones, but I still prefer to do it myself. If you&#8217;ve got any tips or tricks of your own, leave me a comment!</p>
<h3 id="tffpthc_20">References</h3>
<ol>
<li><a href="http://getfirebug.com/">Firebug</a></li>
<li><a href="http://www.pixelperfectplugin.com/">Pixel Perfect Firefox Extension</a></li>
<li><a href="http://morris-photographics.com/photoshop/tutorials/actions.html">Using Actions to Automate Tasks in Photoshop</a></li>
</ol>



Share this article:


	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhokuten.net%2F2010%2Ftips-faster-psd-html-conversions%2F&amp;title=Tips%20for%20Faster%20PSD%20to%20HTML%20Conversions&amp;notes=Ever%20wonder%20how%20those%20PSD%20to%20HTML%20services%20do%20the%20job%20with%20such%20a%20quick%20turnaround%2C%20sometimes%20guaranteeing%20valid%20code%20in%2024%20hours%20on%20even%20the%20most%20complex%20PSDs%3F%20The%20task%20is%20roughly%2040%25%20breaking%20up%20the%20PSD%20logically%2C%2020%25%20coding%2C%20and%2040%25%20moving%20element" title="del.icio.us"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhokuten.net%2F2010%2Ftips-faster-psd-html-conversions%2F&amp;title=Tips%20for%20Faster%20PSD%20to%20HTML%20Conversions" title="StumbleUpon"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhokuten.net%2F2010%2Ftips-faster-psd-html-conversions%2F&amp;title=Tips%20for%20Faster%20PSD%20to%20HTML%20Conversions&amp;bodytext=Ever%20wonder%20how%20those%20PSD%20to%20HTML%20services%20do%20the%20job%20with%20such%20a%20quick%20turnaround%2C%20sometimes%20guaranteeing%20valid%20code%20in%2024%20hours%20on%20even%20the%20most%20complex%20PSDs%3F%20The%20task%20is%20roughly%2040%25%20breaking%20up%20the%20PSD%20logically%2C%2020%25%20coding%2C%20and%2040%25%20moving%20element" title="Digg"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fhokuten.net%2F2010%2Ftips-faster-psd-html-conversions%2F&amp;title=Tips%20for%20Faster%20PSD%20to%20HTML%20Conversions" title="Reddit"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fhokuten.net%2F2010%2Ftips-faster-psd-html-conversions%2F&amp;title=Tips%20for%20Faster%20PSD%20to%20HTML%20Conversions" title="DZone"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/dzone.png" title="DZone" alt="DZone" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fhokuten.net%2F2010%2Ftips-faster-psd-html-conversions%2F&amp;title=Tips%20for%20Faster%20PSD%20to%20HTML%20Conversions" title="Mixx"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Tips%20for%20Faster%20PSD%20to%20HTML%20Conversions%20-%20http%3A%2F%2Fhokuten.net%2F2010%2Ftips-faster-psd-html-conversions%2F" title="Twitter"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Tips%20for%20Faster%20PSD%20to%20HTML%20Conversions&amp;body=http%3A%2F%2Fhokuten.net%2F2010%2Ftips-faster-psd-html-conversions%2F" title="email"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://hokuten.net/2010/tips-faster-psd-html-conversions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A WordPress User&#8217;s Guide to Drupal</title>
		<link>http://hokuten.net/2010/a-wordpress-users-guide-to-drupal/</link>
		<comments>http://hokuten.net/2010/a-wordpress-users-guide-to-drupal/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 01:52:35 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[comparison]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://hokuten.net/?p=115</guid>
		<description><![CDATA[Anyone who has worked with both knows that anything you can do in WordPress, you can do in Drupal, and vice versa. It just takes &#0133;]]></description>
			<content:encoded><![CDATA[<p>Anyone who has worked with both knows that anything you can do in WordPress, you can <a href="http://drupal.org/node/41373">do in Drupal</a>, and <a href="http://pods.uproot.us/">vice</a> <a href="http://www.corephp.com/wordpress/wordpress-integration-for-joomla-1.5.html">versa</a>. It just takes some elbow grease.<br />
I am a huge advocate of WordPress as both a personal blogging engine and a <a href="http://mu.wordpress.org/">multiuser CMS</a>. It is easy to setup and theme, has a largely backed community, and has an extensive selection of plugins (with great focus on SEO and social blogging) making it an excellent choice for sites of any size.<br />
Drupal is <a href="http://www.packtpub.com/award">still regarded as the Best Open Source PHP CMS</a>, though, and is commonly used by large corporations, government, and universities. Drupal has a large following and plugins for nearly any operation as well. It is a great thing to learn because of its broad market, but WordPress developers might find some difficulty getting acclimated&mdash;Drupal has a much higher learning curve.</p>
<p>This information in this article pertains to WordPress 2.8+ and Drupal 6.15. Here are some tips/parallels that may help you as a WordPress user jumping into Drupal.</p>
<h3>Installation</h3>
<p>The installation procedures of Drupal and Wordpress are similar, but there are a few operations you have to perform manually in Drupal:</p>
<p>WordPress has greatly simplified its installation procedure by automating the creation of the <var class="php file">wp-config.php</var> file based the the <var class="file_php file">wp-config-sample.php</var> file. Drupal has yet to do this up&mdash;you have to manually create the <var class="file_php file">settings.php</var> file in the sites/default folder by creating a copy of <var class="file_php file">default.settings.php</var> and renaming it.<br />
<span id="more-115"></span></p>
<p>A vanilla WordPress install in simple given that the directory structure is created for you. In Drupal, after you first upload the files, you have to create additional directories. From your root, go to the <var class="folder">sites/default</var> folder and create a files folder. Make the folder writable if it isn&#8217;t already (see the Drupal status report).</p>
<p>I also recommend going to the <var class="folder">sites/modules</var> folder and creating folders called <var class="folder">contrib</var> and <var class="folder">custom</var>. Put modules you download from Drupal.org into <var class="folder">contrib</var> and modules you create into <var class="folder">custom</var>.</p>
<h3>Theming</h3>
<p>Here is a table of Drupal theme file and folder equivalents:</p>
<table cellpadding="0" cellspacing="0" class="comparison">
<thead>
<tr>
<th>Drupal</th>
<th>WordPress</th>
</tr>
</thead>
<tbody>
<tr>
<td><var class="folder">sites/all/modules (/contrib and /custom)</var></td>
<td><var class="folder">wp-content/plugins</var></td>
</tr>
<tr>
<td><var class="folder">sites/all/themes</var></td>
<td><var class="folder">wp-content/themes</var></td>
</tr>
<tr>
<td><var class="file_info file">themename.info</var></td>
<td><var class="file_css file">style.css + wp_head()</var></td>
</tr>
<tr>
<td><dfn>Region<dfn></td>
<td><dfn>Dynamic Sidebar<dfn></td>
</tr>
<tr>
<td><dfn>Block<dfn></td>
<td><dfn>Sidebar Widget<dfn></td>
</tr>
<tr>
<td><dfn>Page<dfn></td>
<td><dfn>Template<dfn></td>
</tr>
<tr>
<td><dfn>Node / Content Type<dfn></td>
<td><dfn>Post + Custom Values<dfn></td>
</tr>
<tr>
<td><dfn>page*.tpl.php<dfn></td>
<td><dfn>Template file: index/single/archive.php, etc.<dfn></td>
</tr>
<tr>
<td><dfn>node*.tpl.php<dfn></td>
<td><dfn>Code <strong>within</strong> the loop<dfn></td>
</tr>
<tr>
<td><var class="file_php file">template.php</var></td>
<td><var class="file_php file">functions.php</var></td>
</tr>
</tbody>
</table>
<p>The similarities in theming begin to diverge at <var class="file_php file">page.php</var>/<var class="file_php file">index.php</var>. From here, Drupal uses different files for &#8220;nodes,&#8221; &#8220;blocks,&#8221; and optionally &#8220;panels,&#8221; &#8220;contexts,&#8221; &#8220;views,&#8221; and so on depending on what modules you are using.</p>
<p>Let me know if you have any more useful parallels to draw. I hope this helps you make sense of things&mdash;I know it would have helped me when I started.</p>



Share this article:


	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhokuten.net%2F2010%2Fa-wordpress-users-guide-to-drupal%2F&amp;title=A%20WordPress%20User%27s%20Guide%20to%20Drupal&amp;notes=Anyone%20who%20has%20worked%20with%20both%20knows%20that%20anything%20you%20can%20do%20in%20WordPress%2C%20you%20can%20do%20in%20Drupal%2C%20and%20vice%20versa.%20It%20just%20takes%20some%20elbow%20grease.%0D%0AI%20am%20a%20huge%20advocate%20of%20WordPress%20as%20both%20a%20personal%20blogging%20engine%20and%20a%20multiuser%20CMS.%20It%20is%20easy%20" title="del.icio.us"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhokuten.net%2F2010%2Fa-wordpress-users-guide-to-drupal%2F&amp;title=A%20WordPress%20User%27s%20Guide%20to%20Drupal" title="StumbleUpon"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhokuten.net%2F2010%2Fa-wordpress-users-guide-to-drupal%2F&amp;title=A%20WordPress%20User%27s%20Guide%20to%20Drupal&amp;bodytext=Anyone%20who%20has%20worked%20with%20both%20knows%20that%20anything%20you%20can%20do%20in%20WordPress%2C%20you%20can%20do%20in%20Drupal%2C%20and%20vice%20versa.%20It%20just%20takes%20some%20elbow%20grease.%0D%0AI%20am%20a%20huge%20advocate%20of%20WordPress%20as%20both%20a%20personal%20blogging%20engine%20and%20a%20multiuser%20CMS.%20It%20is%20easy%20" title="Digg"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fhokuten.net%2F2010%2Fa-wordpress-users-guide-to-drupal%2F&amp;title=A%20WordPress%20User%27s%20Guide%20to%20Drupal" title="Reddit"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fhokuten.net%2F2010%2Fa-wordpress-users-guide-to-drupal%2F&amp;title=A%20WordPress%20User%27s%20Guide%20to%20Drupal" title="DZone"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/dzone.png" title="DZone" alt="DZone" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fhokuten.net%2F2010%2Fa-wordpress-users-guide-to-drupal%2F&amp;title=A%20WordPress%20User%27s%20Guide%20to%20Drupal" title="Mixx"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=A%20WordPress%20User%27s%20Guide%20to%20Drupal%20-%20http%3A%2F%2Fhokuten.net%2F2010%2Fa-wordpress-users-guide-to-drupal%2F" title="Twitter"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=A%20WordPress%20User%27s%20Guide%20to%20Drupal&amp;body=http%3A%2F%2Fhokuten.net%2F2010%2Fa-wordpress-users-guide-to-drupal%2F" title="email"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://hokuten.net/2010/a-wordpress-users-guide-to-drupal/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google Analytics, iFrames, and Multiple Domain Setups</title>
		<link>http://hokuten.net/2010/google-analytics-iframes-and-multiple-domain-setups/</link>
		<comments>http://hokuten.net/2010/google-analytics-iframes-and-multiple-domain-setups/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 19:38:56 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[web]]></category>
		<category><![CDATA[analytics]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[domains]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[privacy]]></category>
		<category><![CDATA[tracking]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://hokuten.net/?p=179</guid>
		<description><![CDATA[Google&#8217;s FAQ and help pags do a horrible job explaining how to use the tag other than pasting it into your code. Tracking for cross-domain &#0133;]]></description>
			<content:encoded><![CDATA[<p>Google&#8217;s FAQ and help pags do a horrible job explaining how to use the tag other than pasting it into your code. Tracking for cross-domain and frame/iframe scenarios are not explained. There is documentation on the Google Analytics javascript, though, and provisions for doing the complex tracking. Here I will try to explain a common scenario I&#8217;ve had to deal with recently:</p>
<h3>The Scenario</h3>
<ul>
<li>You have a parent page with its own tracking code: <samp>UA-xxxxxx-x</samp>.</li>
<li>The parent page has an iframe in it with a child page.</li>
<li>The child page has its own tracking code as well: <samp>UA-yyyyyy-y</samp>.</li>
<li>You want to independently track both pages.</li>
</ul>
<h3>Parent Page</h3>
<p>Because we are dealing with cross-domain cookies, your page needs to serve a P3P header or link to a P3P policy to create the correct cookies in Internet Explorer 7 and 8 (and possibly Safari).<br />
<span id="more-179"></span></p>
<h4>P3P Policies</h4>
<p>P3P is one of the <a href="http://www.w3.org/">W3C</a>&#8217;s <del datetime="2010-02-24T22:49:34+00:00">failed</del> web standards. It was implemented in Internet Explorer 7 and 8, (and possibly Safari,) and prevents browsers from creating cross-domain (third-party) cookies in the default (Medium) privacy setting (See Internet Explorer -> Internet Options -> Privacy Tab -> Settings).</p>
<div class="image"><a href="http://hokuten.net/wordpress/wp-content/uploads/ie_p3p.png" rel="lightbox[179]"><img src="http://hokuten.net/wordpress/wp-content/uploads/ie_p3p.png" alt="Internet Explorer 8&#039;s Privacy Settings"  width="414" height="308" class="aligncenter size-full wp-image-192" /></a></div>
<p>To create a P3P policy in ASP.net, PHP, JSP, ColdFusion, or through Apache&#8217;s .htaccess, you only need to add some code to the top of your page. See Viral Patel&#8217;s page (and the comments) for the correct header for your pagetype. For IIS settings, see <a href="http://support.microsoft.com/kb/324013">Microsoft&#8217;s support page</a> or <a href="http://www.hanselman.com/blog/TheImportanceOfP3PAndACompactPrivacyPolicy.aspx">Scott Hanselman&#8217;s blog post</a>. If you aren&#8217;t using IIS, Apache, or server-side scripting, you can create an XML policy file and include it into the <code>&lt;head></code> section of your page using the <code>&lt;link></code> tag. <a href="http://www.w3.org/TR/P3P/#syntax_link">The proper code</a>, and more information on P3P is available in the W3C&#8217;s documentation.</p>
<h4>Parent Page Code</h4>
<p>Following the P3P header, here is the code for the parent page (explanation is in the comments within).</p>
<pre class="brush: xml">
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html>
&lt;head>
&lt;title>Parent Page&lt;/title>
&lt;!-- add your P3P &lt;link> here if you aren't using server-side scripting to
	deliver a header -->
&lt;/head>
&lt;body>
&lt;h1>Parent Page&lt;/h1>

&lt;!-- Here is the iframe, do not specify an src. You'll see why later. -->
&lt;iframe height="300" width="400" id="childPage">
	&lt;p>Your browser does not support inline frames.&lt;/p>
&lt;/iframe>

&lt;!-- As usual, insert ga.js and run pageTracker before the end of BODY. -->
&lt;script type="text/javascript">
</pre>
<pre class="brush: js">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</pre>
<pre class="brush: xml">
&lt;/script>
&lt;script type="text/javascript">
</pre>
<pre class="brush: js">
/* We are renaming pageTracker to parentPageTracker for clarity. */
try {
	var parentPageTracker = _gat._getTracker("UA-xxxxxx-x"); 

	/* The parent domain is the only one setting a cookie, so we have to define
		the cookie parameters here: */
	/* Don't include "www" or "subdomain" -- the period in front means the
		cookie will apply to them as well. */
	parentPageTracker._setDomainName(".PARENTDOMAIN.COM");
	/* Enable the linker, which is used to pass cookie information to another
		domain  */
	parentPageTracker._setAllowLinker(true);
	parentPageTracker._setAllowHash(false);

	/* Run the tracker: */
	parentPageTracker._trackPageview();
}
catch (err) {
}

/* The url of the child page (iframe src) is on a different domain.
	We have to let google analytics know about this so the src must be inserted
	with javascript. We're using the linker we enabled above: */
var iframe = document.getElementById("childPage");
iframe.src = parentPageTracker._getLinkerUrl("http://MY.CHILDPAGEURL.COM/");  

/* Now we add a second pageTracker for the child, called childPageTracker */
try {
	var childPageTracker = _gat._getTracker("UA-yyyyyy-y");

	/* Setting the domain to none allows us to track across different
		domains. */
	childPageTracker._setDomainName("none");

	/* Allow the linker again, in case the iframe has an iframe that wants to
		be tracked as well: */
	childPageTracker._setAllowLinker(true);
	childPageTracker._setAllowHash(false);
	childPageTracker._trackPageview();
}
catch (err) {
}

/* You can continue adding if you have more analytics codes to track-- e.g.
try {
	var thirdPageTracker = _gat._getTracker("UA-zzzzzz-z");
	thirdPageTracker._setDomainName("none");
	thirdPageTracker._setAllowLinker(true);
	thirdPageTracker._setAllowHash(false);
	thirdPageTracker._trackPageview();
}
catch (err) {
}
*/
</pre>
<pre class="brush: xml">
&lt;/script>
&lt;/body>
&lt;/html>
</pre>
<h3>Child Page(s)</h3>
<p>The child page should contain the standard Google Analytics code. No modifications need to be made for the child page (iframe contents). Lucky you.</p>
<h3>Conclusion</h3>
<p>Hopefully this will soon be outdated with the adoption of the more optimized <a href="http://code.google.com/apis/analytics/docs/tracking/asyncTracking.html">Asynchronous Tracking</a> code and a better help document.</p>
<h3>References</h3>
<ol>
<li><a href="http://code.google.com/apis/analytics/docs/gaJS/gaJSApiDomainDirectory.html">Google Analytics Documentation &mdash; Tracking API: Domains and Directories</a></li>
<li><a href="http://code.google.com/apis/analytics/docs/tracking/gaTrackingSite.html">Google Analytics Documentation &mdash; Cross-Domain Tracking</a></li>
<li><a href="http://viralpatel.net/blogs/2008/12/how-to-set-third-party-cookies-with-iframe.html">How to set third-party cookies with iframe?</a></li>
<li><a href="http://support.microsoft.com/kb/324013">How to configure IIS to use Platform for Privacy Preferences (P3P)</a></li>
<li><a href="http://www.hanselman.com/blog/TheImportanceOfP3PAndACompactPrivacyPolicy.aspx">The importance of P3P and a Compact Privacy Policy</a></li>
<li><a href="http://www.w3.org/TR/P3P">W3C Specification on P3P</a></li>
</ol>



Share this article:


	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhokuten.net%2F2010%2Fgoogle-analytics-iframes-and-multiple-domain-setups%2F&amp;title=Google%20Analytics%2C%20iFrames%2C%20and%20Multiple%20Domain%20Setups&amp;notes=Google%27s%20FAQ%20and%20help%20pags%20do%20a%20horrible%20job%20explaining%20how%20to%20use%20the%20tag%20other%20than%20pasting%20it%20into%20your%20code.%20Tracking%20for%20cross-domain%20and%20frame%2Fiframe%20scenarios%20are%20not%20explained.%20There%20is%20documentation%20on%20the%20Google%20Analytics%20javascript%2C%20though" title="del.icio.us"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhokuten.net%2F2010%2Fgoogle-analytics-iframes-and-multiple-domain-setups%2F&amp;title=Google%20Analytics%2C%20iFrames%2C%20and%20Multiple%20Domain%20Setups" title="StumbleUpon"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhokuten.net%2F2010%2Fgoogle-analytics-iframes-and-multiple-domain-setups%2F&amp;title=Google%20Analytics%2C%20iFrames%2C%20and%20Multiple%20Domain%20Setups&amp;bodytext=Google%27s%20FAQ%20and%20help%20pags%20do%20a%20horrible%20job%20explaining%20how%20to%20use%20the%20tag%20other%20than%20pasting%20it%20into%20your%20code.%20Tracking%20for%20cross-domain%20and%20frame%2Fiframe%20scenarios%20are%20not%20explained.%20There%20is%20documentation%20on%20the%20Google%20Analytics%20javascript%2C%20though" title="Digg"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fhokuten.net%2F2010%2Fgoogle-analytics-iframes-and-multiple-domain-setups%2F&amp;title=Google%20Analytics%2C%20iFrames%2C%20and%20Multiple%20Domain%20Setups" title="Reddit"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fhokuten.net%2F2010%2Fgoogle-analytics-iframes-and-multiple-domain-setups%2F&amp;title=Google%20Analytics%2C%20iFrames%2C%20and%20Multiple%20Domain%20Setups" title="DZone"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/dzone.png" title="DZone" alt="DZone" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fhokuten.net%2F2010%2Fgoogle-analytics-iframes-and-multiple-domain-setups%2F&amp;title=Google%20Analytics%2C%20iFrames%2C%20and%20Multiple%20Domain%20Setups" title="Mixx"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Google%20Analytics%2C%20iFrames%2C%20and%20Multiple%20Domain%20Setups%20-%20http%3A%2F%2Fhokuten.net%2F2010%2Fgoogle-analytics-iframes-and-multiple-domain-setups%2F" title="Twitter"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Google%20Analytics%2C%20iFrames%2C%20and%20Multiple%20Domain%20Setups&amp;body=http%3A%2F%2Fhokuten.net%2F2010%2Fgoogle-analytics-iframes-and-multiple-domain-setups%2F" title="email"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://hokuten.net/2010/google-analytics-iframes-and-multiple-domain-setups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building a Rating System in ColdFusion and SQL Server</title>
		<link>http://hokuten.net/2010/building-a-rating-system-in-coldfusion-and-sql-server/</link>
		<comments>http://hokuten.net/2010/building-a-rating-system-in-coldfusion-and-sql-server/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 00:12:45 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[cf]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://hokuten.net/?p=113</guid>
		<description><![CDATA[This is a very simple tutorial on how to create a rating system (for rating anything) in Adobe ColdFusion. For this example, we will be &#0133;]]></description>
			<content:encoded><![CDATA[<p>This is a <em>very</em> simple tutorial on how to create a rating system (for rating anything) in Adobe ColdFusion. For this example, we will be creating a game arcade, consisting of a games table and a ratings table.</p>
<h4>Requirements:</h4>
<ul>
<li>Webserver(s) running ColdFusion and SQL Server.</li>
<li>ColdFusion datasource <a href="http://www.peachpit.com/articles/article.aspx?p=29452">already set up</a> (plenty of tutorials for this, too).</li>
</ul>
<h4>Objectives:</h4>
<ul>
<li>Create database tables.</li>
<li>Create rating queries.</li>
</ul>
<h3>Information Architecture</h3>
<p>First we need to create tables in the database. Here is the database structure we will be following:</p>
<div class="image"><a href="http://hokuten.net/wordpress/wp-content/uploads/cfgames_db.png" rel="lightbox[113]"><img src="http://hokuten.net/wordpress/wp-content/uploads/cfgames_db.png" alt=""  class="aligncenter size-thumbnail wp-image-157" /></a></div>
<p>Not that it matters, but this is an identifying relationship, meaning that the games_ratings table is meaningless without the games table. Also, we have a one game to many ratings relationship.</p>
<p><span id="more-113"></span></p>
<h4>SQL for the games table:</h4>
<pre class="brush: sql">
CREATE TABLE [dbo].[games] (
	[id] [int] IDENTITY (1, 1) NOT NULL ,
	[name] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
	[url] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
	[rating] [tinyint] NULL ,
	[weight] [int] NULL
) ON [PRIMARY]
GO
</pre>
<p>This is pretty straightforward. The <samp>weight</samp> is for ordering the entries, i.e., manually sorting the games. Rating is an integer from 1-5.</p>
<h4>SQL for the games_ratings table:</h4>
<pre class="brush: sql">
CREATE TABLE [dbo].[games_ratings] (
	[game_id] [int] NOT NULL ,
	[rating] [tinyint] NOT NULL
) ON [PRIMARY]
GO
</pre>
<p>The <samp>game_id</samp> is a foreign key to the <samp>id</samp> column in the <samp>games</samp> table.</p>
<h4>Add some sample games:</h4>
<p>We won&#8217;t be creating a custom CMS to enter games in this exercise, so let&#8217;s just insert them via SQL:</p>
<pre class="brush: sql">
INSERT INTO [games] ([name], [url]) VALUES('Super Happy Fun Game', '/shfg')
INSERT INTO [games] ([name], [url]) VALUES('Awesome Adventure Omega', '/aao')
GO
</pre>
<p>The IDs will be automatically generated (1 for Super Happy Fun Game and 2 for Awesome Adventure Omega), and we aren&#8217;t using rating or weight.</p>
<h3>A Test UI</h3>
<p>Now that we have the database architecture in place, we need a way to add entries. First, let&#8217;s create an HTML form to add entries for debugging:</p>
<pre class="brush: xml">
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html>&lt;head>&lt;title>Add Game Rating&lt;/title>&lt;/head>&lt;body>
&lt;form action="gamesRate.cfm" method="post">
&lt;fieldset>
&lt;table>
&lt;tr>&lt;td>ID:&lt;/td>&lt;td>&lt;input type="text" size="2" name="id" id="id">&lt;/td>&lt;/tr>
&lt;tr>&lt;td>Rating:&lt;/td>&lt;td>&lt;input type="text" size="1" name="rating" id="rating">&lt;/td>&lt;/tr>
&lt;/table>
&lt;input type="submit" />
&lt;/p>
&lt;/fieldset>
&lt;/form>
&lt;/body>
&lt;/html>
</pre>
<p>I&#8217;ve named this file <samp>gamesRate.cfm</samp>. The form posts to itself, as you can see on line 4. There&#8217;s a field for the game ID and a field for the rating. If you check out this file on your server, you should see the form. You can submit values to it, but it won&#8217;t do anything yet.<br />
For convenience, lets add a table that displays the game names and IDs underneath the form (and before the <code>&lt;/body></code> tag):</p>
<pre class="brush: xml">
&lt;cfquery name="getGames" datasource="#MYDATASOURCE#">
	SELECT 		id, name
	FROM 		games
	ORDER BY 	id DESC
&lt;/cfquery>
&lt;table cellpadding="8" cellspacing="0">
&lt;thead>&lt;tr>
&lt;th>Game ID&lt;/th>
&lt;th>Game Title&lt;/th>
&lt;/tr>&lt;/thead>
&lt;tbody>
&lt;cfoutput query="getGames">&lt;tr>
&lt;td>#getGames.id#&lt;/td>
&lt;td>&lt;a href="#getGames.link_url#">#getGames.name#&lt;/a>&lt;/td>
&lt;/tr>&lt;/cfoutput>
&lt;/tbody>
&lt;/table>
</pre>
<p>Here is our first instance of a ColdFusion Query. Replace <samp>MYDATASOURCE</samp> with the correct value for your ColdFusion datasource. If you visit gamesRate.cfm now you should see the form and a table with IDs and game names. The values should be the ones we <code>INSERT</code>ed earlier.</p>
<p>Next, we want to process the form in the event it is submitted. At the beginning of the gamesRate.cfm file, we are going to add a <code>cfif</code> statement that checks for form submissions. We&#8217;ll do some very basic sanitization checks, and finally insert the rating if the values are in the correct format. Here&#8217;s the code:</p>
<pre class="brush: xml">
<!--- Check form submit --->
<cfif IsDefined("form.id")>
	<cfif NOT IsDefined("form.rating")>
		<cfset variables.error = 'No input passed.'>
	</cfif>

	<!--- Sanity checks --->
	<cfif NOT IsDefined("variables.error")>
		<cfif NOT IsNumeric(form.id)>
			<cfset variables.error = 'Invalid game ID value.'>
		</cfif>
		<cfif NOT IsNumeric(form.rating) OR form.rating GT 5>
			<cfset variables.error = 'Invalid rating value #form.rating#.' >
		</cfif>
	</cfif>

	<!--- ok to run queries now --->
	<cfif NOT IsDefined("variables.error")>
		<!--- Check for game exists: --->
		<cfquery name="gameExists" datasource="#datasource#" result="existsResult">
		 SELECT name
		 FROM #games_table#
		 WHERE id = #form.id#
		</cfquery>
		<cfif existsResult.RecordCount eq 0 >
			<cfset variables.error = 'Invalid game ID.'>
		</cfif>
	</cfif>

	<!--- No errors, do insert: --->
	<cfif NOT IsDefined("variables.error")>
		<cfquery name="rateGame" datasource="#datasource#">
		INSERT INTO #game_ratings_table# (
			game_id,
			rating
		) VALUES (
			#form.id#,
			#form.rating#
		)
		</cfquery>
	</cfif>
</cfif>
</pre>
<p>So first we checked for a submit. Then, we checked that the fields were filled in and filled with numbers. We check to see if the game exists. Finally, if everything is ok, we insert the new rating. An error message will stored in <samp>variables.error</samp> if anything went wrong. If you try your form out now, and check your games_ratings table, you should see values inserted.</p>
<h3>Updating the ratings</h3>
<p>Rather than calculate the average ratings on every page request, we will be using a separate script to generate the averages. A DTS package or other query scheduler (ColdFusion has one!) can run your query on a set schedule. This can reduce your SQL server load. We&#8217;ll add the following code to updateGamesRatings.cfm and run it every half hour (or to a DTS package or other scheduled service):</p>
<pre class="brush: xml">
&gt;cfquery name="getRatings" datasource="MYDATASOURCE" result="getRatingsResult">
	SELECT 		AVG(gr.rating) AS new_rating, MAX(g.id) as id, MAX(g.name) as name
	FROM 		games_ratings gr
	LEFT OUTER JOIN games g ON gr.game_id = g.id
	GROUP BY	gr.game_id
&gt;/cfquery>

&gt;html>&gt;head>&gt;title>Generate Ratings&gt;/title>&gt;/head>&gt;body>
&gt;p>&gt;cfoutput>&gt;strong>#getRatingsResult.RecordCount#&gt;/strong> records updated.&gt;/cfoutput>&gt;/p>
&gt;cfoutput query="getRatings">
	&gt;p>The new average rating for &gt;strong>[#id#] #name#&gt;/strong> is &gt;strong>#new_rating#&gt;/strong>&gt;/p>
	&gt;cfquery name="updateRating" datasource="MYDATASOURCE">
		UPDATE 	 	games
		SET 		rating = &gt;cfqueryparam value="#new_rating#" CFSQLType = "CF_SQL_INTEGER">
		WHERE 		id = &gt;cfqueryparam value="#id#" CFSQLType = "CF_SQL_INTEGER">
	&gt;/cfquery>
&gt;/cfoutput>
&gt;/body>
&gt;/html>
</pre>
<p>When you visit this file, it outputs the result of a query. The query output is the game ID, name, and average rating. The ratings are calculated for a particular game ID in the first <code>cfquery</code> and inserted in the output loop.</p>
<h3>Conclusion</h3>
<p>From this code you should be able to deviate any number of displays for the ratings. You can integrate this code with any number of ratings systems, such as <a href="http://www.fyneworks.com/jquery/star-rating/">jQuery Star Rating Plugin</a>, <a href="http://orkans-tmp.22web.net/star_rating/">Star Rating widget</a>, or some HTML or Flash system. Simply set the <code>$.post()</code> or <code>action</code> URL to the gamesRate.cfm page you created. It could also benefit from a cookie (ok), user login (recommended), or other tracking system to prevent multiple ratings.</p>



Share this article:


	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhokuten.net%2F2010%2Fbuilding-a-rating-system-in-coldfusion-and-sql-server%2F&amp;title=Building%20a%20Rating%20System%20in%20ColdFusion%20and%20SQL%20Server&amp;notes=This%20is%20a%20very%20simple%20tutorial%20on%20how%20to%20create%20a%20rating%20system%20%28for%20rating%20anything%29%20in%20Adobe%20ColdFusion.%20For%20this%20example%2C%20we%20will%20be%20creating%20a%20game%20arcade%2C%20consisting%20of%20a%20games%20table%20and%20a%20ratings%20table.%0D%0A%0D%0ARequirements%3A%0D%0A%0D%0A%09Webserver%28s%29%20running" title="del.icio.us"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhokuten.net%2F2010%2Fbuilding-a-rating-system-in-coldfusion-and-sql-server%2F&amp;title=Building%20a%20Rating%20System%20in%20ColdFusion%20and%20SQL%20Server" title="StumbleUpon"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhokuten.net%2F2010%2Fbuilding-a-rating-system-in-coldfusion-and-sql-server%2F&amp;title=Building%20a%20Rating%20System%20in%20ColdFusion%20and%20SQL%20Server&amp;bodytext=This%20is%20a%20very%20simple%20tutorial%20on%20how%20to%20create%20a%20rating%20system%20%28for%20rating%20anything%29%20in%20Adobe%20ColdFusion.%20For%20this%20example%2C%20we%20will%20be%20creating%20a%20game%20arcade%2C%20consisting%20of%20a%20games%20table%20and%20a%20ratings%20table.%0D%0A%0D%0ARequirements%3A%0D%0A%0D%0A%09Webserver%28s%29%20running" title="Digg"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fhokuten.net%2F2010%2Fbuilding-a-rating-system-in-coldfusion-and-sql-server%2F&amp;title=Building%20a%20Rating%20System%20in%20ColdFusion%20and%20SQL%20Server" title="Reddit"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fhokuten.net%2F2010%2Fbuilding-a-rating-system-in-coldfusion-and-sql-server%2F&amp;title=Building%20a%20Rating%20System%20in%20ColdFusion%20and%20SQL%20Server" title="DZone"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/dzone.png" title="DZone" alt="DZone" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fhokuten.net%2F2010%2Fbuilding-a-rating-system-in-coldfusion-and-sql-server%2F&amp;title=Building%20a%20Rating%20System%20in%20ColdFusion%20and%20SQL%20Server" title="Mixx"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Building%20a%20Rating%20System%20in%20ColdFusion%20and%20SQL%20Server%20-%20http%3A%2F%2Fhokuten.net%2F2010%2Fbuilding-a-rating-system-in-coldfusion-and-sql-server%2F" title="Twitter"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Building%20a%20Rating%20System%20in%20ColdFusion%20and%20SQL%20Server&amp;body=http%3A%2F%2Fhokuten.net%2F2010%2Fbuilding-a-rating-system-in-coldfusion-and-sql-server%2F" title="email"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://hokuten.net/2010/building-a-rating-system-in-coldfusion-and-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQRPG — An Old-School Style RPG in jQuery</title>
		<link>http://hokuten.net/2010/jqrpg-%e2%80%94-an-old-school-style-rpg-in-jquery/</link>
		<comments>http://hokuten.net/2010/jqrpg-%e2%80%94-an-old-school-style-rpg-in-jquery/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 18:55:19 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[ui]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://hokuten.net/?p=145</guid>
		<description><![CDATA[Javascript/jQuery and CSS compatibility is finally at a decent state amongst major browsers (IE and ACID3 notwithstanding). At least, similar/the same DOM manipulation behavior can &#0133;]]></description>
			<content:encoded><![CDATA[<p>Javascript/<a href="http://docs.jquery.com/Browser_Compatibility">jQuery</a> and <a href="http://acidtests.googletoad.com/">CSS</a> compatibility is finally at a decent state amongst major browsers (IE and ACID3 notwithstanding). At least, similar/the same DOM manipulation behavior can be reproduced across those browsers. Not only that, but the JavaScript rendering speed of engines other than Trident (IE&#8217;s) is <a href="http://lifehacker.com/5457242/browser-speed-tests-firefox-36-chrome-4-opera-105-and-extensions">quite fast</a>. With these developments, it is actually possible to <a href="http://gamequery.onaluf.org/">create</a> <a href="http://jonraasch.com/blog/jquery-video-game-remake-tc-surf-designs">playable</a> games (really, check those links out!).</p>
<h3>The Demo</h3>
<p>In about 4 hours I&#8217;ve created a <a href="http://sandbox.hokuten.net/jqrpg/">demo RPG here</a> using jQuery, JavaScript, CSS, and the <a href="http://code.google.com/p/js-hotkeys/">Javascript jQuery Hotkeys Plugin</a>. I&#8217;m surprised no one has created a complete, working one yet, as tile-based RPGs are much easier to make than action games with collision detection.<br />
<a href="http://sandbox.hokuten.net/jqrpg/"><img src="http://hokuten.net/wordpress/wp-content/uploads/jqrpg.png" alt="jQRPG Screenshot" title="jQRPG Screenshot" width="370" height="385" class="aligncenter size-full wp-image-146" /></a><br />
<span id="more-145"></span><br />
If anyone is interested, I might continue building this, adding in turn-based menu battles (oh boy!), a shop system, and AJAX saving and loading with an HTML5 backend. <strong>Leave a comment!</strong></p>
<h3>Outro</h3>
<p>Not that I&#8217;m against Flash (looking at you, Apple), but JavaScript is much easier to learn and there is much potential in using it for things other than special effects and Web Applications. We&#8217;ve already recreated all the basic elements used in the Nintendo games of yore using CSS and jQuery; e.g., <a href="http://tech.hyzonia.com/2009/11/jquery-sprite-animation-plugin.html">sprite animation</a> (with many techniques) and <a href="http://webdev.stephband.info/parallax.html">parallax</a> <a href="http://dev.jonraasch.com/scrolling-parallax/examples/scrolling-parallax">scrolling</a>. Combined with the super fance sliding, fading, easing, and opacity animations we are already afforded, the browser is a feature rich playground for game developers. Hopefully we&#8217;ll see more techniques emerge, and with them more games. I am looking forward to jQuery being the new QBASIC.</p>
<h3>References</h3>
<ol>
<li><a href="http://docs.jquery.com/Browser_Compatibility">jQuery Browser Compatibility</a></li>
<li><a href="http://acidtests.googletoad.com/">Acid Browser Tests</a></li>
<li><a href="http://gamequery.onaluf.org/">gameQuery</a></li>
<li><a href="http://jonraasch.com/blog/jquery-video-game-remake-tc-surf-designs">jQuery Video Game Remake: T&amp;C Surf</a></li>
<li><a href="http://code.google.com/p/js-hotkeys/">Javascript jQuery Hotkeys Plugin</a></li>
<li><a href="http://tech.hyzonia.com/2009/11/jquery-sprite-animation-plugin.html">JQuery Sprite Animation Plugin</a></li>
<li><a href="http://webdev.stephband.info/parallax.html">jParallax</a></li>
<li><a href="http://dev.jonraasch.com/scrolling-parallax/examples/scrolling-parallax">Scrolling Parallax jQuery Plugin</a></li>
</ol>



Share this article:


	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhokuten.net%2F2010%2Fjqrpg-%25e2%2580%2594-an-old-school-style-rpg-in-jquery%2F&amp;title=jQRPG%20%E2%80%94%20An%20Old-School%20Style%20RPG%20in%20jQuery&amp;notes=Javascript%2FjQuery%20and%20CSS%20compatibility%20is%20finally%20at%20a%20decent%20state%20amongst%20major%20browsers%20%28IE%20and%20ACID3%20notwithstanding%29.%20At%20least%2C%20similar%2Fthe%20same%20DOM%20manipulation%20behavior%20can%20be%20reproduced%20across%20those%20browsers.%20Not%20only%20that%2C%20but%20the%20JavaScrip" title="del.icio.us"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhokuten.net%2F2010%2Fjqrpg-%25e2%2580%2594-an-old-school-style-rpg-in-jquery%2F&amp;title=jQRPG%20%E2%80%94%20An%20Old-School%20Style%20RPG%20in%20jQuery" title="StumbleUpon"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhokuten.net%2F2010%2Fjqrpg-%25e2%2580%2594-an-old-school-style-rpg-in-jquery%2F&amp;title=jQRPG%20%E2%80%94%20An%20Old-School%20Style%20RPG%20in%20jQuery&amp;bodytext=Javascript%2FjQuery%20and%20CSS%20compatibility%20is%20finally%20at%20a%20decent%20state%20amongst%20major%20browsers%20%28IE%20and%20ACID3%20notwithstanding%29.%20At%20least%2C%20similar%2Fthe%20same%20DOM%20manipulation%20behavior%20can%20be%20reproduced%20across%20those%20browsers.%20Not%20only%20that%2C%20but%20the%20JavaScrip" title="Digg"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fhokuten.net%2F2010%2Fjqrpg-%25e2%2580%2594-an-old-school-style-rpg-in-jquery%2F&amp;title=jQRPG%20%E2%80%94%20An%20Old-School%20Style%20RPG%20in%20jQuery" title="Reddit"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fhokuten.net%2F2010%2Fjqrpg-%25e2%2580%2594-an-old-school-style-rpg-in-jquery%2F&amp;title=jQRPG%20%E2%80%94%20An%20Old-School%20Style%20RPG%20in%20jQuery" title="DZone"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/dzone.png" title="DZone" alt="DZone" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fhokuten.net%2F2010%2Fjqrpg-%25e2%2580%2594-an-old-school-style-rpg-in-jquery%2F&amp;title=jQRPG%20%E2%80%94%20An%20Old-School%20Style%20RPG%20in%20jQuery" title="Mixx"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=jQRPG%20%E2%80%94%20An%20Old-School%20Style%20RPG%20in%20jQuery%20-%20http%3A%2F%2Fhokuten.net%2F2010%2Fjqrpg-%25e2%2580%2594-an-old-school-style-rpg-in-jquery%2F" title="Twitter"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=jQRPG%20%E2%80%94%20An%20Old-School%20Style%20RPG%20in%20jQuery&amp;body=http%3A%2F%2Fhokuten.net%2F2010%2Fjqrpg-%25e2%2580%2594-an-old-school-style-rpg-in-jquery%2F" title="email"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://hokuten.net/2010/jqrpg-%e2%80%94-an-old-school-style-rpg-in-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drupal 6: Hiding Drupal Form Labels</title>
		<link>http://hokuten.net/2010/drupal-6-hiding-drupal-form-labels/</link>
		<comments>http://hokuten.net/2010/drupal-6-hiding-drupal-form-labels/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 19:46:10 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[cms]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://hokuten.net/?p=101</guid>
		<description><![CDATA[
One of the nuisances of the form output generated by Drupal is that you can&#8217;t output just the form field. The field is always accompanied &#0133;]]></description>
			<content:encoded><![CDATA[<p><img src="http://hokuten.net/wordpress/wp-content/uploads/howtogetridofthese.png" alt="" title="How to get rid of the form labels" width="350" height="125" class="aligncenter size-thumbnail wp-image-102" /><br />
One of the nuisances of the form output generated by Drupal is that you can&#8217;t output <em>just</em> the form field. The field is always accompanied by a <code>&lt;label&gt;</code> (called the <code>#title</code> in Drupal) and optionally the star denoting field requirement. There is no easy way to remove this field&mdash; you need to do it programmatically.</p>
<h3>Unset == Upset</h3>
<p>One way to remove the label is to unset the title element for the field in question:</p>
<pre class="brush: php">
unset($form['ELEMENT_NAME']['#title']);
</pre>
<p>This would be done in your theme&#8217;s (or module&#8217;s) <code>hook_form_alter()</code>. The downfall to this method is that it will most certainly yield unpleasant results when the theme engine is trying to render the form. The best example of this is the use of the <code>#title</code> element in form validation. If the field does not validate (e.g., not filled in when required or invalid format), then the theme engine outputs <samp><strong>#title</strong> is required</samp> or whatever the case may be. With the <code>#title</code> missing, only the &#8220;is required&#8221; is shown.<br />
<span id="more-101"></span></p>
<h3>A Better Way</h3>
<p>You can unobtrusively extend FormAPI, creating a new property to switch labels on and off. The first step to this is to override <code>theme_form_element()</code>. You can add this code to your theme&#8217;s template.php file. Most of the following code is from the core file form.inc except lines 16-26.</p>
<pre class="brush: php">
/**
 * Overriding drupal form.inc
 * Return a themed form element.
 */
function MYTHEME_form_element($element, $value) {
  // This is also used in the installer, pre-database setup.
  $t = get_t();

  $output = '
<div class="form-item"';
  if (!empty($element['#id'])) {
    $output .= ' id="'. $element['#id'] .'-wrapper"';
  }
  $output .= ">\n";
  $required = !empty($element['#required']) ? '<span class="form-required" title="'. $t('This field is required.') .'">*</span>' : '';

  if (!empty($element['#title']) &#038;&#038; !$element['#hidetitle']) {
    $title = $element['#title'];
    if (!empty($element['#id'])) {
      $output .= ' <label for="'. $element['#id'] .'">'. $t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) ."</label>\n";
    }
    else {
      $output .= ' <label>'. $t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) ."</label>\n";
    }
  }
  $output .= " $value\n";
  if (!empty($element['#description']) &#038;&#038; !$element['#hidedesc']) {
    $output .= '
<div class="description">'. $element['#description'] ."</div>

\n";
  }
  $output .= "</div>

\n";
  return $output;
}
</pre>
<p>On line 16 we are checking for a new condition, the boolean value of <samp>$element['#hidetitle']</samp>. If the value is true, the if block is skipped, so the label is not displayed. We do a similar thing on line 26, this time with <samp>$element['#hidedesc']</samp> to hide the description. These two conditions are the only differences from the vanilla form.inc.</p>
<p>Now that the boolean checks are in place for our new elements, we only have to add these new properties to our form elements. If you&#8217;re building a form using FormAPI, do something like this (example is an e-mail textfield):</p>
<pre class="brush: php">
$form['myfieldset']['email'] = array(
  '#type' => 'textfield',
  '#title' => t('E-mail Addresss'),
  '#default_value' => 'email',
  '#description' => t("Your e-mail address."),
  '#maxlength'=> 250,
  '#size'		=> 25,
  '#required' => TRUE,
  '#hidetitle' => TRUE,
  '#hidedesc' => TRUE,
  );
</pre>
<p>The new properties are on lines 9 and 10. When you output this field using <samp>&lt;?php print drupal_render($form['myfieldset']['email']); ?&gt;</samp>, the label will not be displayed. For a textfield the description is never displayed, so <samp>#hidedesc</samp> really only applies to fieldsets.</p>
<p>If you built your form using the Webform module, or you&#8217;re using someone else&#8217;s form, you&#8217;ll have to perform a <code>hook_form_alter()</code>. I made a webform_hidetitles module for one project that does only this. You would add the new properties like so:</p>
<pre class="brush: php">
if($form_id == 'webform_form_id') {
  $form['submitted']['email']['#hidetitle'] = true;
}
</pre>
<p>Replace form_id on line 1 with your own form id (you can find this with Devel), and the form element (<samp>email</samp> in this case) with your own form element.</p>
<h3>Conclusion</h3>
<p>Now that you know how this works, maybe you can go write and contribute a module that makes it easy to optionally display form labels and descriptions.</p>



Share this article:


	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhokuten.net%2F2010%2Fdrupal-6-hiding-drupal-form-labels%2F&amp;title=Drupal%206%3A%20Hiding%20Drupal%20Form%20Labels&amp;notes=%0D%0AOne%20of%20the%20nuisances%20of%20the%20form%20output%20generated%20by%20Drupal%20is%20that%20you%20can%27t%20output%20just%20the%20form%20field.%20The%20field%20is%20always%20accompanied%20by%20a%20%26lt%3Blabel%26gt%3B%20%28called%20the%20%23title%20in%20Drupal%29%20and%20optionally%20the%20star%20denoting%20field%20requirement.%20There%20is%20" title="del.icio.us"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhokuten.net%2F2010%2Fdrupal-6-hiding-drupal-form-labels%2F&amp;title=Drupal%206%3A%20Hiding%20Drupal%20Form%20Labels" title="StumbleUpon"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhokuten.net%2F2010%2Fdrupal-6-hiding-drupal-form-labels%2F&amp;title=Drupal%206%3A%20Hiding%20Drupal%20Form%20Labels&amp;bodytext=%0D%0AOne%20of%20the%20nuisances%20of%20the%20form%20output%20generated%20by%20Drupal%20is%20that%20you%20can%27t%20output%20just%20the%20form%20field.%20The%20field%20is%20always%20accompanied%20by%20a%20%26lt%3Blabel%26gt%3B%20%28called%20the%20%23title%20in%20Drupal%29%20and%20optionally%20the%20star%20denoting%20field%20requirement.%20There%20is%20" title="Digg"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fhokuten.net%2F2010%2Fdrupal-6-hiding-drupal-form-labels%2F&amp;title=Drupal%206%3A%20Hiding%20Drupal%20Form%20Labels" title="Reddit"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fhokuten.net%2F2010%2Fdrupal-6-hiding-drupal-form-labels%2F&amp;title=Drupal%206%3A%20Hiding%20Drupal%20Form%20Labels" title="DZone"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/dzone.png" title="DZone" alt="DZone" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fhokuten.net%2F2010%2Fdrupal-6-hiding-drupal-form-labels%2F&amp;title=Drupal%206%3A%20Hiding%20Drupal%20Form%20Labels" title="Mixx"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Drupal%206%3A%20Hiding%20Drupal%20Form%20Labels%20-%20http%3A%2F%2Fhokuten.net%2F2010%2Fdrupal-6-hiding-drupal-form-labels%2F" title="Twitter"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Drupal%206%3A%20Hiding%20Drupal%20Form%20Labels&amp;body=http%3A%2F%2Fhokuten.net%2F2010%2Fdrupal-6-hiding-drupal-form-labels%2F" title="email"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://hokuten.net/2010/drupal-6-hiding-drupal-form-labels/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Citi imposed an annual fee on me</title>
		<link>http://hokuten.net/2010/citi-imposed-an-annual-fee-on-me/</link>
		<comments>http://hokuten.net/2010/citi-imposed-an-annual-fee-on-me/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 16:48:32 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[money]]></category>
		<category><![CDATA[credit cards]]></category>
		<category><![CDATA[finance]]></category>

		<guid isPermaLink="false">http://hokuten.net/?p=91</guid>
		<description><![CDATA[
So I cancelled the card. I think this applies only to me [update: see http://www.bargaineering.com/articles/how-to-avoid-credit-card-minimum-annual-purchases-fees.html], as the Citi website still advertises the Citi&#0174; Platinum Select&#0174; &#0133;]]></description>
			<content:encoded><![CDATA[<p><img src="http://hokuten.net/wordpress/wp-content/uploads/platinum_select_citi.jpg" alt="Citi Platinum Select MasterCard" title="Citi Platinum Select MasterCard" width="289" height="213" class="alignright size-full wp-image-92" /><br />
So I cancelled the card. <del datetime="2010-02-16T06:37:00+00:00">I think this applies only to me</del> <ins datetime="2010-02-16T06:37:00+00:00">[update: see <a href="http://www.bargaineering.com/articles/how-to-avoid-credit-card-minimum-annual-purchases-fees.html">http://www.bargaineering.com/articles/how-to-avoid-credit-card-minimum-annual-purchases-fees.html</a>]</ins>, as the Citi website <a href="https://www.citicards.com/cards/wv/cardDetail.do?screenID=932&#038;origincontentId=CC_TOP_NO_FEE&#038;CONTENT_TYPE=card_category_detail">still advertises</a> the Citi&#0174; Platinum Select&#0174; MasterCard&#0174; as having no annual fee.</p>
<p>This was my oldest line of credit. I opened it in college and used it for about a year until I switched to an HSBC rewards card. Just last week I received a letter in the mail informing me that I would be charged a $60 annual fee if I did not make $2,400 worth of unreturned purchases annually.</p>
<p>It was a good card: the APR I had was very low (not that it mattered) and I could get a soft pull for a limit increase every six months or so. But considering that:</p>
<ol>
<li>I don&#8217;t get cash back or rewards from this card</li>
<li>This was my second smallest line of credit, at $3,500</li>
<li>I haven&#8217;t used it (maybe once) since 2008</li>
<li>My next oldest line of credit is only a month apart</li>
</ol>
<p>There shouldn&#8217;t be a big impact on my credit score given the factors. I called the number on the letter to &#8220;opt-out&#8221; of the annual fee (read: cancel the card). The operation was quick and painless, although the phone rep sounded sad to hear I was closing the account. I&#8217;m happy about this actually, here&#8217;s to a clean 2010!</p>



Share this article:


	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhokuten.net%2F2010%2Fciti-imposed-an-annual-fee-on-me%2F&amp;title=Citi%20imposed%20an%20annual%20fee%20on%20me&amp;notes=%0D%0ASo%20I%20cancelled%20the%20card.%20I%20think%20this%20applies%20only%20to%20me%20%5Bupdate%3A%20see%20http%3A%2F%2Fwww.bargaineering.com%2Farticles%2Fhow-to-avoid-credit-card-minimum-annual-purchases-fees.html%5D%2C%20as%20the%20Citi%20website%20still%20advertises%20the%20Citi%26%230174%3B%20Platinum%20Select%26%230174%3B%20Ma" title="del.icio.us"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhokuten.net%2F2010%2Fciti-imposed-an-annual-fee-on-me%2F&amp;title=Citi%20imposed%20an%20annual%20fee%20on%20me" title="StumbleUpon"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhokuten.net%2F2010%2Fciti-imposed-an-annual-fee-on-me%2F&amp;title=Citi%20imposed%20an%20annual%20fee%20on%20me&amp;bodytext=%0D%0ASo%20I%20cancelled%20the%20card.%20I%20think%20this%20applies%20only%20to%20me%20%5Bupdate%3A%20see%20http%3A%2F%2Fwww.bargaineering.com%2Farticles%2Fhow-to-avoid-credit-card-minimum-annual-purchases-fees.html%5D%2C%20as%20the%20Citi%20website%20still%20advertises%20the%20Citi%26%230174%3B%20Platinum%20Select%26%230174%3B%20Ma" title="Digg"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fhokuten.net%2F2010%2Fciti-imposed-an-annual-fee-on-me%2F&amp;title=Citi%20imposed%20an%20annual%20fee%20on%20me" title="Reddit"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fhokuten.net%2F2010%2Fciti-imposed-an-annual-fee-on-me%2F&amp;title=Citi%20imposed%20an%20annual%20fee%20on%20me" title="DZone"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/dzone.png" title="DZone" alt="DZone" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fhokuten.net%2F2010%2Fciti-imposed-an-annual-fee-on-me%2F&amp;title=Citi%20imposed%20an%20annual%20fee%20on%20me" title="Mixx"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Citi%20imposed%20an%20annual%20fee%20on%20me%20-%20http%3A%2F%2Fhokuten.net%2F2010%2Fciti-imposed-an-annual-fee-on-me%2F" title="Twitter"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Citi%20imposed%20an%20annual%20fee%20on%20me&amp;body=http%3A%2F%2Fhokuten.net%2F2010%2Fciti-imposed-an-annual-fee-on-me%2F" title="email"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://hokuten.net/2010/citi-imposed-an-annual-fee-on-me/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drupal 6: Creating an E-mail Subscription Block</title>
		<link>http://hokuten.net/2010/drupal-creating-an-e-mail-subscription-block/</link>
		<comments>http://hokuten.net/2010/drupal-creating-an-e-mail-subscription-block/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 17:17:39 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[cms]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://hokuten.net/2010/drupal-creating-an-e-mail-subscription-block/</guid>
		<description><![CDATA[The Drupal manual does a good job telling you how to create a plain old block module but other tutorials on module development are a &#0133;]]></description>
			<content:encoded><![CDATA[<p>The Drupal manual does a good job telling you how to <a href="http://drupal.org/node/206753">create a plain old block module</a> but other tutorials on module development are a hundredfold more complicated. The goal of this article is to follow up on the Drupal developer&#8217;s guide by creating another only slightly more advanced block.</p>
<h4>Prerequisites</h4>
<p>You should:</p>
<ol>
<li>have a <a href="http://drupal.org/getting-started/install">Drupal installation</a> to work with.</li>
<li>know how to administer Drupal (e.g., <a href="http://drupal.org/getting-started/install-contrib">install and activate modules</a>, <a href="http://drupal.org/handbook/modules/block">add blocks</a>).</li>
<li>know how to <a href="http://drupal.org/node/206753">create a basic block</a>.</li>
</ol>
<h4>Learning Objectives</h4>
<p>You will learn:</p>
<ol>
<li>how to create a .install file to create a database table.</li>
<li>how to create a block with a form.</li>
<li>how to process a form in Drupal.</li>
<li>how to perform database transactions in a Drupal module.</li>
<li>how to theme a form.</li>
</ol>
<h3>The proposed block</h3>
<p>The proposed block consists of a form with a fieldset, a text-input field, and a submit button. On submission, the text input field is validated as an e-mail address. If it does not validate, a Drupal error message is returned. Otherwise, the e-mail address will be saved to a database, an e-mail will be sent to the address, and a &#8220;thank you&#8221; message will be displayed. We will call this a &#8220;Persistent E-mail Capture Block&#8221; and use &#8220;pecapture&#8221; as its machine name.</p>
<p>This is what we&#8217;re aiming for:</p>
<div class="aligncenter"><img src="http://hokuten.net/wordpress/wp-content/uploads/drupal_pecapture_block.png" alt="" title="Drupal pecapture Block" width="278" height="212" class="aligncenter size-full wp-image-75" /></div>
<p><span id="more-77"></span></p>
<h3>The .info File</h3>
<p>You know what it is and how it works from the Drupal developer&#8217;s guide. Our .info file will contain the following:</p>
<pre class="brush: plain">
; $Id$
name = Persistent E-mail Capture
description = Provides a block with a form to enroll in subscriptions.
version = "6.x-0.0.1"
core = 6.x
php = 5.x
package = Other
</pre>
<p>If you need a refresher on what anything does, see the <a href="http://drupal.org/node/171205">Drupal manual page on .info files</a>.</p>
<h3>The .install File</h3>
<p>As described earlier, we are using a database table to store e-mail addresses. Here is our very simple database model:</p>
<div class="aligncenter"><img src="http://hokuten.net/wordpress/wp-content/uploads/drupal_pecapture_dbmodel.png" alt="" title="Drupal pecapture Database Model" width="232" height="102" class="aligncenter size-full wp-image-76" /></div>
<p>We will now transform this model into an .install file schema:</p>
<pre class="brush: php">
&lt;?php
// $Id$

/**
 * Implementation of hook_install().
 */
function pecapture_install() {
  drupal_install_schema('pecapture');
}

/**
 * Implementation of hook_uninstall().
 */
function pecapture_uninstall() {
  drupal_uninstall_schema('pecapture');
}

/**
 * Implementation of hook_schema().
 */
function pecapture_schema() {
  $schema = array();
  $schema['pecapture'] = array(
    'fields' =&gt; array(
      'capture_id' =&gt; array(
        'type' 		=&gt; 'serial',
        'unsigned' 	=&gt; TRUE,
        'not null'	=&gt; TRUE,
      ),
      'email'=&gt;array(
        'type'		=&gt; 'varchar',
        'length'	=&gt; '250',
        'not null'	=&gt; TRUE,
        'default'	=&gt; '',
      ),
    ),
    'indexes' =&gt; array('capture_id' =&gt; array('capture_id')),
    'primary_key' =&gt; array('capture_id'),
  );
  return $schema;
}
</pre>
<p>When you activate your module, Drupal executes the <code>hook_install()</code> function, <samp>pecapture_install()</samp> in this case. Likewise, in deactivation or removal, the <code>hook_uninstall()</code> function is executed&mdash; <samp>pecapture_uninstall()</samp> for us.<br />
Our hooks are pretty simple. Their one task is to install or uninstall the pecapture schema. The function <samp>pecapture_schema()</samp> returns an array of arrays, which Drupal uses to build a table. The structure of this array of arrays is pretty straightforward and mirrors our database model exactly.</p>
<h3>The .module File</h3>
<p>The .module file should have an opening php tag and a CVS tag as its first two<br />
lines:</p>
<pre class="brush: php">
&lt;?php
// $Id$
</pre>
<p>After that, we will add our own code. I&#8217;ll go over each function based on its dependency on other functions. The hooks are not necessarily the order Drupal executes them, but that doesn&#8217;t matter.</p>
<h4>General Functions</h4>
<p>First up are the standard hooks. These are all described in the Drupal developer&#8217;s guide, so I won&#8217;t reinvent the wheel here.</p>
<pre class="brush: php">
/**
 * Display help and module information
 * @param path which path of the site we're displaying help
 * @param arg array that holds the current path as would be returned from arg() function
 * @return help text for the path
 */
function pecapture_help($path, $arg) {
  $output = '';  //declare your output variable
  switch ($path) {
    case "admin/help#pecapture":
      $output = '&lt;p&gt;'.  t("Provides a block for the persistent e-mail capture form.") .'&lt;/p&gt;';
      break;
  }
  return $output;
} // function pecapture_help

/**
 * Implementation of hook_perm().
 */
function pecapture_perm() {
  return array('access pecapture content', 'administer pecapture');
}
</pre>
<h4>Our Functions</h4>
<p>Now for the good stuff: functions providing the unique functionality of our block. We will begin with the function that actually creates a block: <code>hook_block()</code>. In this case, our function is called <samp>pecapture_block()</samp>.</p>
<pre class="brush: php">
/**
 * Implementation of hook_block
 * @param string $op one of "list", "view", "save" and "configure"
 * @param integer $delta code to identify the block
 * @param array $edit only for "save" operation
 */
function pecapture_block($op = 'list', $delta = 0, $edit = array()) {
  $block = array();
  if ($op == 'list') { // Generate listing of blocks from this module, for the admin/block page
    $block[0]['info'] = t('Persistent E-mail Capture Form Block');
  }
  else if ($op == 'view') { // Generate our block content
    $block['subject'] = ''; //'Persistent E-mail Capture Form';
    $block['content'] = pecapture_displayform();
  }
  return $block;
} // function pecapture_block
</pre>
<p>You&#8217;ll recognize the list part from the Drupal guide. Our <samp>&#8216;view&#8217;</samp> operation is different, though. We aren&#8217;t giving it a subject, and we&#8217;re using a function to generate the contents.</p>
<p>Here is that function:</p>
<pre class="brush: php">
function pecapture_displayform() {
  return drupal_get_form('pecapture_blockform');
}
</pre>
<p>All this function does is return another function&#8217;s value! We use it to facilitate theming later on. The return value calls <code>drupal_get_form()</code>, which takes a function name as an argument.</p>
<p>The function name provided is <samp>pecapture_blockform()</samp>:</p>
<pre class="brush: php">
function pecapture_blockform(&#038;$form_state) {
  $form = array();
  $form['pecapture'] = array(
    '#type'			=&gt; 'fieldset',
    '#title'		=&gt; t('Don\'t Miss Out'),
    '#description'	=&gt; t('Sign up for National Train Day updates.'),
    '#collapsible' 	=&gt; FALSE,
    '#hidefieldsets' =&gt; TRUE,
  );
  $form['pecapture']['email'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('E-mail Addresss'),
    '#default_value' =&gt; 'email',
    '#description' =&gt; t("The e-mail address to which you will receive updates."),
    '#maxlength'=&gt; 250,
    '#size'		=&gt; 25,
    '#required' =&gt; TRUE,
  );
  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Keep me updated!'),
  );
  $form['#theme']     = 'pecapture_displayform';
  $form['#validate']  = array('pecapture_blockform_validate');
  return $form;
}
</pre>
<p>This function holds a Drupal form definition. Drupal has a special system for creating forms using an array of arrays. It works the same as creating a database table in Drupal. First we build a fieldset with a title (which equates to the <code>&lt;legend&gt;</code> tag and a description, which is simply the first paragraph in the fieldset. Then we create the e-mail field and submit button.</p>
<p>The line <code>$form['#theme']     = 'pecapture_displayform';</code> tells Drupal that when outputting this form, use <samp>&#8216;pecapture_displayform&#8217;</samp> as the argument for the <code>theme()</code> function. The <code>theme()</code> function currently has no clue what to do with <samp>&#8216;pecapture_displayform&#8217;</samp> so we have to give it a definition using <code>hook_theme()</code>:</p>
<pre class="brush: php">
/**
 * Implementation of hook_theme()
 */
function pecapture_theme() {
  $path = drupal_get_path('module', 'pecapture') . '/theme';
  return array(
    'pecapture_displayform' => array(
      'arguments' => array('form' => NULL),
      'template' => 'pecapture-displayform',
      'path' => $path,
    ),
  );
}
</pre>
<p>This tells Drupal that when <samp>theme(&#8216;pecapture_displayform&#8217;)</samp> is called, the file <samp>pecapture/theme/pecapture-displayform.tpl.php</samp> should be returned for output. We have to create that file:</p>
<pre class="brush: php">
&lt;div class="sidebar-email"&gt;

&lt;img src="&lt;?php print base_path().path_to_theme(); ?&gt;/images/headline_dontmissout.jpg" alt="Don't Miss Out" width="211" height="30" border="0" /&gt;
&lt;p&gt;&lt;?php print $form['pecapture']['#description']; ?&gt;&lt;/p&gt;
&lt;br /&gt;
	&lt;?php print drupal_render($form['pecapture']['email']); ?&gt;
	&lt;?php print drupal_render($form['submit']); ?&gt;
	&lt;div style="display: none;"&gt;
	&lt;?php
		unset($form['pecapture']);
		unset($form['submit']);
		print drupal_render($form);
	?&gt;
	&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>This creates a <code>&lt;div&gt;</code> for the block, displays a header image, prints the description, displays the e-mail field and submit button, and flushes the rest of the form that we don&#8217;t need. You can customize this to your liking. Save this in the <samp>theme</samp> subdirectory in your module&#8217;s directory.</p>
<p>Now that you know what happens with <code>$form['#theme']     = 'pecapture_displayform';</code> we can go back to the function <samp>pecapture_blockform()</samp>, and explain the line: <code>$form['#validate']  = array('pecapture_blockform_validate');</code></p>
<p>This line tells drupal to use the function <samp>pecapture_blockform_validate()</samp> to validate the form before it is submitted. Here is the code:</p>
<pre class="brush: php">
function pecapture_blockform_validate($form, &#038;$form_state) {
  $email = $form_state['values']['email'];
  if (strlen($email) &lt; 1) {
    form_set_error('email', t('Please provide your e-mail address.'));
  }
  else if (!eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,4})$', $email)) {
    form_set_error('email', t('That is not a valid e-mail address.'));
  }
  else if ($email_user = pecapture_getUserByField('email',$email)) {
    if (isset($email_user)) {
      form_set_error('answers', t('Your e-mail address has already been subscribed.'));
    }
  }
}
</pre>
<p>This checks to see if the e-mail address field was blank, if it matches an e-mail regular expression, and if the e-mail address already exists in the database. We are using the function <samp>pecapture_getUserByField(&#8216;email&#8217;,$email)</samp> to find a user in the database, but we need to write that. Here it is:</p>
<pre class="brush: php">
function pecapture_getUserByField($field,$data){
  $q = 'SELECT capture_id FROM {pecapture} WHERE %s LIKE \'%s\' LIMIT 1';
  $q = db_fetch_array(db_query($q,array($field,$data)));
  if (isset($q['capture_id']))
    return true;
  else
    return false;
}
</pre>
<p>This very simply selects the e-mail address from the database and returns true or false. This concludes our validation function.</p>
<p>The final function in our module is the <code>hook_submit()</code> function for the form:</p>
<pre class="brush: php">
function pecapture_blockform_submit($form, &#038;$form_state) {
  $values = $form_state['values'];
  $fields = array('email');
  $q = 'INSERT INTO {pecapture} ('.implode(',',$fields).') VALUES (\'%s\')';
  $insert = array();
  foreach ($fields as $f) {
	$insert[] = $values[$f];
  }
  db_query($q, $insert);
  $user = $insert;
  drupal_set_message('Thanks for subscribing!');
}
</pre>
<p>This just creates a query based on the form values and runs it, then queues a Drupal message.</p>
<h3>Conclusion</h3>
<p>This could have been accomplished with the modules <a href="http://drupal.org/project/webform">Webform</a> and <a href="http://drupal.org/project/webformblock">Webform Block</a> or <a href="http://drupal.org/project/nodeasblock">Node As Block</a> or <a href="http://drupal.org/node/248157">PHPTemplate to insert a node into a region</a>, but creating your own module in this case offers a level of theme output greater than what Webform allows without some intricate hooks (try and remove the form label!). You should now also have a better understanding of how to create a Drupal module, form, and hook into themes.</p>
<h3>Further Reading</h3>
<p>I recommend following these tutorials next, in order:</p>
<ol>
<li><a href="http://www.packtpub.com/article/creating-our-first-module-using-drupal6-part1">Creating Our First Module using Drupal 6</a></li>
<li><a href="http://gazebo.commonplaces.com/2009/06/creating-simple-modules-and-filling-the-functionality-gap/">Creating &#8220;Simple&#8221; Drupal Modules, and Filling the Functionality Gap</a></li>
</ol>



Share this article:


	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fhokuten.net%2F2010%2Fdrupal-creating-an-e-mail-subscription-block%2F&amp;title=Drupal%206%3A%20Creating%20an%20E-mail%20Subscription%20Block&amp;notes=The%20Drupal%20manual%20does%20a%20good%20job%20telling%20you%20how%20to%20create%20a%20plain%20old%20block%20module%20but%20other%20tutorials%20on%20module%20development%20are%20a%20hundredfold%20more%20complicated.%20The%20goal%20of%20this%20article%20is%20to%20follow%20up%20on%20the%20Drupal%20developer%27s%20guide%20by%20creating%20an" title="del.icio.us"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fhokuten.net%2F2010%2Fdrupal-creating-an-e-mail-subscription-block%2F&amp;title=Drupal%206%3A%20Creating%20an%20E-mail%20Subscription%20Block" title="StumbleUpon"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fhokuten.net%2F2010%2Fdrupal-creating-an-e-mail-subscription-block%2F&amp;title=Drupal%206%3A%20Creating%20an%20E-mail%20Subscription%20Block&amp;bodytext=The%20Drupal%20manual%20does%20a%20good%20job%20telling%20you%20how%20to%20create%20a%20plain%20old%20block%20module%20but%20other%20tutorials%20on%20module%20development%20are%20a%20hundredfold%20more%20complicated.%20The%20goal%20of%20this%20article%20is%20to%20follow%20up%20on%20the%20Drupal%20developer%27s%20guide%20by%20creating%20an" title="Digg"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fhokuten.net%2F2010%2Fdrupal-creating-an-e-mail-subscription-block%2F&amp;title=Drupal%206%3A%20Creating%20an%20E-mail%20Subscription%20Block" title="Reddit"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Fhokuten.net%2F2010%2Fdrupal-creating-an-e-mail-subscription-block%2F&amp;title=Drupal%206%3A%20Creating%20an%20E-mail%20Subscription%20Block" title="DZone"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/dzone.png" title="DZone" alt="DZone" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fhokuten.net%2F2010%2Fdrupal-creating-an-e-mail-subscription-block%2F&amp;title=Drupal%206%3A%20Creating%20an%20E-mail%20Subscription%20Block" title="Mixx"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Drupal%206%3A%20Creating%20an%20E-mail%20Subscription%20Block%20-%20http%3A%2F%2Fhokuten.net%2F2010%2Fdrupal-creating-an-e-mail-subscription-block%2F" title="Twitter"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Drupal%206%3A%20Creating%20an%20E-mail%20Subscription%20Block&amp;body=http%3A%2F%2Fhokuten.net%2F2010%2Fdrupal-creating-an-e-mail-subscription-block%2F" title="email"><img src="http://hokuten.net/wordpress/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://hokuten.net/2010/drupal-creating-an-e-mail-subscription-block/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
