<?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>Cozmoslabs &#187; hack</title>
	<atom:link href="http://www.cozmoslabs.com/tag/hack/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cozmoslabs.com</link>
	<description>Web design and development experiment.</description>
	<lastBuildDate>Thu, 01 Jul 2010 09:26:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>WP Greet Box, my Design and Thematic &#8211; The Good, the Bad and the Ugly</title>
		<link>http://www.cozmoslabs.com/2008/09/19/wp-greet-box-my-design-and-thematic-the-good-the-bad-and-the-ugly/</link>
		<comments>http://www.cozmoslabs.com/2008/09/19/wp-greet-box-my-design-and-thematic-the-good-the-bad-and-the-ugly/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 23:54:47 +0000</pubDate>
		<dc:creator>Cristian</dc:creator>
				<category><![CDATA[Theme Design]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[child theme]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[Thematic]]></category>

		<guid isPermaLink="false">http://www.cozmoslabs.com/?p=111</guid>
		<description><![CDATA[Photo by StevenM_61 First of all the reason: most of my trafic comes from StumbleUpon. With that in mind I decided that it would be a really good way to promote my blog by nicely asking visitors that came from Stumble to give me a thumb up if they like the article (the all &#8220;ask [...]


Related posts:<ol><li><a href='http://www.cozmoslabs.com/2009/10/28/create-an-about-the-author-area-for-thematic/' rel='bookmark' title='Permanent Link: Create an &#8220;About the author&#8221; area for Thematic'>Create an &#8220;About the author&#8221; area for Thematic</a></li>
<li><a href='http://www.cozmoslabs.com/2009/06/26/thematic-featured-posts/' rel='bookmark' title='Permanent Link: Add &#8220;Featured Posts&#8221; to your Thematic child theme'>Add &#8220;Featured Posts&#8221; to your Thematic child theme</a></li>
<li><a href='http://www.cozmoslabs.com/2008/08/11/10-design-tips-for-your-custom-wordpress-theme-built-with-thematic/' rel='bookmark' title='Permanent Link: 10 design tips for your custom wordpress theme built with thematic'>10 design tips for your custom wordpress theme built with thematic</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="postimage"><img class="alignnone size-medium wp-image-114" title="western" src="http://www.cozmoslabs.com/wp-content/uploads/2008/09/western-300x225.jpg" alt="" width="300" height="225" /></p>
<p>Photo by <a href="http://www.flickr.com/photos/stevenm_61/380238429/">StevenM_61</a></p>
</div>
<p><strong>First of all the reason:</strong> most of my trafic comes from <a href="http://www.stumbleupon.com/">StumbleUpon</a>. With that in mind I decided that it would be a really good way to promote my blog by nicely asking visitors that came from Stumble to give me a thumb up if they like the article (the all &#8220;ask and you will be given&#8221; mentality). The ideea came from stumbling on a post from Smashing Magazine which nicely asked for my &#8220;Thumb Up&#8221;.</p>
<p>Initially I thought that it would be even cooler to actually develop a plugin for WordPress that did just that&#8230;  Of course after 5 minutes or so of brainstorming about the technical problems of this, I realized that this was WordPress and someone must have already developed such a useful plugin. After a quick search in the plugin directory on wordpress.org I found <strong>THE GOOD</strong> <a href="http://wordpress.org/extend/plugins/wp-greet-box/">WP Greet Box</a>.<span id="more-111"></span></p>
<h3>The Good &#8211; WP Greet Box</h3>
<p>This plugin lets you show a different greeting message to your new visitors depending on their referrer url.  For example, when a Digg user clicks through from Digg, they will see a message reminding them to digg your post if they like it.  Another example, when a visitor clicks through from Twitter, they will see a message suggesting them to twit the post and follow you on Twitter. You can also set a default greeting message for new visitors (not matching any referrer URLs) suggesting them to subscribe to your RSS feed.  Having these targeted suggestions will help your blog increase exposure and loyal readership. Best of all, this plugin is compatible with various WordPress cache plugins so you do not have to sacrifice speed.</p>
<p>Currently the following referrers are installed by default, but you can easily create your own if your favorite referrer is not on the list!</p>
<ul>
<li>del.icio.us</li>
<li>digg.com</li>
<li>google.com</li>
<li>yahoo.com</li>
<li>stumbleupon.com</li>
<li>technorati.com</li>
<li>twitter.com</li>
</ul>
<h3>The Bad &#8211; My Design</h3>
<p>Why is that? Well&#8230; It has to do with  the fact that my theme is a Child Theme, based on Thematic, so it has all the bells and whistles Thematic has&#8230; So why is it the bad&#8230; simple actually&#8230; I have to add <em>wp_greet_box(); </em>inside my theme to load the message.</p>
<p>Thematic give you the option to add below the header and above the footer using <em>functions.php</em> file (more info over at <a href="http://themeshaper.com/custom-wordpress-hooks-filters-thematic-06/">Thematic</a>). That being said if I add the greet message below my header (so it is visible by my visitors) my right-side navigation would just move down&#8230; because of the way Thematic&#8217;s HTML is built. There&#8217;s nothing wrong with this of course , just that I created the design with the side bar stuck to my header so using this plugin like this in a way brakes my design.</p>
<h3>The Ugly &#8211; Finding a workaround using <em>functions.php</em> in my Thematic Child Theme</h3>
<p>To make things strait: <strong>THEMATIC IS NOT THE BAD</strong>. My workaround is <img src='http://www.cozmoslabs.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  .</p>
<p>The obvious solution was to post my greet just before of my FIRST Post Title (I&#8217;ll get back to the &#8220;first&#8221; part).</p>
<p>To do this I&#8217;ve used Thematic&#8217;s <em>thematic_postheader</em> custom hook. Since this is used for displaying the title and author data in every post I couldn&#8217;t just put <em>add_filter( &#8216;thematic_postheader&#8217;, &#8216;greet_box&#8217; );</em> in my <em>functions.php</em> and create a simple function with <em>wp_greet_box(); </em>inside because that would just delete my titles&#8230;( I mean not displaying them ).</p>
<p>So I&#8217;ve copy-pasted the code from inside <em>themes/thematic/library/functions/hooks-filters.php </em>that is related to <em>thematic_postheader</em> hook inside my greet_box() function and made a small modification &#8211; code and comments below:</p>
<pre class="brush: php;">

function greet_box(){

//this is the original code from the hooks-filters.php file

global $post, $authordata;

if (is_single() || is_page()) {
$posttitle = '&lt;h1 class=&quot;entry-title&quot;&gt;' . get_the_title() . &quot;&lt;/h1&gt;\n&quot;;
} elseif (is_404()) {
$posttitle = '&lt;h1 class=&quot;entry-title&quot;&gt;' . __('Not Found', 'thematic') . &quot;&lt;/h1&gt;\n&quot;;
} else {
$posttitle = '&lt;h2 class=&quot;entry-title&quot;&gt;&lt;a href=&quot;';
$posttitle .= get_permalink();
$posttitle .= '&quot; title=&quot;';
$posttitle .= __('Permalink to ', 'thematic') . the_title_attribute('echo=0');
$posttitle .= '&quot; rel=&quot;bookmark&quot;&gt;';
$posttitle .= get_the_title();
$posttitle .= &quot;&lt;/a&gt;&lt;/h2&gt;\n&quot;;
}

$postmeta = '&lt;div class=&quot;entry-meta&quot;&gt;';
$postmeta .= '&lt;span class=&quot;author vcard&quot;&gt;';
$postmeta .= __('By ', 'thematic') . '&lt;a class=&quot;url fn n&quot; href=&quot;';
$postmeta .= get_author_link(false, $authordata-&gt;ID, $authordata-&gt;user_nicename);
$postmeta .= '&quot; title=&quot;' . __('View all posts by ', 'thematic') . get_the_author() . '&quot;&gt;';
$postmeta .= get_the_author();
$postmeta .= '&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;meta-sep&quot;&gt; | &lt;/span&gt;';
$postmeta .= '&lt;span class=&quot;entry-date&quot;&gt;&lt;abbr class=&quot;published&quot; title=&quot;';
$postmeta .= get_the_time('Y-m-d\TH:i:sO') . '&quot;&gt;';
$postmeta .= the_date('', '', '', false);
$postmeta .= '&lt;/abbr&gt;&lt;/span&gt;';
$postmeta .= &quot;&lt;/div&gt;&lt;!-- .entry-meta --&gt;\n&quot;;

if ($post-&gt;post_type == 'page' || is_404()) {
$postheader = $posttitle;
} else {
$postheader = $posttitle . $postmeta;
}
// this was the original filter applied to  thematic_postheader
//echo apply_filters( 'thematic_postheader', $postheader );

echo $postheader; //I've just echoed out $postheader because

//the hole function will be added to the filter below
}

add_filter( 'thematic_postheader', 'greet_box' );
</pre>
<p>Now if all that wasn&#8217;t bad enough, if I leave it like this the greet box will appear in all posts above the title, which means on the homepage I will have 10 identical greet boxes for all my 10 posts&#8230; Not a pretty picture one might say.</p>
<p>There is a solution if you are wondering&#8230;</p>
<p>I&#8217;ve created a global variable that it&#8217;s initialized with &#8217;1&#8242; once the page loads (I&#8217;ve called it <em>$greet_count</em>). I&#8217;ve done this inside a <em>init_count(); </em>function that gets hooked to <em>thematic_belowheader</em> so it get&#8217;s initialized only once on page load (if we would&#8217;ve  added it to the <em>greet_box()</em> function that hooks into <em>thematic_postheader</em> it would have been re-initialized on every post and still display 10 greet boxes on the home page ).</p>
<p>This in my functions.php file after all the hacking <img src='http://www.cozmoslabs.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre class="brush: php;">

function init_count(){
global $greet_count;
$greet_count = 1;
}
function greet_box(){

global $post, $authordata, $greet_count; //added the counter as a global var.

if (is_single() || is_page()) {
$posttitle = '&lt;h1 class=&quot;entry-title&quot;&gt;' . get_the_title() . &quot;&lt;/h1&gt;\n&quot;;
} elseif (is_404()) {
$posttitle = '&lt;h1 class=&quot;entry-title&quot;&gt;' . __('Not Found', 'thematic') . &quot;&lt;/h1&gt;\n&quot;;
} else {
$posttitle = '&lt;h2 class=&quot;entry-title&quot;&gt;&lt;a href=&quot;';
$posttitle .= get_permalink();
$posttitle .= '&quot; title=&quot;';
$posttitle .= __('Permalink to ', 'thematic') . the_title_attribute('echo=0');
$posttitle .= '&quot; rel=&quot;bookmark&quot;&gt;';
$posttitle .= get_the_title();
$posttitle .= &quot;&lt;/a&gt;&lt;/h2&gt;\n&quot;;
}

$postmeta = '&lt;div class=&quot;entry-meta&quot;&gt;';
$postmeta .= '&lt;span class=&quot;author vcard&quot;&gt;';
$postmeta .= __('By ', 'thematic') . '&lt;a class=&quot;url fn n&quot; href=&quot;';
$postmeta .= get_author_link(false, $authordata-&gt;ID, $authordata-&gt;user_nicename);
$postmeta .= '&quot; title=&quot;' . __('View all posts by ', 'thematic') . get_the_author() . '&quot;&gt;';
$postmeta .= get_the_author();
$postmeta .= '&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;meta-sep&quot;&gt; | &lt;/span&gt;';
$postmeta .= '&lt;span class=&quot;entry-date&quot;&gt;&lt;abbr class=&quot;published&quot; title=&quot;';
$postmeta .= get_the_time('Y-m-d\TH:i:sO') . '&quot;&gt;';
$postmeta .= the_date('', '', '', false);
$postmeta .= '&lt;/abbr&gt;&lt;/span&gt;';
$postmeta .= &quot;&lt;/div&gt;&lt;!-- .entry-meta --&gt;\n&quot;;

if ($post-&gt;post_type == 'page' || is_404()) {
$postheader = $posttitle;
} else {
$postheader = $posttitle . $postmeta;
}

//checked to see if the box was displayed before
if ($greet_count == 1) { wp_greet_box();$greet_count=2; }

//echo apply_filters( 'thematic_postheader', $postheader );
echo $postheader;
}

add_filter( 'thematic_belowheader', 'init_count' );
add_filter( 'thematic_postheader', 'greet_box' );
</pre>
<p>Now that was simple right? I came up with this idea after over 1 hour of trying to position that box with css without breaking the layout and failing miserably.</p>
<p>I have now clue to how some one else might find this useful, but it&#8217;s a big web out there and if you had any uses for this hack please let me know! It would be really interesting to see what you&#8217;ve come up with.</p>
<p>Also if someone else has am idea on how to do this using Child Themes other then my own please let me know!</p>


<p>Related posts:<ol><li><a href='http://www.cozmoslabs.com/2009/10/28/create-an-about-the-author-area-for-thematic/' rel='bookmark' title='Permanent Link: Create an &#8220;About the author&#8221; area for Thematic'>Create an &#8220;About the author&#8221; area for Thematic</a></li>
<li><a href='http://www.cozmoslabs.com/2009/06/26/thematic-featured-posts/' rel='bookmark' title='Permanent Link: Add &#8220;Featured Posts&#8221; to your Thematic child theme'>Add &#8220;Featured Posts&#8221; to your Thematic child theme</a></li>
<li><a href='http://www.cozmoslabs.com/2008/08/11/10-design-tips-for-your-custom-wordpress-theme-built-with-thematic/' rel='bookmark' title='Permanent Link: 10 design tips for your custom wordpress theme built with thematic'>10 design tips for your custom wordpress theme built with thematic</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.cozmoslabs.com/2008/09/19/wp-greet-box-my-design-and-thematic-the-good-the-bad-and-the-ugly/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Database Caching 21/56 queries in 0.065 seconds using disk

Served from: www.cozmoslabs.com @ 2010-07-31 02:44:59 -->