Add a comment preview and delete link in the Admin section of sNews
filed under: sNews CMS / Hacks & Mods
I got a recent request to do a simple mod to put a "delete" link beside the comment edit link in the Admin section of sNews, so one can easily delete an obvious spam comment without clicking edit, then deleting. Seemed like a good idea, so I've added a few extra bits and have it running on my site as well, so I might as well offer it up to the community too. Here's a preview;
Within snews.php, find the function administration(), and add the following highlighted code in the comment SQL query;
$query_comm = 'SELECT id,articleid,name,comment FROM '._PRE.'comments'.' WHERE approved != 'True'';
Now find the code that outputs the unapproved comments;
echo '<p>'.$r['name'].' (<strong>'.$articleTITLE.'</strong>) '.l('divider').'
<a href="'._SITE.'?action=editcomment&commentid='.$r['id'].'">'.l('edit').'</a></p>';
Now replace that code with this block;
if (strlen($r['comment']) > '60') {
$preview = substr($r['comment'],0,60).'...';
} else {
$preview = $r['comment'];
}
echo '<p>'.$r['name'].' (<strong>'.$articleTITLE.'</strong>) '.l('divider').' <a href="'._SITE.'?action=editcomment&commentid='.$r['id'].'">'.l('edit').'</a> <a href="'._SITE.'?action=process&task=deletecomment&commentid='.$r['id'].'" title="'.l('delete').' '.l('comment').'" onclick="return pop()">'.l('delete').'</a><br /> - <span class="comment_preview">"'.$preview.'"</span></p>';
And the style for the comment preview;
.comment_preview {
font-size: .9em;
font-style: italic;
color: #555;
}
That's it. Very basic. It still redirects you to the article related to the comment, but to change that would require quite a bit more hacking on other functions.
4 comments
Add a new comment »Categories
Recent Entries
Recent Comments
- Redbeard (I managed to get Vampire: The Masquerade - Bloodlines ...)
- Tina (Installed this today and working like a charm :) Thanks!)
- Tina (Thanks for this great mod :) Working on my site for quite a ...)
- konga (Hi Matt, if you plan to update it, please have a look into ...)
- David (Yo Matt, I have a problem, when I use this mod. ...)
- Dave (Have a Toshiba NB305. Win7 starter would not do screen ...)
- Daichisan (Howdy Matt, I dont really get it, whats ...)
- Matt (Mine is just customized further, that's all :) It just spits ...)
- Matt (David, Do you own or admin the server? Do you have exec ...)
Popular Entries
- Compact archives for sNews 1.7 (5/5)
- Light-weight related articles mod for sNews 1.7 (4.78/5)
- SEF / SEO search for your sNews website (4.75/5)
- 1024x600 netbook wallpapers of Evangeline Lilly (4.67/5)
- Gravatar mod for sNews 1.7 (4.67/5)
- An improved tag cloud for sNews 1.7 (4.67/5)
- Image / math hybrid captcha version 2, vastly improved (4.64/5)
- Command & Conquer Generals, and the Zero Hour expansion on the Acer Aspire One netbook (4.6/5)
- Related Articles mod for sNews CMS, public beta release (4.6/5)
Nov 6th, 2009 at 8:20 am
hey matt
very nice mod,
it is a must for snews comment system.
thank you and
awesome day
Jan 25th, 2010 at 7:17 am
Mhm, now where the feck can I find and being able to change "Comment preview:" ?? Have styled that label, but I can't get rid of the semicolon...
Jan 25th, 2010 at 7:39 am
I'm not sure I follow you Patric, where do you see "Comment preview:" at?
Are you thinking about this;
http://mdj.us/web-development/ajax-javascript/live-comment-previewing-using-the-jquery-library/
If that's the case, it's in the javascript, just remove the semi-colon from that code... that colon should have been in the label actually;
$('#text').parent().after('<div><label for="comment-preview">Comment Preview</label>:</div><div id="comment-preview"></div>');Jan 25th, 2010 at 7:46 am
YES, I'm such an dumba**, thanks Matt.