<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://mydrupalblog.lhmdesign.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>My Drupal Blog - Theming Drupal&amp;#039;s Vote Up/Down Module - Comments</title>
 <link>http://mydrupalblog.lhmdesign.com/theming-drupals-vote-down-module</link>
 <description>Comments for &quot;Theming Drupal&#039;s Vote Up/Down Module&quot;</description>
 <language>en</language>
<item>
 <title>Thanks Laurence, just what I</title>
 <link>http://mydrupalblog.lhmdesign.com/theming-drupals-vote-down-module#comment-11536</link>
 <description>&lt;p&gt;Thanks Laurence, just what I needed.  &lt;/p&gt;
&lt;p&gt;btw, I like the author comment img at the bottom of your comments- that looks sharp&lt;/p&gt;
</description>
 <pubDate>Thu, 03 Jul 2008 16:16:54 -0700</pubDate>
 <dc:creator>RockSoup</dc:creator>
 <guid isPermaLink="false">comment 11536 at http://mydrupalblog.lhmdesign.com</guid>
</item>
<item>
 <title>Is there a class for</title>
 <link>http://mydrupalblog.lhmdesign.com/theming-drupals-vote-down-module#comment-10954</link>
 <description>&lt;p&gt;Is there a class for &quot;already voted&quot;? Like how Digg does &quot; Dugg&quot; and the opacity changes.&lt;/p&gt;
&lt;p&gt;What class would you use for this? Thanks and great blog!&lt;/p&gt;
</description>
 <pubDate>Tue, 20 May 2008 14:32:14 -0700</pubDate>
 <dc:creator>Chad</dc:creator>
 <guid isPermaLink="false">comment 10954 at http://mydrupalblog.lhmdesign.com</guid>
</item>
<item>
 <title>Nice stuff!</title>
 <link>http://mydrupalblog.lhmdesign.com/theming-drupals-vote-down-module#comment-10624</link>
 <description>&lt;p&gt;Nice stuff!&lt;/p&gt;
</description>
 <pubDate>Sat, 15 Mar 2008 13:06:49 -0700</pubDate>
 <dc:creator>Guest</dc:creator>
 <guid isPermaLink="false">comment 10624 at http://mydrupalblog.lhmdesign.com</guid>
</item>
<item>
 <title>There is a bug with this</title>
 <link>http://mydrupalblog.lhmdesign.com/theming-drupals-vote-down-module#comment-10568</link>
 <description>&lt;p&gt;There is a bug with this method, when you click over &quot;digg it&quot; word to cast a vote, the div is moved down, if you keep click the div is moved down again and again.. the problem is vertical alignment using the padding method, any ideas on how to solve it?&lt;/p&gt;
&lt;p&gt;regards,&lt;/p&gt;
</description>
 <pubDate>Sat, 01 Mar 2008 20:14:31 -0700</pubDate>
 <dc:creator>Guest</dc:creator>
 <guid isPermaLink="false">comment 10568 at http://mydrupalblog.lhmdesign.com</guid>
</item>
<item>
 <title>That was not supposed to say</title>
 <link>http://mydrupalblog.lhmdesign.com/theming-drupals-vote-down-module#comment-6537</link>
 <description>&lt;p&gt;That was not supposed to say *tags* btw, but supposed to say Un-Ordered List, UL&lt;/p&gt;
</description>
 <pubDate>Wed, 07 Nov 2007 11:49:58 -0700</pubDate>
 <dc:creator>Guest</dc:creator>
 <guid isPermaLink="false">comment 6537 at http://mydrupalblog.lhmdesign.com</guid>
</item>
<item>
 <title>What do you think about</title>
 <link>http://mydrupalblog.lhmdesign.com/theming-drupals-vote-down-module#comment-6403</link>
 <description>&lt;p&gt;What do you think about using &lt;UL&gt;  tags for the voting widget instead of Divs? Curious because thats what most of the voting sites use.&lt;/p&gt;
</description>
 <pubDate>Wed, 31 Oct 2007 15:58:19 -0700</pubDate>
 <dc:creator>Chad</dc:creator>
 <guid isPermaLink="false">comment 6403 at http://mydrupalblog.lhmdesign.com</guid>
</item>
<item>
 <title>If using a node.tpl.php</title>
 <link>http://mydrupalblog.lhmdesign.com/theming-drupals-vote-down-module#comment-6076</link>
 <description></description>
 <pubDate>Thu, 18 Oct 2007 14:45:52 -0700</pubDate>
 <dc:creator>Guest</dc:creator>
 <guid isPermaLink="false">comment 6076 at http://mydrupalblog.lhmdesign.com</guid>
</item>
<item>
 <title>Hi Chad,
glad you like the</title>
 <link>http://mydrupalblog.lhmdesign.com/theming-drupals-vote-down-module#comment-5855</link>
 <description>&lt;p&gt;Hi Chad,&lt;br /&gt;
glad you like the tutorial :)&lt;br /&gt;
I wrote a post a few months ago on &lt;a href=&quot;http://mydrupalblog.lhmdesign.com/creating-custom-regions&quot; title=&quot;Creating custom regions in Drupal&quot;&gt;creating custom regions in Drupal&lt;/a&gt;, which might be useful to you with regards to adsense placement.&lt;/p&gt;
</description>
 <pubDate>Fri, 12 Oct 2007 04:22:52 -0700</pubDate>
 <dc:creator>Laurence</dc:creator>
 <guid isPermaLink="false">comment 5855 at http://mydrupalblog.lhmdesign.com</guid>
</item>
<item>
 <title>Nice! Glad to see this and</title>
 <link>http://mydrupalblog.lhmdesign.com/theming-drupals-vote-down-module#comment-5846</link>
 <description>&lt;p&gt;Nice! Glad to see this and you explained it perfectly. Great addition on showing how to correctly change the &quot;points&quot;  text. &lt;/p&gt;
&lt;p&gt;Another idea for a tutorial that seems to clog the Drupal Forums is a cool way to display Advertisement like Adsense.  &lt;/p&gt;
&lt;p&gt; HTML Buzz  would handle an adsense section like  &lt;a href=&quot;http://digg.com/about&quot; title=&quot;http://digg.com/about&quot;&gt;http://digg.com/about&lt;/a&gt;&lt;br /&gt;
has quite well. Custom Region? Great Tutorials!&lt;/p&gt;
</description>
 <pubDate>Thu, 11 Oct 2007 22:18:45 -0700</pubDate>
 <dc:creator>Chad C.</dc:creator>
 <guid isPermaLink="false">comment 5846 at http://mydrupalblog.lhmdesign.com</guid>
</item>
<item>
 <title>Thanks,
yes I should have</title>
 <link>http://mydrupalblog.lhmdesign.com/theming-drupals-vote-down-module#comment-5818</link>
 <description>&lt;p&gt;Thanks,&lt;br /&gt;
yes I should have made clear that I&#039;m not suggesting you should copy Digg! (not unless you enjoy threatening letters ;)&lt;br /&gt;
I was just using Digg as it is the most well known example of a voting button, but you can adapt the methods above to pretty much whatever design you&#039;ve got going on your website.&lt;/p&gt;
</description>
 <pubDate>Thu, 11 Oct 2007 06:40:03 -0700</pubDate>
 <dc:creator>Laurence</dc:creator>
 <guid isPermaLink="false">comment 5818 at http://mydrupalblog.lhmdesign.com</guid>
</item>
<item>
 <title>Nice trick :)
Maybe you</title>
 <link>http://mydrupalblog.lhmdesign.com/theming-drupals-vote-down-module#comment-5817</link>
 <description>&lt;p&gt;Nice trick :)&lt;/p&gt;
&lt;p&gt;Maybe you could create more unique visual effect than copy of the &quot;digg it&quot;.&lt;/p&gt;
&lt;p&gt;However, nice.&lt;/p&gt;
</description>
 <pubDate>Thu, 11 Oct 2007 06:00:07 -0700</pubDate>
 <dc:creator>themegarden.org</dc:creator>
 <guid isPermaLink="false">comment 5817 at http://mydrupalblog.lhmdesign.com</guid>
</item>
<item>
 <title>Theming Drupal&#039;s Vote Up/Down Module</title>
 <link>http://mydrupalblog.lhmdesign.com/theming-drupals-vote-down-module</link>
 <description>&lt;p&gt;I guess quite a few people are looking to integrate some voting mechanism into their sites these days, so here&#039;s a quick guide to theming Drupal&#039;s vote up/down module Digg style.  Btw, thanks to Chad C for the suggestion, and if anyone else has ideas for posts/tutorials they&#039;d like to see on My Drupal Blog feel free to just post them in the comments or &lt;a href=&quot;?q=contact&quot; title=&quot;Contact me&quot;&gt;drop me an email&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For this tutorial I&#039;ll be using the &lt;a href=&quot;http://drupal.org/project/vote_up_down&quot; title=&quot;Drupal vote up/down module&quot;&gt;vote up/down module&lt;/a&gt; 5.x-1.x-dev on Drupal 5.2 and the default Garland theme.&lt;/p&gt;
&lt;p&gt;This tutorial assumes that you have already installed and enabled the other necessary voting modules – in this case the &lt;a href=&quot;http://drupal.org/project/votingapi&quot; title=&quot;Drupal voting API module&quot;&gt;voting API module&lt;/a&gt; 5.x-1.5.  If not, refer to the install.txt and readme.txt files packaged with the vote up/down module for further help.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Digg button&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Well, Digg is the classic voting button after all, so lets look at how you&#039;d theme Drupal&#039;s vote up/down package to look just like the Digg button.  Basically, we&#039;ll take the default Drupal look (left) and turn it into the Digg look (right).&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/files/blogimg/voteupdown_beforeafter.png&quot; alt=&quot;Vote up/down before and after theming&quot; /&gt;&lt;br /&gt;
&lt;!--break--&gt;&lt;br /&gt;
&lt;strong&gt;Step 1: Setup&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;First thing you need to do is go into the admin vote up/down settings (Administer &gt; Site configuration &gt; Vote up/down).&lt;br /&gt;
Set the node type you want the voting widget to show up on, set the &#039;Vote widget style&#039; to alternative, and then disable the &#039;Link display of vote points&#039;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/files/blogimg/voteupdown_settings.png&quot; alt=&quot;Vote up/down settings&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 2: The Images&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;OK, second thing you&#039;re going to need are three images:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;one for the count/number of diggs background&lt;/li&gt;
&lt;li&gt;one for the digg it button background when inactive&lt;/li&gt;
&lt;li&gt;one for the digg it button background when hovered over&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; For the purposes of this example I&#039;m using the images from Digg, but you can use any images you like.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/files/blogimg/voteupdown_images.png&quot; alt=&quot;Vote up/down images&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now, just save these images to your theme&#039;s &#039;images&#039; folder as normal.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 3: style.css&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Open your style.css file and add the following:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;.vote-up-down-widget-alt .vote-points {&lt;br /&gt;	height: 44px;&lt;br /&gt;	width: 51px;&lt;br /&gt;	margin: 0 0 3px 0;&lt;br /&gt;	padding: 8px 0 0 0;&lt;br /&gt;	color: #736926;&lt;br /&gt;	font-family: Arial, Helvetica, sans-serif;&lt;br /&gt;	background: #fff url(images/count_bg.jpg) no-repeat;&lt;br /&gt;}&lt;br /&gt;.vote-up-down-widget-alt .vote-up-inact:hover {&lt;br /&gt;	background: url(images/diggit_hover_bg.jpg) no-repeat;&lt;br /&gt;}&lt;br /&gt;.vote-up-down-widget-alt span.vote-up-act, .vote-up-down-widget-alt span.vote-up-inact, .vote-up-down-widget-alt span.up-inact {&lt;br /&gt;	border: none;&lt;br /&gt;}&lt;br /&gt;.vote-up-down-widget-alt .vote-up-inact, .vote-up-down-widget-alt .up-inact, .vote-up-down-widget-alt .vote-up-act {&lt;br /&gt;	background: url(images/diggit_bg.jpg) no-repeat;&lt;br /&gt;}&lt;br /&gt;.vote-up-down-widget-alt .vote-up-act, .vote-up-down-widget-alt .vote-up-inact, .vote-up-down-widget-alt .up-inact {&lt;br /&gt;	width: 51px;&lt;br /&gt;	height: 25px;&lt;br /&gt;}&lt;br /&gt;.vote-up-down-widget-alt .vote-points-label {&lt;br /&gt;	font-size: 63%;&lt;br /&gt;	line-height: 100%;&lt;br /&gt;	color: #998d43;&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Obviously, you will need to replace the various styles for height, width, color, and image with ones that relate to your particular site.&lt;/p&gt;
&lt;p&gt;One &lt;strong&gt;important&lt;/strong&gt; thing to note is that positioning/aligning the &#039;0 points&#039; text vertically can be a little tricky.  I have done it by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;adding a top padding of 8px to the .vote-up-down-widget-alt .vote-points div to position the text nicely&lt;/li&gt;
&lt;li&gt;subtracting this amount (8px) from the actual height of my count_bg.jpg (52px) file to give the real height you need to enter in the style.css (in this case 44px).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This extra calculation is required to help the digg it button sit correctly underneath. &lt;/p&gt;
&lt;p&gt;All being well, you should now have the following:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/files/blogimg/voteupdown_pointsstage.png&quot; alt=&quot;Vote up/down points stage&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 4: template.php&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;OK, that&#039;s looking pretty good but we now need to override the actual vote up/down module file functions which output &#039;points&#039; and change it to &#039;diggs&#039;, so open your theme&#039;s template.php file and add the following:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;/**&lt;br /&gt; *Override vote up/down. Change &amp;#039;points&amp;#039; to &amp;#039;diggs&amp;#039;.&lt;br /&gt; */&lt;br /&gt;function garland_vote_up_down_points($cid, $type, $nodelink = FALSE) {&lt;br /&gt;&amp;nbsp; $vote_result = votingapi_get_voting_result($type, $cid, &amp;#039;points&amp;#039;, variable_get(&amp;#039;vote_up_down_tag&amp;#039;, &amp;#039;vote&amp;#039;), &amp;#039;sum&amp;#039;);&lt;br /&gt;&amp;nbsp; if ($nodelink) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($vote_result) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $output = array(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#039;title&amp;#039; =&amp;gt; &amp;#039;&amp;lt;span id=&amp;quot;vote_points_&amp;#039;. $cid .&amp;#039;&amp;quot; class=&amp;quot;vote-points&amp;quot;&amp;gt;&amp;#039;. format_plural($vote_result-&amp;gt;value, &amp;#039;1 digg&amp;#039;, &amp;#039;@count diggs&amp;#039;) .&amp;#039;&amp;lt;/span&amp;gt;&amp;#039;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#039;html&amp;#039; =&amp;gt; TRUE&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $output = array(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#039;title&amp;#039; =&amp;gt; &amp;#039;&amp;lt;span id=&amp;quot;vote_points_&amp;#039;. $cid .&amp;#039;&amp;quot; class=&amp;quot;vote-points&amp;quot;&amp;gt;&amp;#039;. t(&amp;#039;0 diggs&amp;#039;) .&amp;#039;&amp;lt;/span&amp;gt;&amp;#039;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#039;html&amp;#039; =&amp;gt; TRUE&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($vote_result) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $output = &amp;#039;&amp;lt;span id=&amp;quot;vote_points_&amp;#039;. $cid .&amp;#039;&amp;quot; class=&amp;quot;vote-points&amp;quot;&amp;gt;&amp;#039;. format_plural($vote_result-&amp;gt;value, &amp;#039;1 digg&amp;#039;, &amp;#039;@count diggs&amp;#039;) .&amp;#039;&amp;lt;/span&amp;gt;&amp;#039;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $output = &amp;#039;&amp;lt;span id=&amp;quot;vote_points_&amp;#039;. $cid .&amp;#039;&amp;quot; class=&amp;quot;vote-points&amp;quot;&amp;gt;&amp;#039;. t(&amp;#039;0 diggs&amp;#039;) .&amp;#039;&amp;lt;/span&amp;gt;&amp;#039;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; return $output;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function garland_vote_up_down_points_alt($cid, $type) {&lt;br /&gt;&amp;nbsp; $vote_result = votingapi_get_voting_result($type, $cid, &amp;#039;points&amp;#039;, variable_get(&amp;#039;vote_up_down_tag&amp;#039;, &amp;#039;vote&amp;#039;), &amp;#039;sum&amp;#039;);&lt;br /&gt;&amp;nbsp; if ($vote_result) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $output = &amp;#039;&amp;lt;div id=&amp;quot;vote_points_&amp;#039;. $cid .&amp;#039;&amp;quot; class=&amp;quot;vote-points&amp;quot;&amp;gt;&amp;#039;. $vote_result-&amp;gt;value;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $output = &amp;#039;&amp;lt;div id=&amp;quot;vote_points_&amp;#039;. $cid .&amp;#039;&amp;quot; class=&amp;quot;vote-points&amp;quot;&amp;gt;0&amp;#039;;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; $output .= &amp;#039;&amp;lt;div class=&amp;quot;vote-points-label&amp;quot;&amp;gt;&amp;#039;. format_plural($vote_result-&amp;gt;value, &amp;#039;digg&amp;#039;, &amp;#039;diggs&amp;#039;) .&amp;#039;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;#039;;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; return $output;&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;…and basically that&#039;s it.&lt;/p&gt;
&lt;p&gt;Just remember when using the above snippet to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;replace &#039;garland&#039; with the name of your own Drupal theme folder&lt;/li&gt;
&lt;li&gt;replace each occurrence of &#039;digg&#039; and &#039;diggs&#039; with your own points name (e.g. spins, goals, boosts, votes etc.) using either the singular or plural as appropriate&lt;/li&gt;
&lt;/ul&gt;
</description>
 <comments>http://mydrupalblog.lhmdesign.com/theming-drupals-vote-down-module#comments</comments>
 <category domain="http://mydrupalblog.lhmdesign.com/topic/digg">Digg</category>
 <category domain="http://mydrupalblog.lhmdesign.com/taxonomy/term/1">Drupal</category>
 <category domain="http://mydrupalblog.lhmdesign.com/topic/drupal-theming">Drupal Theming</category>
 <category domain="http://mydrupalblog.lhmdesign.com/topic/style-css">style.css</category>
 <category domain="http://mydrupalblog.lhmdesign.com/topic/template-php">template.php</category>
 <category domain="http://mydrupalblog.lhmdesign.com/topic/vote-down">vote up/down</category>
 <pubDate>Wed, 10 Oct 2007 13:29:48 -0700</pubDate>
 <dc:creator>Laurence</dc:creator>
 <guid isPermaLink="false">35 at http://mydrupalblog.lhmdesign.com</guid>
</item>
</channel>
</rss>
