<?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>MySandbox</title>
	<atom:link href="http://sandbox.ronggur.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://sandbox.ronggur.com</link>
	<description>Ronggur Hutasuhut Playground</description>
	<lastBuildDate>Mon, 31 Oct 2011 10:39:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>WordPress : How to get category ancestor</title>
		<link>http://sandbox.ronggur.com/2011/10/31/wordpress-how-to-get-category-ancestor/</link>
		<comments>http://sandbox.ronggur.com/2011/10/31/wordpress-how-to-get-category-ancestor/#comments</comments>
		<pubDate>Sun, 30 Oct 2011 17:15:36 +0000</pubDate>
		<dc:creator>ronggur</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://sandbox.ronggur.com/?p=267</guid>
		<description><![CDATA[Here is code I usually use to find ancestor or parent of a category I know this code is premature, it&#8217;s only works when you didn&#8217;t modify the category slug. But at least it is working in almost all my (&#8230;)</p><p><a href="http://sandbox.ronggur.com/2011/10/31/wordpress-how-to-get-category-ancestor/">Read the rest of this entry &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Here is code I usually use to find ancestor or parent of a category</p>
<pre class="brush: php; title: ; notranslate">

function getCategoryAncestor($cat,$index=0){

$parentCatList = get_category_parents($cat,false,',');
$parentCatListArray = @split(&quot;,&quot;,$parentCatList);
$topParentName = $parentCatListArray[$index];
$charReplace = array(&quot; &quot; =&gt; &quot;-&quot;, &quot;(&quot; =&gt; &quot;&quot;, &quot;)&quot; =&gt; &quot;&quot;);
$topParentSlug = strtolower(strtr($topParentName,$charReplace));
$catAncestor['ancestor'] = $topParentName;
$catAncestor['ancestor_slug'] = $topParentSlug;
return $catAncestor;

}

// How to use :
// if you have this category (by term ID) structure : 1 &gt; 2 &gt; 3
// to get ancestor of a category ID 3

$ancestors = getCategoryAncestor(3);

// to get parent of a category ID 3

$ancestors = getCategoryAncestor(3,1);
</pre>
<p>I know this code is premature, it&#8217;s only works when you didn&#8217;t modify the category slug. But at least it is working in almost all my projects :p.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://sandbox.ronggur.com/2011/10/31/wordpress-how-to-get-category-ancestor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress : Custom Action Hook in Action</title>
		<link>http://sandbox.ronggur.com/2011/08/09/wordpress-custom-action-hook-in-action/</link>
		<comments>http://sandbox.ronggur.com/2011/08/09/wordpress-custom-action-hook-in-action/#comments</comments>
		<pubDate>Tue, 09 Aug 2011 12:48:30 +0000</pubDate>
		<dc:creator>ronggur</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Wordpress Plugins]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress plugin]]></category>

		<guid isPermaLink="false">http://sandbox.ronggur.com/?p=253</guid>
		<description><![CDATA[There are two types of hook in WordPress, filter and action. And in this occasion I will try to give examples about Actions hook. According to codex.wordpress.org: Actions: Actions are the hooks that the WordPress core launches at specific points (&#8230;)</p><p><a href="http://sandbox.ronggur.com/2011/08/09/wordpress-custom-action-hook-in-action/">Read the rest of this entry &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>There are two types of hook in WordPress, <a href="http://codex.wordpress.org/Plugin_API#Filters" onclick="pageTracker._trackPageview('/outgoing/codex.wordpress.org/Plugin_API_Filters?referer=');">filter</a> and <a href="http://codex.wordpress.org/Plugin_API#Actions" onclick="pageTracker._trackPageview('/outgoing/codex.wordpress.org/Plugin_API_Actions?referer=');">action</a>. And in this occasion I will try to give examples about Actions hook.</p>
<p>According to codex.wordpress.org:</p>
<p><a title="" href="http://codex.wordpress.org/Plugin_API#Actions" onclick="pageTracker._trackPageview('/outgoing/codex.wordpress.org/Plugin_API_Actions?referer=');">Actions</a>: Actions are the hooks that the WordPress core launches at specific points during execution, or when specific events occur. Your plugin can specify that one or more of its PHP functions are executed at these points, using the Action API.</p>
<p>You can find more complete explanation about this hooks in <a href="http://codex.wordpress.org/Plugin_API" onclick="pageTracker._trackPageview('/outgoing/codex.wordpress.org/Plugin_API?referer=');">http://codex.wordpress.org/Plugin_API</a> and right now I only give simple example to create custom hook that would give us benefit if we want to build wordpress plugin.</p>
<p><span id="more-253"></span></p>
<h3>1. Initialize Our Hook</h3>
<p>You can put this code in any of your plugin files</p>
<pre class="brush: php; title: ; notranslate">
function my_first_hook(){
// initialize hook
do_action('my_act_first_hook');
}
</pre>
<h3>2. Adding Action</h3>
<pre class="brush: php; title: ; notranslate">
function my_first_action(){
echo 'This is my first hook';
}
add_action('my_act_first_hook','my_first_action',5);
</pre>
<p><em><strong>remember</strong></em> : &#8217;5&#8242; at the end of the add_action is priority. 5 mean lower than 4 to execute and the default value is 10</p>
<h3>3. Execute it</h3>
<p>Now, we only need to call our function from the first Step in every your php files</p>
<pre class="brush: php; title: ; notranslate">
my_first_hook();
</pre>
<p>This function will produce</p>
<blockquote><p>This is my first hook</p></blockquote>
<p>That&#8217;s all we&#8217;re finish. <span style="text-decoration: underline;"><em>&#8220;Really? how about if I want to append other text to my hook?&#8221;</em></span>. All you need is only create another function and call it via add_action. Here it is how to do this :</p>
<pre class="brush: php; title: ; notranslate">
function append_another_text(){
echo '. Append new text';
}
add_action('my_act_first_hook','append_another_text',6);
</pre>
<p>Code above will produce</p>
<blockquote><p>This is my first hook. Append new text</p></blockquote>
<p>See the &#8217;6&#8242;? change it to lower number than 5 and your text will appear before the original one. <span style="text-decoration: underline;"><em>&#8220;Cool, But how about if I want to pass argument into this hook?&#8221;</em></span><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px; white-space: normal;">. Good question, all you need is only change your code a bit. here it is</span></p>
<pre class="brush: php; title: ; notranslate">
function my_first_hook($arg){
do_action('my_act_first_hook',$arg);
}
function my_first_action($arg){
echo 'This is my first hook with '.$arg;
}
add_action('my_act_first_hook','my_first_action',5,1);
</pre>
<p><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px; white-space: normal;">and call it to your php files</span></p>
<pre class="brush: php; title: ; notranslate">
my_first_hook('Argument');
</pre>
<p>And the code above should produce</p>
<blockquote><p>This is my first hook with Argument</p></blockquote>
<p>Not too complicated right?.</p>
<p><span style="text-decoration: underline;"><em>&#8220;How about if i want to completely remove the original text and change it with the new one?&#8221;</em></span>.</p>
<p>There is also answer about that one. You only need to call <a href="http://codex.wordpress.org/Function_Reference/remove_action" onclick="pageTracker._trackPageview('/outgoing/codex.wordpress.org/Function_Reference/remove_action?referer=');">remove_action</a>. Here it is how to do this.</p>
<h3>1. Remove previous action</h3>
<pre class="brush: php; title: ; notranslate">
function remove_text(){
	remove_action('my_act_first_hook','my_first_action');
}
add_action('init','remove_text');
</pre>
<h3>2. Create your new brand new function</h3>
<pre class="brush: php; title: ; notranslate">
function brand_new_text_action(){
echo 'Brand new text';
}
add_action('my_act_first_hook','brand_new_text_action');
</pre>
<p>That&#8217;s it, want to see real action in form of plugin? you can download it here <a href="http://sandbox.ronggur.com/wp-content/plugins/download-monitor/download.php?id=10" title="Action Hook in Action">Action Hook in Action</a> | size : 4.75 kB</p>
<p>Thank You, hope this article is usefull for us</p>
]]></content:encoded>
			<wfw:commentRss>http://sandbox.ronggur.com/2011/08/09/wordpress-custom-action-hook-in-action/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Newscoop Contest Design</title>
		<link>http://sandbox.ronggur.com/2011/07/27/newscoop-contest-design/</link>
		<comments>http://sandbox.ronggur.com/2011/07/27/newscoop-contest-design/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 10:48:06 +0000</pubDate>
		<dc:creator>ronggur</dc:creator>
				<category><![CDATA[Contest]]></category>
		<category><![CDATA[contest]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[newscoop]]></category>
		<category><![CDATA[sourcefabric]]></category>

		<guid isPermaLink="false">http://sandbox.ronggur.com/?p=244</guid>
		<description><![CDATA[Newscoop is an open source CMS used by hundreds of independent news organisations to publish content online. Sourcefabric are looking for individuals to create a new theme that brings together quality journalism, with quality design. The prize? A chance to (&#8230;)</p><p><a href="http://sandbox.ronggur.com/2011/07/27/newscoop-contest-design/">Read the rest of this entry &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p><img class="algnleft alignleft" src="http://www.sourcefabric.org/templates/2011/_img/Newscoop_SF_Logo_L_RGB.png" alt="" width="247" height="77" />Newscoop is an open source CMS used by hundreds of independent news organisations to publish content online. Sourcefabric are looking for individuals to create a new theme that brings together quality journalism, with quality design. The prize? A chance to meet media experts and develop their design with an all-expenses paid trip to Sourcecamp Prague 2011.</p>
<p>The contest is looking for designers and developers to invent new ways to display news content, new ways to integrate comments and social media into the user experience, and new ways to adapt site design to mobiles and tablets.</p>
<p>The contest is free to enter and open until October 5th 2011. Interested parties can visit <a href="http://contest.sourcefabric.org/" onclick="pageTracker._trackPageview('/outgoing/contest.sourcefabric.org/?referer=');">http://contest.sourcefabric.org</a> to find out more.</p>
]]></content:encoded>
			<wfw:commentRss>http://sandbox.ronggur.com/2011/07/27/newscoop-contest-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RH Yahoo! Messenger WordPress Plugin</title>
		<link>http://sandbox.ronggur.com/2011/05/24/rh-yahoo-messenger-wordpress-plugin/</link>
		<comments>http://sandbox.ronggur.com/2011/05/24/rh-yahoo-messenger-wordpress-plugin/#comments</comments>
		<pubDate>Tue, 24 May 2011 06:16:45 +0000</pubDate>
		<dc:creator>ronggur</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Wordpress Plugins]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress plugin]]></category>

		<guid isPermaLink="false">http://sandbox.ronggur.com/?p=231</guid>
		<description><![CDATA[Hi, there. In this post I want to introduce my first WordPress plugin . This plugin is a widget plugin that will shows multiple Yahoo! Messenger Status of your own. So here it is.. Installation The plugin is simple to (&#8230;)</p><p><a href="http://sandbox.ronggur.com/2011/05/24/rh-yahoo-messenger-wordpress-plugin/">Read the rest of this entry &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Hi, there. In this post I want to introduce my first WordPress plugin <img src='http://sandbox.ronggur.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . This plugin is a widget plugin that will shows multiple Yahoo! Messenger Status of your own. So here it is..</p>
<h3>Installation</h3>
<p>The plugin is simple to use:</p>
<p>1. Download `rh-ym-status.zip` you can download here <a href="http://sandbox.ronggur.com/wp-content/plugins/download-monitor/download.php?id=9" title="RH Yahoo! Messenger Status WP Plugin">RH Yahoo! Messenger Status WP Plugin</a> | size : 66.22 kB<br />
2. Unzip<br />
3. Upload `rh-ym-status` directory to your `/wp-content/plugins` directory<br />
4. Enable the plugin via plugin managament page<br />
5. Go to widget area and fill your Yahoo Name(s) and Yahoo ID(s) to show your Yahoo! Messenger status in widget area</p>
<p><span id="more-231"></span></p>
<h3>Screen Shot</h3>
<p><a href="http://sandbox.ronggur.com/wp-content/uploads/2011/05/screenshoot.png"><img class="alignnone size-medium wp-image-237" title="screenshot" src="http://sandbox.ronggur.com/wp-content/uploads/2011/05/screenshoot-300x283.png" alt="" width="300" height="283" /></a></p>
<h3>Download</h3>
<a href="http://sandbox.ronggur.com/wp-content/plugins/download-monitor/download.php?id=9" title="RH Yahoo! Messenger Status WP Plugin">RH Yahoo! Messenger Status WP Plugin</a> | size : 66.22 kB
<p>For bugs reporting, please send your email to wp.plugins@ronggur.com. And feel free to leave any comments <img src='http://sandbox.ronggur.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://sandbox.ronggur.com/2011/05/24/rh-yahoo-messenger-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WordPress : Get page permalink by name, slug or title outside loop</title>
		<link>http://sandbox.ronggur.com/2011/04/19/wordpressget-page-permalink-by-name-title-outside-loop/</link>
		<comments>http://sandbox.ronggur.com/2011/04/19/wordpressget-page-permalink-by-name-title-outside-loop/#comments</comments>
		<pubDate>Tue, 19 Apr 2011 08:07:14 +0000</pubDate>
		<dc:creator>ronggur</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[jquery tutorial]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[Wordpress Themes]]></category>

		<guid isPermaLink="false">http://sandbox.ronggur.com/?p=217</guid>
		<description><![CDATA[I know we have get_permalink() in WordPress to get permalink by id of specific page. So this post is only alternative how to get the permalink by name, slug or title. 1. Get Page ID by name, slug or title (&#8230;)</p><p><a href="http://sandbox.ronggur.com/2011/04/19/wordpressget-page-permalink-by-name-title-outside-loop/">Read the rest of this entry &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>I know we have <a href="http://codex.wordpress.org/Function_Reference/get_permalink" onclick="pageTracker._trackPageview('/outgoing/codex.wordpress.org/Function_Reference/get_permalink?referer=');">get_permalink()</a> in WordPress to get permalink by id of specific page. So this post is only alternative how to get the permalink by name, slug or title.</p>
<h4>1. Get Page ID by name, slug or title</h4>
<pre class="brush: php; title: ; notranslate">
&lt;?php
function rh_get_page_id($name)
{
global $wpdb;
// get page id using custom query
$page_id = $wpdb-&gt;get_var(&quot;SELECT ID FROM $wpdb-&gt;posts WHERE ( post_name = '&quot;.$name.&quot;' or post_title = '&quot;.$name.&quot;' ) and post_status = 'publish' and post_type='page' &quot;);
return $page_id;
}
?&gt;
</pre>
<p><span id="more-217"></span></p>
<h4>2. Get Page Permalink by name, slug or title</h4>
<pre class="brush: php; title: ; notranslate">
&lt;?php
function rh_get_page_permalink($name)
{
$page_id = rh_get_pageid($name);
return get_permalink($page_id);
}
?&gt;
</pre>
<h4>3. How To Use</h4>
<pre class="brush: php; title: ; notranslate">
&lt;?php
// get by title
echo rh_get_page_permalink('Your Page Name');
// get by name or slug
echo rh_get_page_permalink('your-page-name');
?&gt;
</pre>
<p>Enjoy.. I hope it useful and works for you <img src='http://sandbox.ronggur.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div id="_mcePaste" class="mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;">http://codex.wordpress.org/Function_Reference/get_permalinkget</div>
]]></content:encoded>
			<wfw:commentRss>http://sandbox.ronggur.com/2011/04/19/wordpressget-page-permalink-by-name-title-outside-loop/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>WPTrick : Add new element into wp menu</title>
		<link>http://sandbox.ronggur.com/2011/01/09/wptrick-add-new-element-into-wp-menu/</link>
		<comments>http://sandbox.ronggur.com/2011/01/09/wptrick-add-new-element-into-wp-menu/#comments</comments>
		<pubDate>Sun, 09 Jan 2011 02:17:54 +0000</pubDate>
		<dc:creator>ronggur</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[featured]]></category>

		<guid isPermaLink="false">http://sandbox.ronggur.com/?p=209</guid>
		<description><![CDATA[A simple trick to add new element into your wp menu.In this case I want to add custom search form to may Just add this codes to your wp code I usually put in in functions.php Method above will add (&#8230;)</p><p><a href="http://sandbox.ronggur.com/2011/01/09/wptrick-add-new-element-into-wp-menu/">Read the rest of this entry &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>A simple trick to add new element into your wp menu.In this case I want to add custom search form to may</p>
<p>Just add this codes to your wp code I usually put in in functions.php</p>
<pre class="brush: php; title: ; notranslate">

&lt;?php

// Filter wp_nav_menu() to add additional links and other output
function custom_nav_menu_items($items, $args) {

 $search = '&lt;li id=&quot;search&quot;&gt;';
 $search .= custom_searchform();
 $search .= '&lt;/li&gt;';
 $items = $items .$search;

return $items;
}
add_filter( 'wp_nav_menu_items', 'custom_nav_menu_items', 10, 2 );

function custom_searchform(){
 $search = get_search_query();
 if($search) $search_text = $search;
 else $search_text = &quot;Search&quot;;

 $form = '&lt;form method=&quot;get&quot; id=&quot;searchform&quot;  action=&quot;'.get_bloginfo('home').'&quot;&gt;';
 $form .= '&lt;fieldset&gt;';
 $form .= '&lt;input type=&quot;text&quot; value=&quot;'.$search_text.'&quot;  name=&quot;s&quot; id=&quot;s&quot;  /&gt;';
 $form .= '&lt;input type=&quot;hidden&quot; id=&quot;searchsubmit&quot; /&gt;';
 $form .= '&lt;/fieldset&gt;';
 $form .= '&lt;/form&gt;';

 return $form;
}

?&gt;
</pre>
<p>Method above will add search form to all wp menu. So how about if I only want to add to specific menu location?</p>
<p>Here we goes</p>
<pre class="brush: php; title: ; notranslate">

&lt;?php

# apply only ini 'header-menu' location

if($args-&gt;theme_location == 'header-menu'){
 $search = '&lt;li id=&quot;search&quot;&gt;';
 $search .= rh_searchform();
 $search .= '&lt;/li&gt;';
 $items = $items .$search;
 }

?&gt;
</pre>
<p>Finish,<br />
-rmh-</p>
]]></content:encoded>
			<wfw:commentRss>http://sandbox.ronggur.com/2011/01/09/wptrick-add-new-element-into-wp-menu/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>quote of the day</title>
		<link>http://sandbox.ronggur.com/2010/09/14/quote-of-the-day/</link>
		<comments>http://sandbox.ronggur.com/2010/09/14/quote-of-the-day/#comments</comments>
		<pubDate>Mon, 13 Sep 2010 22:44:39 +0000</pubDate>
		<dc:creator>ronggur</dc:creator>
				<category><![CDATA[Just Saying]]></category>

		<guid isPermaLink="false">http://sandbox.ronggur.com/?p=206</guid>
		<description><![CDATA[quote of the day : wordpress makes your life seem easier]]></description>
			<content:encoded><![CDATA[<p>quote of the day :</p>
<blockquote><p>wordpress makes your life seem easier</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://sandbox.ronggur.com/2010/09/14/quote-of-the-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Capturing it</title>
		<link>http://sandbox.ronggur.com/2010/04/15/capturing-it/</link>
		<comments>http://sandbox.ronggur.com/2010/04/15/capturing-it/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 08:53:21 +0000</pubDate>
		<dc:creator>ronggur</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://sandbox.ronggur.com/?p=203</guid>
		<description><![CDATA[Let me introduce my new photoblog http://shoot.ronggur.com . New hobby and of course need new extra time :p. Still and always need more knowledge about this new hobby. Enjoy..]]></description>
			<content:encoded><![CDATA[<p>Let me introduce my new photoblog <a href="http://shoot.ronggur.com" onclick="pageTracker._trackPageview('/outgoing/shoot.ronggur.com?referer=');">http://shoot.ronggur.com</a> <img src='http://sandbox.ronggur.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . New hobby and of course need new extra time :p. Still and always need more knowledge about this new hobby.</p>
<p>Enjoy..</p>
]]></content:encoded>
			<wfw:commentRss>http://sandbox.ronggur.com/2010/04/15/capturing-it/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Houston, We&#8217;ve Got a Problem</title>
		<link>http://sandbox.ronggur.com/2010/02/02/houston-weve-got-a-problem/</link>
		<comments>http://sandbox.ronggur.com/2010/02/02/houston-weve-got-a-problem/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 08:00:50 +0000</pubDate>
		<dc:creator>ronggur</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://sandbox.ronggur.com/?p=196</guid>
		<description><![CDATA[Last nite i found my blog down for several hours, i don&#8217;t know what happened and now it&#8217;s up again but unfortunately there are some comments lost (sorry). But it&#8217;s okay since i&#8217;, not losing the whole database images taken (&#8230;)</p><p><a href="http://sandbox.ronggur.com/2010/02/02/houston-weve-got-a-problem/">Read the rest of this entry &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<div id="attachment_197" class="wp-caption alignleft" style="width: 301px"><a href="http://sandbox.ronggur.com/wp-content/uploads/2010/02/moon.jpg"><img class="size-medium wp-image-197" title="moon" src="http://sandbox.ronggur.com/wp-content/uploads/2010/02/moon-291x300.jpg" alt="houston we've got problem" width="291" height="300" /></a><p class="wp-caption-text">houston we&#39;ve got problem</p></div>
<p>Last nite i found my blog down for several hours, i don&#8217;t know what happened and now it&#8217;s up again but unfortunately there are some comments lost (sorry). But it&#8217;s okay since i&#8217;, not losing the whole database</p>
<p>images taken from <a href="http://nopicturenostory.com/the_cartoon_parade/michel_rilhac/groney/bin/images/large/moon.jpg" onclick="pageTracker._trackPageview('/outgoing/nopicturenostory.com/the_cartoon_parade/michel_rilhac/groney/bin/images/large/moon.jpg?referer=');">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sandbox.ronggur.com/2010/02/02/houston-weve-got-a-problem/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery Tutorial : Simple ajax star rating with php (extended)</title>
		<link>http://sandbox.ronggur.com/2010/01/19/jquery-tutorial-simple-ajax-star-rating-with-php-extended/</link>
		<comments>http://sandbox.ronggur.com/2010/01/19/jquery-tutorial-simple-ajax-star-rating-with-php-extended/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 23:32:41 +0000</pubDate>
		<dc:creator>ronggur</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery tutorial]]></category>

		<guid isPermaLink="false">http://sandbox.ronggur.com/?p=186</guid>
		<description><![CDATA[Some people ask me question about how to implement my last star rating in multiple star rating, and here is the answer on how to implement it. 1. Upgrade latest table Since you&#8217;ll need to add &#8216;id&#8217; on multiple record (&#8230;)</p><p><a href="http://sandbox.ronggur.com/2010/01/19/jquery-tutorial-simple-ajax-star-rating-with-php-extended/">Read the rest of this entry &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Some people ask me question about how to implement my <a title="simple ajax star rating with php" href="http://sandbox.ronggur.com/2009/05/30/jquery-tutorial-simple-ajax-star-rating-with-php">last star rating</a> in multiple star rating, and here is the answer on how to implement it.</p>
<h3>1. Upgrade latest table</h3>
<p>Since you&#8217;ll need to add &#8216;id&#8217; on multiple record then we need to upgrade the existing table. Here is the full sql</p>
<pre class="brush: sql; title: ; notranslate">
CREATE TABLE IF NOT EXISTS `vote` (
 `id` int(11) NOT NULL auto_increment,
 `desc` varchar(50) NOT NULL,
 `counter` int(8) NOT NULL default '0',
 `value` int(8) NOT NULL default '0',
 PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--
-- Dumping data for table `vote`
--

INSERT INTO `vote` (`id`, `desc`, `counter`, `value`) VALUES
(1, 'star - 1', 0, 0),
(2, 'star - 2', 0,0);
</pre>
<h3>2. CSS</h3>
<p>We still can stylesheet from the previous post. No need to modify it.</p>
<p><span id="more-186"></span></p>
<h3>3. PHP files (index.php &amp; update.php)</h3>
<p>There are some code changes in this files. If in previous post we just need an html file to represent the star rating, now we need php file to do it. Here is full code for <em>index.php</em> and some simple code explanation in it</p>
<pre class="brush: php; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; /&gt;
&lt;title&gt;jQuery Tutorial : Simple ajax star rating&lt;/title&gt;
&lt;meta name=&quot;Keywords&quot; content=&quot;Star rating, jQuery, ajax&quot;&gt;
&lt;meta name=&quot;Description&quot; content=&quot;jQuery Tutorial : Simple ajax star rating&quot;&gt;
&lt;meta http-equiv=&quot;Content-Language&quot; content=&quot;en&quot;&gt;
&lt;meta name=&quot;robots&quot; content=&quot;index,follow&quot;&gt;
&lt;script src=&quot;rating/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;rating/starrating.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;link href=&quot;rating/starrating.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;?php
// include update.php
include_once 'update.php';
// get all data from tabel
$arr_star = fetchStar();
?&gt;
&lt;?php
// start looping datas
foreach($arr_star as $star){ ?&gt;
&lt;h2&gt;Star Rater - &lt;?php echo $star['id'];?&gt;&lt;/h2&gt;
&lt;ul class='star-rating' id=&quot;star-rating-&lt;?php echo $star['id'];?&gt;&quot;&gt;
&lt;?php /* getRating($id) is to generate current rating */?&gt;
 &lt;li id=&quot;current-rating-&lt;?php echo $star['id'];?&gt;&quot; style=&quot;width:&lt;?php echo getRating($star['id'])?&gt;%&quot;&gt;&lt;!-- will show current rating --&gt;&lt;/li&gt;
 &lt;?php
 /* we need to generate 'id' for star rating.. this 'id' will identify which data to execute  */
 /* we will pass it in ajax later */
 ?&gt;
 &lt;span id=&quot;&lt;?php echo $star['id'];?&gt;&quot;&gt;
 &lt;li&gt;&lt;a href=&quot;javascript:void(0)&quot; title=&quot;1 star out of 5&quot;&gt;1&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href=&quot;javascript:void(0)&quot; title=&quot;2 stars out of 5&quot;&gt;2&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href=&quot;javascript:void(0)&quot; title=&quot;3 stars out of 5&quot;&gt;3&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href=&quot;javascript:void(0)&quot; title=&quot;4 stars out of 5&quot;&gt;4&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href=&quot;javascript:void(0)&quot; title=&quot;5 stars out of 5&quot;&gt;5&lt;/a&gt;&lt;/li&gt;
 &lt;/span&gt;
&lt;/ul&gt;
&lt;?php } ?&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>And this is for <em>update.php</em></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
// connect to database
$dbh=mysql_connect (&quot;localhost&quot;, &quot;user&quot;, &quot;password&quot;) or die ('Cannot connect to the database');
mysql_select_db (&quot;database&quot;,$dbh);

if($_GET['do']=='rate'){
 // do rate and get id
 rate($_GET['id']);
}else if($_GET['do']=='getrate'){
 // get rating and get id
 getRating($_GET['id']);
}

// get data from tabel
function fetchStar(){
 $sql = &quot;select * from `vote`&quot;;
 $result=@mysql_query($sql);
 while($rs = @mysql_fetch_array($result,MYSQL_ASSOC)){
 $arr_data[] = $rs;
 }
 return $arr_data;
}

// function to retrieve
function getRating($id){
 $sql= &quot;select * from vote`` where id='&quot;.$id.&quot;' &quot;;
 $result=@mysql_query($sql);
 $rs=@mysql_fetch_array($result);
 // set width of star
 $rating = (@round($rs[value] / $rs[counter],1)) * 20;
 echo $rating;
}

// function to insert rating
function rate($id){
 $text = strip_tags($_GET['rating']);
 $update = &quot;update `vote` set counter = counter + 1, value = value + &quot;.$_GET['rating'].&quot;  where id='&quot;.$id.&quot;' &quot;;

 $result = @mysql_query($update);
}
?&gt;
</pre>
<h3>4. Javascript</h3>
<pre class="brush: jscript; title: ; notranslate">
// JavaScript Document
 $(document).ready(function() {
 // get rating function
 function getRating(id){
 $.ajax({
 type: &quot;GET&quot;,
 url: &quot;update.php&quot;,
 data: &quot;do=getrate&amp;id=&quot;+id,
 cache: false,
 async: false,
 success: function(result) {
 // apply star rating to element
 $(&quot;#current-rating-&quot;+id+&quot;&quot;).css({ width: &quot;&quot; + result + &quot;%&quot; });
 },
 error: function(result) {
 alert(&quot;some error occured, please try again later&quot;);
 }
 });
 }

 // link handler
 $('.ratelinks li a').click(function(){
 // get the parent id
 var idStar = $(this).parent().parent().attr('id');
 $.ajax({
 type: &quot;GET&quot;,
 url: &quot;update.php&quot;,
 data: &quot;rating=&quot;+$(this).text()+&quot;&amp;do=rate&amp;id=&quot;+idStar,
 cache: false,
 async: false,
 success: function(result) {
 // remove #ratelinks element to prevent another rate
 $(&quot;#ratelinks&quot;).remove();
 // get rating after click
 getRating(idStar);
 },
 error: function(result) {
 alert(&quot;some error occured, please try again later&quot;);
 }
 });

 });
 });
</pre>
<p>That&#8217;s it! hope it works for you <img src='http://sandbox.ronggur.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . You can add some modification like notification, or loader while processing.</p>
<p>- <a title="Simple star rating" href="http://dock.ronggur.com/tutorial/jquery_tutorial_starrating_extended/" onclick="pageTracker._trackPageview('/outgoing/dock.ronggur.com/tutorial/jquery_tutorial_starrating_extended/?referer=');">View Demo</a></p>
<p>- Download zip file <a class="downloadlink" href="http://sandbox.ronggur.com/wp-content/plugins/download-monitor/download.php?id=8" title=" downloaded 1086 times" >jQuery Tutorial : Simple ajax star rating with php (extended) (1086)</a></p>
<p class="buymebeer"><form action="https://www.paypal.com/cgi-bin/webscr" target="paypal" method="post"><input type="hidden" name="cmd" value="_xclick" /><input type="hidden" name="business" value="ronggur.mh@gmail.com" /><input type="hidden" name="return" value="Thank you for your kindness :D" /><input type="hidden" name="item_name" value="Buy Me a Beer for jQuery Tutorial : Simple ajax star rating with php (extended)" /><input type="hidden" name="currency_code" value="USD" /><input type="hidden" name="amount" value="" /><input type="image" src="http://sandbox.ronggur.com/wp-content/plugins/buy-me-beer/icon_cafe.gif" align="left" alt="coffee" title="coffee" hspace="3" /></form><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amp;business=ronggur.mh@gmail.com&amp;currency_code=USD&amp;amount=&amp;return=Thank you for your kindness :D&amp;item_name=Buy+Me+a+Beer+for+jQuery+Tutorial+:+Simple+ajax+star+rating+with+php+(extended)" target="paypal" onclick="pageTracker._trackPageview('/outgoing/www.paypal.com/cgi-bin/webscr?cmd=_xclick_amp_business=ronggur.mh_gmail.com_amp_currency_code=USD_amp_amount=_amp_return=Thank_you_for_your_kindness_D_amp_item_name=Buy+Me+a+Beer+for+jQuery+Tutorial+_+Simple+ajax+star+rating+with+php+_extended&amp;referer=');">You can give me some coffee if you want to :D</a></p>]]></content:encoded>
			<wfw:commentRss>http://sandbox.ronggur.com/2010/01/19/jquery-tutorial-simple-ajax-star-rating-with-php-extended/feed/</wfw:commentRss>
		<slash:comments>34</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: sandbox.ronggur.com @ 2012-02-04 22:11:56 -->
