<?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>AwesomeTopic &#187; StatPress Plugin</title>
	<atom:link href="http://www.awesometopic.com/tag/statpress-plugin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.awesometopic.com</link>
	<description>is designed to display CSS, XHTML, and JavaScript work and offers ideas on how to solve similar challenges.</description>
	<lastBuildDate>Mon, 16 Aug 2010 22:27:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Sierra Club Green Home</title>
		<link>http://www.awesometopic.com/work/coming-soon-sierra-club-green-home/</link>
		<comments>http://www.awesometopic.com/work/coming-soon-sierra-club-green-home/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 03:16:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[Carousel.js]]></category>
		<category><![CDATA[OpenX]]></category>
		<category><![CDATA[Organizer Plugin]]></category>
		<category><![CDATA[Search Reloaded Plugin]]></category>
		<category><![CDATA[ShareThis Plugin]]></category>
		<category><![CDATA[Similar Posts Plugin]]></category>
		<category><![CDATA[StatPress Plugin]]></category>
		<category><![CDATA[SuperSleight PNG fix]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP-Polls Plugin]]></category>

		<guid isPermaLink="false">http://www.awesometopic.com/blog/?p=47</guid>
		<description><![CDATA[This site includes zones to manage content, track advertising campaigns, and handle member logins.
The content management is built with WordPress and utilizes several plugins to maximize functionality for the site&#8217;s users and for those maintaining the content. The administrator can add polls, view site statistics, write articles, and direct users to related information. The WordPress [...]]]></description>
			<content:encoded><![CDATA[<p>This site includes zones to manage content, track advertising campaigns, and handle member logins.<span id="more-47"></span></p>
<p>The content management is built with WordPress and utilizes several plugins to maximize functionality for the site&#8217;s users and for those maintaining the content. The administrator can add polls, view site statistics, write articles, and direct users to related information. The WordPress Cross Linker plugin was modified to display a tool tip with a word&#8217;s definition to help keep readers informed.</p>
<p>The ads are served through <a title="OpenX" href="http://www.openx.org/">OpenX</a> and run on JavaScript invocation codes that are included in the sidebar. The administrator can start ad campaigns, upload images, and place ads in very targeted locations on the site.</p>
<p>Registration is handled separately, and managed through a customized admin panel. Once a user logs in, they can search for providers of green products and services in their area, view vendor profiles, post on the bulletin board, and participate in quizzes to test the health of their home and their Carbon Dioxide emissions.</p>
<p>One of the biggest challenges was handling the drop down menus, which open on click and close when users click outside of the menu. Additionally, the largest drop down contains three floated lists that hold subcategories of the &#8220;Educate&#8221; category and their respective articles. Creating this list required a custom query to the WordPress database. The PHP for this query and the JavaScript for the button events is below.</p>
<h5>PHP</h5>
<pre>//connect to WP DB
$om_con = mysql_connect(DB_HOST, DB_USER,DB_PASSWORD);
$om_db = mysql_select_db(DB_NAME,$om_con); 

// FOR every <strong>term_id</strong> in <strong>wp_term_taxonomy</strong> WHERE parent = 10
  		// compare <strong>term_id</strong> in <strong>wp_term_taxonomy</strong> to <strong>term_id</strong> in <strong>wp_terms</strong>
		// FOR every alignment:
			// build up an array of subcategories with <strong>name</strong> in <strong>wp_terms</strong>
			// compare <strong>term_id</strong> in <strong>wp_terms</strong> to <strong>term_taxonomy_id</strong> in <strong>wp_terms_relationships</strong> 

					// compare <strong>term_id</strong> in <strong>wp_terms</strong> to <strong>term_taxonomy_id</strong> in <strong>wp_terms_relationships</strong>
					// FOR every alignment:
$sql = " SELECT  wp.ID, wt.name, wp.post_title, wp.guid FROM wp_term_taxonomy AS wtt
		LEFT JOIN wp_terms AS wt ON (wtt.term_id = wt.term_id)
		LEFT JOIN wp_term_relationships AS wtr ON (wt.term_id = wtr.term_taxonomy_id)
		LEFT JOIN wp_posts AS wp ON (wtr.object_id = wp.ID)
		WHERE wtt.parent = '10'
		ORDER BY wt.name ASC, wp.post_date ASC ";  //ORDER BY category alphabetically, subcategory alphabetically, and post date

//hold the result
$res = mysql_query($sql, $om_con) or die( mysql_error() );

//count the number of rows in the result
//(so we can split it up into 3)
$numRows = mysql_num_rows($res);

//instantiate variables for the loop
$sub_cat_name = '';
$rowcount = 0;
$doonce = true;
$thirdsCounte = 1;
$dosecondpass = true;

//while we still have rows in the result
while( $row = mysql_fetch_assoc($res) ) {
	//increase the row counter
	$rowcount++;

	//each row represents a subcategory of the bigger wp category "Educate"
	//if it is the next subcat...
	if ($sub_cat_name != $row['name']) {
		//put the name of the subcategory in the variable
		$sub_cat_name = $row['name'];

		//if the row number you are on is still less than the total number of rows divided by 3
		//AND if we have not already done this once...
		if( ( ($numRows/3) &lt; $rowcount ) &amp;&amp; $doonce ) {
			//reset the variable so we do not repeat this
			$doonce = false;

			//build a variable that will end the left list and start the center list
			$msg .= "\t\t&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;
&lt;ul class=\"clearfix third_width_list\"&gt;
	&lt;li&gt;". $sub_cat_name."
		&lt;ul &gt;\n";

		}//end else if you're in the first column

		else if( (( 2*($numRows/3)) &lt; $rowcount) &amp;&amp; $dosecondpass ) {
			//reset the variable so we do not repeat this
			$dosecondpass = false;

			//build a variable that will end the center list and start the right side list
			$msg .= "\t\t&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;
&lt;ul class=\"clearfix third_width_list\"&gt;
	&lt;li&gt;". $sub_cat_name."
		&lt;ul &gt;\n";

		}//end else if you're in the second column

		else {
			//else, if you are starting a new subcategory, end the preceding subcategory and start the next
			$msg .= "&lt;/ul&gt;
	&lt;/li&gt;

	&lt;li&gt;". $sub_cat_name."
		&lt;ul&gt;\n";

		}//end else if you're in the third column 

	}//end if it IS a new subcat

	//else, if it is NOT a new subcategory, then it must be the articles within the subcats
	//add to the output variable to print the link to each article
	$stringWithoutAmps = str_replace("&amp;", "&amp;", $row['post_title']);

	$msg .= "\t\t\t&lt;li&gt;&lt;a href='".get_permalink($row['ID'])."' title='".$stringWithoutAmps ."' &gt;".$stringWithoutAmps."&lt;/a&gt;&lt;/li&gt;\n";

	}//end else if it is NOT a new subcat

//the very first subcategory will not need to have this stuff, since there was nothing above it
$msg = ltrim($msg, "\t&lt;/li&gt;
&lt;/ul&gt;");

//echo the stuff that starts the ball rolling
echo "&lt;ul class=\"clearfix third_width_list\"&gt;
	&lt;li&gt;";
//print out the message
echo $msg;
//print out important closing tags
echo "&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;";</pre>
<h5>JavaScript</h5>
<pre>//using the Mootools domready event
window.addEvent('domready', function() {

    //GLOBAL CLICK EVENT
    document.addEvent('click', function(e){

		//any time you click the page, the educate drop down will close
        document.getElementById('triple').style.visibility='hidden';

    });
    //capture events
    if (document.captureEvents) document.captureEvents(Event.CLICK);

    //BUTTON CLICK EVENT
    $('nav_educate').addEvent('click', function(e){
        //prevent bubbling up to the global click event
        if (!e) var e = window.event;
        e.cancelBubble = true;
        if (e.stopPropagation) e.stopPropagation();

        //show the educate dropdown menu
        document.getElementById('triple').style.visibility='visible';

    });

});</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.awesometopic.com/work/coming-soon-sierra-club-green-home/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
