sNews Forum

Previous sNews versions => sNews 1.4 Final => Mods and Addons => Topic started by: urbitasmedia on July 08, 2006, 08:36:38 am

Title: [MOD] Article Views Counter Mod (sNews 1.4)
Post by: urbitasmedia on July 08, 2006, 08:36:38 am
First, let me say thanks to the sNews team.  I'm a huge fan.  I thought it was time for me to give a little back to the sNews community.

Sorry if this mod already exisits.  I did a quick search and didn't see anything similar.

Summary
This mod will add a real-time counter to news articles.  The counter will increment everytime the article is viewed or refreshed.  This mod can be completed in two steps.

1)  Create a new field in the article table called views.  This new field should be an Integer type and have a default value of 0 (zero).

2)  Copy the following code into the center() function in your snews.php.

Code: [Select]
// Article Views
$views = $r['views'];
$views++;
$query = "UPDATE articles SET views='$views' WHERE id = $r[id]";
echo "Views:
" .$views. "

";
mysql_query ($query);
I placed my code above just before these lines...
Code: [Select]
echo "if ($category <> s('home')) { echo $category. "'>";  } else { echo "'>"; }Here is what it looks like on my wife's web-site.
http://www.authenticorlando.com/dining/columbia_elegant_spanish_dining/

I'll check back to see anyone has any questions.
Title: [MOD] Article Views Counter Mod (sNews 1.4)
Post by: Mika on July 08, 2006, 09:24:50 am
nice mod, short & clean *thumbs-up*
Title: [MOD] Article Views Counter Mod (sNews 1.4)
Post by: brauck on July 08, 2006, 02:09:04 pm
Nice mod, urbitasmedia. I looked at your website and saw that it does not render well in Firefox and Opera. This is due to the CSS part of your site. As you probably know Firefox and Opera render by the rules and IE does not. So, if you haven't Firefox and Opera installed on your machine, please download and install them.  In IE your site looks rather nice; if you need help on the css part come back and ask. :)
Title: [MOD] Article Views Counter Mod (sNews 1.4)
Post by: urbitasmedia on July 08, 2006, 05:03:33 pm
Thanks brauck.  Some of my old sites have major problems, the only FireFox problem I saw with my sNews sites was with the background not spanning the entire screen.  I fixed that by adding a Height auto;.   I know more and more people are using FireFox and Opera, but I rarely do.  I appreciate you bringing this to my attention.
Title: [MOD] Article Views Counter Mod (sNews 1.4)
Post by: brauck on July 08, 2006, 06:20:58 pm
You're very welcome, that's what we are here for.
Title: [MOD] Article Views Counter Mod (sNews 1.4)
Post by: dracko on July 23, 2006, 02:25:29 am
thank you, really usefull for my site