Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [MOD] Article Views Counter Mod (sNews 1.4)  (Read 3889 times)

urbitasmedia

  • Newbie
  • *
  • Karma: 0
  • Posts: 32
    • http://www.urbitasmedia.com
[MOD] Article Views Counter Mod (sNews 1.4)
« 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.
Logged

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD] Article Views Counter Mod (sNews 1.4)
« Reply #1 on: July 08, 2006, 09:24:50 am »

nice mod, short & clean *thumbs-up*
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

brauck

  • Hero Member
  • *****
  • Karma: 18
  • Posts: 556
    • http://www.hbw-webdesign.nl/
[MOD] Article Views Counter Mod (sNews 1.4)
« Reply #2 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. :)
Logged
Confidence is reduced complexity.
brauck.nl for free css templates

urbitasmedia

  • Newbie
  • *
  • Karma: 0
  • Posts: 32
    • http://www.urbitasmedia.com
[MOD] Article Views Counter Mod (sNews 1.4)
« Reply #3 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.
Logged

brauck

  • Hero Member
  • *****
  • Karma: 18
  • Posts: 556
    • http://www.hbw-webdesign.nl/
[MOD] Article Views Counter Mod (sNews 1.4)
« Reply #4 on: July 08, 2006, 06:20:58 pm »

You're very welcome, that's what we are here for.
Logged
Confidence is reduced complexity.
brauck.nl for free css templates

dracko

  • Jr. Member
  • **
  • Karma: 0
  • Posts: 57
    • http://www.gritala.com
[MOD] Article Views Counter Mod (sNews 1.4)
« Reply #5 on: July 23, 2006, 02:25:29 am »

thank you, really usefull for my site
Logged