Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [MOD] Digg.com counter button (admin option for articles)  (Read 10574 times)

Ken Dahlin

  • Full Member
  • ***
  • Karma: 30
  • Posts: 139
    • http://www.kendahlin.com/
[MOD] Digg.com counter button (admin option for articles)
« on: August 09, 2007, 06:57:20 pm »

This mod creates a check box in the customize section of article editing which allows you, at any time, to choose whether or not you want a digg.com vote button to appear on that article. You'll need to add a field to your sNews database in order to be able to toggle this option on and off per article. This is important otherwise you'd have a bunch of articles with 0 diggs and that would just look silly.

Demo: http://snews.kendahlin.com/digg_button/mods/digg-button-integrated-into-snews-16/



Start off by adding a new field to your mysql database. In table "articles" add the field "diggbutton"

You can use phpmyadmin to add it easily, just make sure it has:

Field: diggbutton
Type: char(3)
Null: No
Default: YES

The default value should be YES or NO depending on your needs... if you don't want to unclick it every time you write an article, make it NO

---

Ok, lets edit snews.php - first we'll need a background color for the button so add digg_bg to your language variables so you can define that for whatever color will match your site:
Code: [Select]
$l['digg_bg'] = '#FFFFFF';Now in function center() find
Code: [Select]
if ($r['displaytitle'] == 'YES') {echo '<h2>'.(strlen($text) > $shorten ? $link.$category.'/'.$r['seftitle'].'/" title="'.$title.'">'.$title.'</a>' : $title).'</h2>';}and then add this block of code immediately after:

Code: [Select]
if ($r['diggbutton'] == 'YES') {
echo "<div style='float: left; margin-right: 10px; margin-bottom: 2px; margin-top: 10px;'> <script type='text/javascript'> digg_url = '";
echo db('website').$category.'/'.$r['seftitle'].'/';
echo "'; digg_bgcolor = '".l('digg_bg')."'; digg_title = '$title'; digg_bodytext = 'Describe this article in your own words.';</script><script src='http://digg.com/tools/diggthis.js' type='text/javascript'></script></div>";
}
In function form_articles() find:

Code: [Select]
$frm_display_title = $r['displaytitle'] == 'YES' ? 'ok' : '';and add this line immediately after:

Code: [Select]
$frm_digg_button = $r['diggbutton'] == 'YES' ? 'ok' : '';In the same function find:

Code: [Select]
$frm_display_title = 'ok';and add this line immediately after:

Code: [Select]
$frm_digg_button = 'ok';again in the same function find:

Code: [Select]
echo html_input('checkbox', 'display_title', 'dt', 'YES', l('display_title'), '', '', '', '', $frm_display_title, '', '', '', '', '');and add this line immediately following it:

Code: [Select]
echo html_input('checkbox', 'digg_button', 'db', 'YES', 'Enable digg button', '', '', '', '', $frm_digg_button, '', '', '', '', '');In function processing() look for:

Code: [Select]
$display_title = $_POST['display_title'] == 'on' ? 'YES' : 'NO';and add this line after it:

Code: [Select]
$digg_button = $_POST['digg_button'] == 'on' ? 'YES' : 'NO';In the same function find:
Code: [Select]
mysql_query("INSERT INTO ".db('prefix')."articles(title, seftitle, text, date, category, position, displaytitle, displayinfo, commentable, published, description_meta, keywords_meta) VALUES('$title', '$seftitle', '$text', '$date', '$category', '$position', '$display_title', '$display_info', '$commentable', '$publish_article', '$description_meta', '$keywords_meta')");and CHANGE that line to read:
Code: [Select]
mysql_query("INSERT INTO ".db('prefix')."articles(title, seftitle, text, date, category, position, displaytitle, displayinfo, commentable, published, description_meta, keywords_meta, diggbutton) VALUES('$title', '$seftitle', '$text', '$date', '$category', '$position', '$display_title', '$display_info', '$commentable', '$publish_article', '$description_meta', '$keywords_meta', '$digg_button')");a couple lines down, find:
Code: [Select]
mysql_query("UPDATE ".db('prefix')."articles SET title='$title', seftitle = '$seftitle', text = '$text',".$future." category = '$category', position = '$position', displaytitle = '$display_title', displayinfo = '$display_info', commentable = '$commentable', published = '$publish_article', description_meta = '$description_meta', keywords_meta = '$keywords_meta' WHERE id = '$id' LIMIT 1;");and change that to read:
Code: [Select]
mysql_query("UPDATE ".db('prefix')."articles SET title='$title', seftitle = '$seftitle', text = '$text',".$future." category = '$category', position = '$position', displaytitle = '$display_title', displayinfo = '$display_info', commentable = '$commentable', published = '$publish_article', description_meta = '$description_meta', keywords_meta = '$keywords_meta' , diggbutton = '$digg_button' WHERE id = '$id' LIMIT 1;");That's it. You should be ready now if your article gets listed on digg.com and users of Digg can now vote directly from your site.
« Last Edit: September 07, 2007, 07:25:28 am by Ken Dahlin »
Logged

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
[MOD] Digg.com counter button (admin option for articles)
« Reply #1 on: August 10, 2007, 01:58:22 am »

Another terrific MOD Ken, you've produced some terrific additions lately. Cheers! *tips hat* :D
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

Ken Dahlin

  • Full Member
  • ***
  • Karma: 30
  • Posts: 139
    • http://www.kendahlin.com/
[MOD] Digg.com counter button (admin option for articles)
« Reply #2 on: August 10, 2007, 07:16:50 am »

Thanks for the appreciation, piXelatedEmpire.
Logged

David

  • Hero Member
  • *****
  • Karma: 7
  • Posts: 567
[MOD] Digg.com counter button (admin option for articles)
« Reply #3 on: August 10, 2007, 09:02:14 am »

Great mod Kendahlin!!! thank you.
Logged

sibas

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 451
    • www.simply4all.net
Re: [MOD] Digg.com counter button (admin option for articles)
« Reply #4 on: October 19, 2007, 03:35:29 pm »

Hi
I try to add in snews1.6 enhanced
display only the image and i dont have link or iframe in digg button

tables is different so i make it like this
Code: [Select]
case(isset($_POST['add_article'])):
mysql_query("INSERT INTO ".db(prefix)."".gl('articles_table')."(title, seftitle, text, date, category, position, displaytitle, displayinfo, commentable, published, description_meta, keywords_meta, diggbutton, display_auto) VALUES('$title', '$seftitle', '$text', '$date', '$category', '$position', '$display_title', '$display_info', '$commentable', '$publish_article', '$description_meta', '$keywords_meta', '$digg_button', '$display_auto')");
break;
case(isset($_POST['edit_article'])):
if ($fpost_enabled == true) {$future = " date = '$date',";}
mysql_query("UPDATE ".db(prefix)."".gl('articles_table')." SET title='$title', seftitle = '$seftitle', text = '$text',".$future." category = '$category', position = '$position', displaytitle = '$display_title', displayinfo = '$display_info', commentable = '$commentable', published = '$publish_article', description_meta = '$description_meta', keywords_meta = '$keywords_meta', diggbutton = '$digg_button', display_auto = '$display_auto' WHERE id = '$id' LIMIT 1;");


Any idea? Do i have to register in Digg to use this?

Logged

Ken Dahlin

  • Full Member
  • ***
  • Karma: 30
  • Posts: 139
    • http://www.kendahlin.com/
Re: [MOD] Digg.com counter button (admin option for articles)
« Reply #5 on: October 29, 2007, 06:58:04 am »

I haven't monkeyed with this script in a while, but I'll try to get it to work with snews1.6 enhanced. You should see a button, regardless if you're a member of digg.com or not. If you aren't a member, it will send you to the digg registration page.
Logged

sibas

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 451
    • www.simply4all.net
Re: [MOD] Digg.com counter button (admin option for articles)
« Reply #6 on: October 29, 2007, 01:31:56 pm »

Thank you Ken
With above setup in snews1.6 enhanced is working,
The problem with iframe and link was in my CSS i change it and is working  ;D
Logged

Vivvo

  • Newbie
  • *
  • Karma: 0
  • Posts: 20
Re: [MOD] Digg.com counter button (admin option for articles)
« Reply #7 on: December 17, 2007, 11:46:51 am »

How do you change this code to choose a different Digg button they offer to match your site
Logged

crm

  • Newbie
  • *
  • Karma: 1
  • Posts: 26
    • planetmayfield.com
Re: [MOD] Digg.com counter button (admin option for articles)
« Reply #8 on: December 18, 2007, 12:16:10 am »

Very nice mod, thanks!
Logged
Endlessly banging my head against the keyboard.

crm

  • Newbie
  • *
  • Karma: 1
  • Posts: 26
    • planetmayfield.com
Re: [MOD] Digg.com counter button (admin option for articles)
« Reply #9 on: February 03, 2008, 05:55:43 am »

Ken very nice mod...

I know this question is going to reveal my ineptitude when it comes to PHP/MySQL programming, but how can I have the value of the 'Digg Button' be unchecked by default when composing articles?


Logged
Endlessly banging my head against the keyboard.

jlhaslip

  • Sr. Member
  • ****
  • Karma: 16
  • Posts: 374
    • My snews with AEF Forum site
Re: [MOD] Digg.com counter button (admin option for articles)
« Reply #10 on: February 04, 2009, 08:16:24 pm »

Setting the default behaviour is defined in the original post, below the image.
Quote
The default value should be YES or NO depending on your needs... if you don't want to unclick it every time you write an article, make it NO
Logged
Yes! I have no siggy.