<?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>Small Program Blog &#187; PHP</title>
	<atom:link href="http://blog.sunnycyk.hk/?feed=rss2&#038;tag=php" rel="self" type="application/rss+xml" />
	<link>http://blog.sunnycyk.hk</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sat, 05 Nov 2011 06:32:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mac OSX: Add Hosts to Local hosts file</title>
		<link>http://blog.sunnycyk.hk/?p=358</link>
		<comments>http://blog.sunnycyk.hk/?p=358#comments</comments>
		<pubDate>Mon, 14 Sep 2009 08:01:38 +0000</pubDate>
		<dc:creator>Sunny</dc:creator>
				<category><![CDATA[Mac Stuff]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[hosts]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[Virtual Machine]]></category>
		<category><![CDATA[VM]]></category>
		<category><![CDATA[VMware]]></category>

		<guid isPermaLink="false">http://blog.sunnycyk.hk/?p=358</guid>
		<description><![CDATA[I was in the hospital for awhile, so I have not had a chance to update my blog.  
Yesterday I installed OpenSuse to my VM on my Mac Pro because I wanted to play with Magento, so I installed Apache, PHP, and mySQL with all necessary modules.  Everything is going well, and Magento(1.1.3) [...]]]></description>
			<content:encoded><![CDATA[<p>I was in the hospital for awhile, so I have not had a chance to update my blog.  </p>
<p>Yesterday I installed OpenSuse to my VM on my Mac Pro because I wanted to play with Magento, so I installed Apache, PHP, and mySQL with all necessary modules.  Everything is going well, and Magento(1.1.3) finally installed successfully with it&#8217;s sample data today(it was a bitch until I changed the hostname to localhost.com!) .  However, I set my VM hostname as localhost.com, and I would like to access it from my OSX Safari.  And of course, my DNS records localhost.com as something else on the internet, but not pointing to my VM&#8217;s IP address.  </p>
<p>So what should I do?  I have to change the &#8220;<strong>hosts</strong>&#8221; file on my Mac.  It is located at &#8220;<strong>/private/etc/hosts</strong>&#8220;.  In order to edit it, you have to grant yourself as root privilege, but by default &#8220;root&#8221; account is disabled in OSX.  Therefore, you will use command &#8220;<strong>sudo</strong>&#8220;.  For example, I use vi for editing, I will type &#8220;<strong>sudo vi /private/etc/hosts</strong>&#8221; in my terminal windows, and it will prompt me to enter a password(which it should be your admin password on OSX).  Once you get authorized, you should be able to edit the <strong>hosts</strong> file. </p>
<p> To enter a new hostname in hosts file, in a new line at the end, type in IP address, then Tab, and the hostname.  Once saved, Mac OSX should resolve the hostname to that IP address.  </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sunnycyk.hk/?feed=rss2&amp;p=358</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex &#8211; Playing with Twitter API and solving the cross-domain problem</title>
		<link>http://blog.sunnycyk.hk/?p=279</link>
		<comments>http://blog.sunnycyk.hk/?p=279#comments</comments>
		<pubDate>Thu, 26 Mar 2009 17:27:30 +0000</pubDate>
		<dc:creator>Sunny</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.sunnycyk.hk/?p=279</guid>
		<description><![CDATA[Today I wrote a small and simple Flex program with Twitter API.  Here is my code:


&#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62;
  &#60;mx:Application xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34; backgroundImage=&#34;@Embed(source='image/twitter_bg.png')&#34; height=&#34;50&#34; width=&#34;850&#34; layout=&#34;absolute&#34; creationComplete=&#34;twitterService.send()&#34;&#62;
&#60;mx:Script&#62;
&#60;![CDATA[
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;

[Bindable]
private var Feed:Object;

public function twitterHandler(event:ResultEvent):void {
Feed = event.result.user;
}

]]&#62;
&#60;/mx:Script&#62;
&#60;mx:HTTPService id=&#34;twitterService&#34; url=&#34;proxy.php&#34; result=&#34;twitterHandler(event)&#34; /&#62;
  &#60;mx:HBox width=&#34;800&#34; height=&#34;41&#34; verticalCenter=&#34;1&#34; x=&#34;0&#34; verticalAlign=&#34;middle&#34;&#62;
  &#60;mx:Spacer x=&#34;0&#34; y=&#34;0&#34; width=&#34;15&#34;/&#62;
  &#60;mx:Image source=&#34;@Embed(source='image/twitter_logo_header.png')&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>Today I wrote a small and simple Flex program with Twitter API.  Here is my code:</p>
<pre>
<code>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; backgroundImage=&quot;@Embed(source='image/twitter_bg.png')&quot; height=&quot;50&quot; width=&quot;850&quot; layout=&quot;absolute&quot; creationComplete=&quot;twitterService.send()&quot;&gt;
&lt;mx:Script&gt;
&lt;![CDATA[
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;

[Bindable]
private var Feed:Object;

public function twitterHandler(event:ResultEvent):void {
Feed = event.result.user;
}

]]&gt;
&lt;/mx:Script&gt;
&lt;mx:HTTPService id=&quot;twitterService&quot; url=&quot;proxy.php&quot; result=&quot;twitterHandler(event)&quot; /&gt;
  &lt;mx:HBox width=&quot;800&quot; height=&quot;41&quot; verticalCenter=&quot;1&quot; x=&quot;0&quot; verticalAlign=&quot;middle&quot;&gt;
  &lt;mx:Spacer x=&quot;0&quot; y=&quot;0&quot; width=&quot;15&quot;/&gt;
  &lt;mx:Image source=&quot;@Embed(source='image/twitter_logo_header.png')&quot; width=&quot;126&quot; height=&quot;25&quot;/&gt;
  &lt;mx:Image source=&quot;{Feed.profile_image_url}&quot; width=&quot;30&quot; height=&quot;30&quot;/&gt;
  &lt;mx:Label text=&quot;{Feed.screen_name}&quot; fontSize=&quot;16&quot; color=&quot;#2896AD&quot; width=&quot;83&quot;/&gt;
  &lt;mx:Label text=&quot;{Feed.status.text}&quot; width=&quot;498&quot; fontSize=&quot;12&quot; color=&quot;#084755&quot;/&gt;
  &lt;/mx:HBox&gt;
  &lt;/mx:Application&gt;
</code>
</pre>
<p>and you can see the result here: <a href="http://sunnycyk.hk/twitter/">http://sunnycyk.hk/twitter/</a></p>
<p>It may look easy, but actually it takes me sometime to figure out how to make it works.  The code was working fine in debug mode with Flex, but it did not work on release mode.  I was wondering why and searching on internet, and finally figure out it is because of security reason.  </p>
<p>There are couple methods you can try, but I just used a easy way to do it by adding a proxy.php file.  What proxy.php does just requests data from the remote domain site (for my case, it is &#8220;http://twitter.com/users/show/skyc999.xml&#8221;), and regenerates the output so that your flash player will think that you are working with a local XML file.  </p>
<p>When my flash file runs, it will call proxy.php.  Then proxy.php will grab XML file from Twitter, and generate the XML output to my flash file.  Because my flash file only calls the local file, it does not voliate the flash player security policy setting, and everything works again!</p>
<p>The proxy.php only contains two line of code:</p>
<pre>
<code>
&lt;?php
$dataURL = "http://twitter.com/users/show/skyc999.xml";
readfile($dataURL);
?&gt;
</code>
</pre>
<p>If you are a twitter user, you can try my program(download it?) and replace the skyc999  in $dataURL with your screen name.  </p>
<p>This example just gives a basic idea how to work with cross-domain files and Twitter API.  Hope it can help you (and me) <img src='http://blog.sunnycyk.hk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sunnycyk.hk/?feed=rss2&amp;p=279</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Theme &#8211; My header.php</title>
		<link>http://blog.sunnycyk.hk/?p=266</link>
		<comments>http://blog.sunnycyk.hk/?p=266#comments</comments>
		<pubDate>Tue, 24 Mar 2009 10:30:16 +0000</pubDate>
		<dc:creator>Sunny</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Theme Design]]></category>

		<guid isPermaLink="false">http://blog.sunnycyk.hk/?p=266</guid>
		<description><![CDATA[This is code for my header.php:


&#60;?php
  /**
  * @package WordPress
  * @subpackage mySmallProgramTheme
  */
  ?&#62;
  &#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62;
  &#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34; &#60;?php language_attributes(); ?&#62;&#62;

&#60;head profile=&#34;http://gmpg.org/xfn/11&#34;&#62;
  &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;&#60;?php bloginfo('html_type'); ?&#62;; charset=&#60;?php bloginfo('charset'); ?&#62;&#34; /&#62;

&#60;title&#62;&#60;?php wp_title('&#38;laquo;', true, 'right'); ?&#62; &#60;?php bloginfo('name'); ?&#62;&#60;/title&#62;

&#60;link rel=&#34;stylesheet&#34; href=&#34;&#60;?php [...]]]></description>
			<content:encoded><![CDATA[<p>This is code for my header.php:</p>
<pre>
<code>
&lt;?php
  /**
  * @package WordPress
  * @subpackage mySmallProgramTheme
  */
  ?&gt;
  &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
  &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &lt;?php language_attributes(); ?&gt;&gt;

&lt;head profile=&quot;http://gmpg.org/xfn/11&quot;&gt;
  &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;&lt;?php bloginfo('html_type'); ?&gt;; charset=&lt;?php bloginfo('charset'); ?&gt;&quot; /&gt;

&lt;title&gt;&lt;?php wp_title('&amp;laquo;', true, 'right'); ?&gt; &lt;?php bloginfo('name'); ?&gt;&lt;/title&gt;

&lt;link rel=&quot;stylesheet&quot; href=&quot;&lt;?php bloginfo('stylesheet_url'); ?&gt;&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;
  &lt;link rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot; title=&quot;&lt;?php bloginfo('name'); ?&gt; RSS Feed&quot; href=&quot;&lt;?php bloginfo('rss2_url'); ?&gt;&quot; /&gt;
  &lt;link rel=&quot;alternate&quot; type=&quot;application/atom+xml&quot; title=&quot;&lt;?php bloginfo('name'); ?&gt; Atom Feed&quot; href=&quot;&lt;?php bloginfo('atom_url'); ?&gt;&quot; /&gt;
  &lt;link rel=&quot;pingback&quot; href=&quot;&lt;?php bloginfo('pingback_url'); ?&gt;&quot; /&gt;
  &lt;link rel=&quot;shortcut icon&quot; href=&quot;&lt;?php get_bloginfo('url') ?&gt;/wp-content/themes/mysmallprogramtheme/image/favicon.png&quot; type=&quot;image/png&quot; /&gt;

&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot; /&gt;
  &lt;?php if (is_singular() ) wp_enqueue_script('comment-reply');
  ?&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id=&quot;page&quot;&gt;
  &lt;div id=&quot;header&quot;&gt;

  &lt;div id=&quot;headerimage&quot;&gt;
  &lt;a href=&quot;&lt;?php echo get_option('home'); ?&gt;&quot; &gt;&lt;h1&gt;&lt;?php bloginfo('name'); ?&gt;&lt;/h1&gt;&lt;/a&gt;
  &lt;div class=&quot;description&quot;&gt;&lt;?php bloginfo('description'); ?&gt;&lt;/div&gt;
  &lt;/div&gt;
</code>
</pre>
<p>First, I have setup some header information with bloginfo() in the Header tag.  You may just take a look how I did that because you mostly will put the same header as mine.</p>
<p>After the Header Tag, I defined a Wrapper layer &#8220;page&#8221;</p>
<pre>
<code>
&lt;div id=&quot;page&quot;&gt;
</code>
</pre>
<p>This is the wrapper for all contents in my blog.  In this wrapper, usually you will define four different parts(or layers).  </p>
<p>1. Header<br />
2. Content<br />
3. Footer<br />
4. Sidebar</p>
<p>And for this example, this file is called header.php, so I will define our &#8220;Header&#8221; layer here.  Next 5 lines, I have defined my &#8220;Header&#8221;:</p>
<pre>
<code>
 &lt;div id=&quot;header&quot;&gt;

  &lt;div id=&quot;headerimage&quot;&gt;
  &lt;a href=&quot;&lt;?php echo get_option('home'); ?&gt;&quot; &gt;&lt;h1&gt;&lt;?php bloginfo('name'); ?&gt;&lt;/h1&gt;&lt;/a&gt;
  &lt;div class=&quot;description&quot;&gt;&lt;?php bloginfo('description'); ?&gt;&lt;/div&gt;
  &lt;/div&gt;
</code>
</pre>
<p>In the header layer, I have defined another wrapper called &#8220;headerimage&#8221;.  This is because I want to wrap my Blog title and description in my header layer.</p>
<p>Later on, I will show you how I created index.php for my content layer.  footer.php for my footer layer, and sidebar.php for my sidebar layer.  </p>
<p>One more thing I forgot to mention, in header section, there is a php code:</p>
<pre>
<code>
 &lt;?php if (is_singular() ) wp_enqueue_script('comment-reply');
  ?&gt;
</code>
</pre>
<p>is_singular() will check if this page is a single post (only one post on the page, and actually there is a template file called single.php that you may also define it yourself or by WordPress default template.  single.php is liked index.php which I will call my header, sidebar, and footer files here except it only displays one post per page).  In my case, I only want to include javascript for replying a comment when someone land on single.php, or else the code should not be included.  </p>
<p>So, it looks pretty simple right?  However, don&#8217;t forget the code above has no decoration, so you will have to define your own CSS style for each layer and wrapper, or otherwise you will only see plain text on your header. </p>
<pre>
<code>
body {
	font-size: 62.5%; /* Resets 1em to 10px */
	font-family: Arial, Helvetica, sans-serif;
	background: #ffffff;
	color: #333;
	text-align: center;

}

#page {
	border: none;
	background:url(image/layoutbg.png) repeat-y bottom center;

}

#header {
	background: url(image/headerpic.jpg) no-repeat top center;
}

#headerimage {
	width: 830px;
	height: 195px;
}

#header h1 {
	font-size:36px;
	text-align: center;
	color: #903;
}

#header a, #header a:visited {
	text-decoration: none;
	color: #903;
}

#header a:hover {
	text-decoration:underline;
}

#headerimage .description {
	font-size:14px;
	text-align: center;
	color: #666;
	font-family:Georgia, "Times New Roman", Times, serif;
	font-style:italic;
}

body {
	margin: 0px 0 20px 0;
	padding: 0;
}

#page {
	margin: 0px auto;
	padding: 0;
	width: 830px;
}

#header {
	margin: 0 0 0 0px;
	padding:0;
	height:195px;
	width: 830px;
}

#headerimage {
	margin: 0;
}

#header h1 {
	margin: 0;
	padding:70px 0px 0px 0;
}

#headerimage .description {
	margin: 0;
	padding:1px 15px 0 0;
}

</code>
</pre>
<p>Please forgive my mess. <img src='http://blog.sunnycyk.hk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   I defined them twice because I kinda modified from the default WordPress Theme which it separates the style of structure and coloring in two parts.  You may just group them in one depends on what you like.  </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sunnycyk.hk/?feed=rss2&amp;p=266</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>WordPress Theme &#8211; Highlight Plugin</title>
		<link>http://blog.sunnycyk.hk/?p=250</link>
		<comments>http://blog.sunnycyk.hk/?p=250#comments</comments>
		<pubDate>Thu, 12 Mar 2009 02:41:47 +0000</pubDate>
		<dc:creator>Sunny</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Theme Design]]></category>

		<guid isPermaLink="false">http://blog.sunnycyk.hk/?p=250</guid>
		<description><![CDATA[When I was trying to post some PHP coding, I found it is not easy to decorate it.. for example, you want the code to be aligned, so that it is user friendly (easy to read).  Then you need to handle space for each line.  Also, you may want to highlight some keywords. [...]]]></description>
			<content:encoded><![CDATA[<p>When I was trying to post some PHP coding, I found it is not easy to decorate it.. for example, you want the code to be aligned, so that it is user friendly (easy to read).  Then you need to handle space for each line.  Also, you may want to highlight some keywords.  There will be a lot of work, and some programming languages look really similar, but if you want to decorate them, you may have to do it one by one, and it could suck out most of your time.</p>
<p>Fortunately, WordPress has a plugin that helps you to do all the works for you.  It is called <a href="http://softwaremaniacs.org/soft/highlight/en/">Highlight</a>, and you can download it and use it as WordPress plugin or just code it within your HTML file.  You only need to assign some CSS style such as color for keywords.  This is very nice because usually I like to program everything myself, but this really saves me a lot of time.  (On the other hand, many things on the web are really useful).  </p>
<p>For example,</p>
<pre>
<code>
&lt;?php
if (is_home()) {
	echo bloginfo('name');
} elseif (is_404()) {
	echo '404 Not Found';
} else {
	echo wp_title('');
}
?&gt;
</code>
</pre>
<p>and my CSS Style (which applies the highlight for the code above and below for showcase):</p>
<pre>
<code>
code {
	color: #000099;
	font: normal "Courier New", Courier, monospace;
	white-space: nowrap;
	padding: 0 2px;
}
pre code {
	display: block;
	clear: both;
	background: #FDF;
	color: #333;
	border: solid 1px #ccc;
	overflow: auto;
	line-height: 140%;
	white-space: pre;
	width: 470px;
	text-align:left;
}
code .comment {
	color: #888;
}
code .class, code .rules {
	color: #ff00ff;
	font-size: 100%;
}
code .value,  code .title, code .string {
	color: #0000FF;
}
code .tag {
	color: #000099;
}
code .keyword {
	color: #000099;
}
.html .attribute {
	color: #006600;
}
</code>
</pre>
<p>All I have done is just put all my code within &lt;pre&gt;&lt;code&gt;&lt;/code&gt;&lt;/pre&gt; and it will decorate my code with my CSS style.  Isn&#8217;t it really easy?  yea, you can compare my old posts which I just use &lt;p&gt; and style it, and which still doesn&#8217;t look good.  </p>
<p>One more thing, if you do not want to use it as plugin, you can just put these two lines of code on your web page (The WordPress plugin will automatically add these two lines to your WordPress blog) :</p>
<pre>
<code>
&lt;script type="text/javascript" src="highlight.pack.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript"&gt;
      hljs.initHighlightingOnLoad();
    &lt;/script&gt;
</code>
</pre>
<p>It is pretty easy, right?</p>
<p>For more information about <b>Highlight</b>, you can visit this Link:<br />
<a href="http://softwaremaniacs.org/soft/highlight/en/"> http://softwaremaniacs.org/soft/highlight/en/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sunnycyk.hk/?feed=rss2&amp;p=250</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>WordPress Theme &#8211; A Very Nice Tutorial</title>
		<link>http://blog.sunnycyk.hk/?p=243</link>
		<comments>http://blog.sunnycyk.hk/?p=243#comments</comments>
		<pubDate>Tue, 10 Mar 2009 17:07:05 +0000</pubDate>
		<dc:creator>Sunny</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Theme Design]]></category>

		<guid isPermaLink="false">http://blog.sunnycyk.hk/?p=243</guid>
		<description><![CDATA[I actually found a very nice tutorial site for designing the WordPress Theme.  I will say compare to this site, my blog for designing the WordPress Theme is a mess&#8230; haha.. 
ok, anyway, here you go: http://www.webdesignerwall.com/tutorials/building-custom-wordpress-theme/
It has many tricks too.  Good for anyone wants to do some graphic and web design (same [...]]]></description>
			<content:encoded><![CDATA[<p>I actually found a very nice tutorial site for designing the WordPress Theme.  I will say compare to this site, my blog for designing the WordPress Theme is a mess&#8230; haha.. </p>
<p>ok, anyway, here you go: <a href="http://www.webdesignerwall.com/tutorials/building-custom-wordpress-theme/">http://www.webdesignerwall.com/tutorials/building-custom-wordpress-theme/</a></p>
<p>It has many tricks too.  Good for anyone wants to do some graphic and web design (same as me <img src='http://blog.sunnycyk.hk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  )</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sunnycyk.hk/?feed=rss2&amp;p=243</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Theme &#8211; Sidebar</title>
		<link>http://blog.sunnycyk.hk/?p=224</link>
		<comments>http://blog.sunnycyk.hk/?p=224#comments</comments>
		<pubDate>Mon, 09 Mar 2009 17:05:38 +0000</pubDate>
		<dc:creator>Sunny</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Theme Design]]></category>

		<guid isPermaLink="false">http://blog.sunnycyk.hk/?p=224</guid>
		<description><![CDATA[In WordPress, there are widgets such as calender that may appear on your theme based on your appearance setting.  Usually they will appear on sidebar when you add the widgets in the theme.  If there is no widget adding to the sidebar, a function dynamic_sidebar() will return a FALSE value.  This function [...]]]></description>
			<content:encoded><![CDATA[<p>In WordPress, there are widgets such as calender that may appear on your theme based on your appearance setting.  Usually they will appear on sidebar when you add the widgets in the theme.  If there is no widget adding to the sidebar, a function <b>dynamic_sidebar()</b> will return a FALSE value.  This function is useful if you are designing a theme template because you may want to create something if there is no widget on the sidebar.  For example, you may want to include your own widget to the sidebar if user has not included any widget in the theme appearance setting.  </p>
<p>Further, if you want to add widget at the appearance setting, you will need to register the sidebar to WordPress in the file <b>function.php</b>.  The function <b>register_sidebar()</b> will tell the plugin that your theme will need exactly one sidebar and your admin inteface should have <b>Sidebar Widgets</b> in the Presentation menu.  <b>register_sidebar()</b> also allows you to decorate the widget by adding a parameter to it.  For example,</p>
<p style="padding: 10px; display: block; background-color: #eef;font-weight:bold;">
&lt;?php<br />
if (function_exists(&#8217;register_sidebar&#8217;) )<br />
<strong>register_sidebar</strong>(array(&#8217;before_widget&#8217;=>&#8217; &#8216;,<br />
&#8216;after_widget&#8217; => &#8216; &#8216;,<br />
&#8216;before_title&#8217; => &#8216;&lt;div class=&#8221;title&#8221;&gt;&#8217;,<br />
&#8216;after_title&#8217;=>&#8217;&lt;/div&gt;&#8217;));<br />
?&gt;
</p>
<p><b>before_widget</b> and <b>after_widget</b> means that something that you want to decorate the widget.. you may think it can be a warper and you will warp your widgets.  In this example, we put nothing, so there is no decoration for this widget warper.  Then <b>before_title</b> and <b>after_title</b>, will decorate the wiget title with &lt;div lass=&#8221;title&#8221;&gt; and &lt;/div&gt;.  The output will look like this:</p>
<p style="padding: 10px; display: block; background-color: #eef;font-weight:bold;">
&lt;div lass=&#8221;title&#8221;&gt; Widgets Title &lt;/div&gt;
</p>
<p>What if you want to include more than one sidebar?  Then instead of using <b>register_sidebar()</b>, you will use <b>register_sidebars(n)</b> where n is the number of sidebars.  (starting with 1)  </p>
<p>For more information, you may check out this page to see how to widgetizing themes with sidebar.<br />
<a href="http://codex.wordpress.org/Widgetizing_Themes">http://codex.wordpress.org/Widgetizing_Themes</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sunnycyk.hk/?feed=rss2&amp;p=224</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Theme &#8211; WordPress Loop</title>
		<link>http://blog.sunnycyk.hk/?p=157</link>
		<comments>http://blog.sunnycyk.hk/?p=157#comments</comments>
		<pubDate>Sun, 08 Mar 2009 09:22:24 +0000</pubDate>
		<dc:creator>Sunny</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Theme Design]]></category>

		<guid isPermaLink="false">http://blog.sunnycyk.hk/?p=157</guid>
		<description><![CDATA[WordPress Loop is the Loop that is used by WordPress to display each of your blog posts.  Using the Loop, WordPress processes each of the posts to be displayed on the current page and formats them within the Loop tags.
Basic WordPress Loop structure will look like this:

&#60;?php if ( have_posts() )&#160;: while ( have_posts() )&#160;: [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress Loop is the Loop that is used by WordPress to display each of your blog posts.  Using the Loop, WordPress processes each of the posts to be displayed on the current page and formats them within the Loop tags.</p>
<p>Basic WordPress Loop structure will look like this:</p>
<p style="display:block; background-color:#eef; padding: 10px; border:#ddf solid 1px;">
<b>&lt;?php if ( have_posts() )&nbsp;: while ( have_posts() )&nbsp;: the_post();&nbsp;?&gt;</b><br />
&lt;!&#8211; something you want to repeat within the Loop tag &#8211;&gt;<br />
<b>&lt;?php endwhile; else:&nbsp;?&gt;<br />
&lt;p&gt;&lt;?php _e(&#8217;Sorry, no posts matched your criteria.&#8217;);&nbsp;?&gt;&lt;/p&gt;<br />
&lt;?php endif;&nbsp;?&gt;</b>
</p>
<p style="margin:10px 0 0 0;">
Let me explain what is going on.  First, you need to know that there is a global object called <b>$wp_query</b>, and when WordPress generates your blog pages, it will build and execute a DB query that results in an array of posts, and which will store in the <b>$wp_query</b> object and also return back to the blog header where it is stuffed into the global <b>$post</b> array.
</p>
<p>
 The <b>have_posts()</b> actually calls <b>$wp_query->have_posts()</b> which checks a loop counter to see if there are any pots left in the post array and return a boolean value TRUE if there is post or FALSE when we have exhausted the loop.   And <b>the_post()</b> calls <b>$wp_query->the post()</b> which advance the loop counter and sets up the global <b>$post</b> variable as well as all of the global post data.  On the other hand, It takes the current item in the collection of the posts and makes it available for use inside the iteration of the Loop.
</p>
<p>
Once you understand how the WordPress loop works, then you can use this loop for displaying your blog posts.  So, here are some functions that you probably will put inside the WordPress loop:
</p>
<p style="display:block; background-color:#eef; padding: 10px; border:#ddf solid 1px; margin: 5px 0 5px 0;">
<b>the_title()</b> &#8211; Display the current post&#8217;s title
</p>
<p style="display:block; background-color:#eef; padding: 10px; border:#ddf solid 1px; margin: 5px 0 5px 0;">
<b>the_time(<i>format</i>)</b> &#8211; Display the date with <i>format</i>
</p>
<p style="display:block; background-color:#eef; padding: 10px; border:#ddf solid 1px; margin: 5px 0 5px 0;">
<b>the_author()</b> &#8211; Display the author name
</p>
<p style="display:block; background-color:#eef; padding: 10px; border:#ddf solid 1px; margin: 5px 0 5px 0;">
<b>the_permalink()</b> &#8211; a Permanent Link that point to the current post
</p>
<p style="display:block; background-color:#eef; padding: 10px; border:#ddf solid 1px; margin: 5px 0 5px 0;">
<b>the_content()</b> &#8211; Display the content of the post
</p>
<p style="margin: 10px 0 0 0;">
There are more technique you can use and display inside the loop.  Here I just post some common functions that you will usually use, but there are more function you can do such as comment for the post.  You can find more information here:</p>
<p> <a href="http://codex.wordpress.org/The_Loop">http://codex.wordpress.org/The_Loop</a><br />
<a href="http://codex.wordpress.org/The_Loop_in_Action">http://codex.wordpress.org/The_Loop_in_Action</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sunnycyk.hk/?feed=rss2&amp;p=157</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress Theme &#8211; wp_enqueue_script() and Conditional Tags</title>
		<link>http://blog.sunnycyk.hk/?p=107</link>
		<comments>http://blog.sunnycyk.hk/?p=107#comments</comments>
		<pubDate>Thu, 05 Mar 2009 16:18:31 +0000</pubDate>
		<dc:creator>Sunny</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Theme Design]]></category>

		<guid isPermaLink="false">http://blog.sunnycyk.hk/?p=107</guid>
		<description><![CDATA[Conditional Tag:

Using Conditional Tags for testing whether a certain condition is met, and then returns either TRUE or FALSE.
For example,
is_home() will return TRUE if the main blog page is being displayed.
Some of the conditional tags may contain parameters for conditions.  More information can be found here: http://codex.wordpress.org/Conditional_Tags
Function: wp_enqueue_script():
wp_enqueue_script(handle, src, deps, ver) is a function for adding [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: large;"><span><strong>Conditional Tag:<br />
</strong></span></span></p>
<p>Using Conditional Tags for testing whether a certain condition is met, and then returns either TRUE or FALSE.</p>
<p><span style="background-color: #FEF; padding: 5px 5px 5px 10px; display: block; line-height:30px;">For example,<br />
<strong>is_home()</strong> will return TRUE if the main blog page is being displayed.</span></p>
<p>Some of the conditional tags may contain parameters for conditions.  More information can be found here: <a href="http://codex.wordpress.org/Conditional_Tags">http://codex.wordpress.org/Conditional_Tags</a><br />
<span style="font-size: large; margin: 30px 0 10px 0;font-weight: bold; display: block;">Function: wp_enqueue_script():</span></p>
<p><a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script"><strong>wp_enqueue_script(handle, src, deps, ver)</strong></a> is a function for adding Javascripts to a WordPress generated page.  It accepts four parameters:</p>
<p><span style="background-color: #FEF; padding: 5px 5px 5px 10px; display: block; line-height:30px;"><strong>Usage: wp_enqueue_script(handle, src, deps, ver)</strong><br />
<strong><em>handle </em></strong>- (<em>string</em>) Name of the script. Lowercase string.<br />
<strong><em>src</em></strong> - (<em>string</em>) (Optional) Path to the script from the root directory of WordPress. Default is false.<br />
<strong><em>deps</em></strong> - (<em>array</em>) (Optional) Array of handles of any script that this script depends on; scripts that must be loaded before this script.  Default is false.<br />
<strong><em>ver</em></strong> - (<em>string</em>) (Optional) String specifying the script version number, if it has one. Defaults is false.<br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sunnycyk.hk/?feed=rss2&amp;p=107</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress Theme &#8211; bloginfo() and include tags</title>
		<link>http://blog.sunnycyk.hk/?p=91</link>
		<comments>http://blog.sunnycyk.hk/?p=91#comments</comments>
		<pubDate>Thu, 05 Mar 2009 05:49:33 +0000</pubDate>
		<dc:creator>Sunny</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Theme Design]]></category>

		<guid isPermaLink="false">http://blog.sunnycyk.hk/?p=91</guid>
		<description><![CDATA[I am learning Flex and iPhone programming right now, but since I have installed WordPress, so I have decided to learn about how to write WordPress Theme first. (Yea.. I just want to learn everything&#8230;)
This is my very first WordPress Theme.  Very simple, and kinda modified from the default theme which comes with WordPress.  I [...]]]></description>
			<content:encoded><![CDATA[<p>I am learning Flex and iPhone programming right now, but since I have installed WordPress, so I have decided to learn about how to write WordPress Theme first. (Yea.. I just want to learn everything&#8230;)</p>
<p>This is my very first WordPress Theme.  Very simple, and kinda modified from the default theme which comes with WordPress.  I actually have hard time to understand the API and function references from WordPress when I was drafting it at the beginning, but it is kinda straight forward.  It is not completely done, and I may just zip it here when it is completed in the future.</p>
<p><a href="http://blog.sunnycyk.hk/wp-content/uploads/2009/03/picture-1.png"><img class="alignnone size-medium wp-image-92" title="mysmallprogramtheme" src="http://blog.sunnycyk.hk/wp-content/uploads/2009/03/picture-1-300x290.png" alt="mysmallprogramtheme" width="300" height="290" /></a></p>
<p>I am not going to write much detail here, but going to put some references here for myself for future development.</p>
<p><strong>bloginfo() , get_bloginfo()</strong>:<a href="http://codex.wordpress.org/Template_Tags/get_bloginfo"><br />
http://codex.wordpress.org/Template_Tags/get_bloginfo</a></p>
<p><strong>get_header(), get_footer(), get_sidebar(), comments_template()</strong>:<br />
<a href="http://codex.wordpress.org/Include_Tags">http://codex.wordpress.org/Include_Tags</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sunnycyk.hk/?feed=rss2&amp;p=91</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
