Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: [MOD] Most Popular Articles (Dynamic) (sNews 1.4)  (Read 8298 times)

urbitasmedia

  • Newbie
  • *
  • Karma: 0
  • Posts: 32
    • http://www.urbitasmedia.com
[MOD] Most Popular Articles (Dynamic) (sNews 1.4)
« on: July 09, 2006, 02:04:43 am »

As a tag on Mod for the Article Views Counter, below is simple PHP that will return the top 5 most popular articles by views.

Requires:  http://www.solucija.com/forum/viewtopic.php?id=1251

Code: [Select]
// MOST POPULAR ARTICLES BY VIEWS
$query = "SELECT articles.id, articles.title, articles.category, categories.seftitle, articles.seftitle, articles.views FROM articles LEFT JOIN categories ON articles.category = categories.id ORDER BY articles.views DESC LIMIT 5 ";
$result = @mysql_query ($query);
while ($row = mysql_fetch_array($result, MYSQL_NUM))
     echo "$row[1]";
     mysql_free_result ($result);
?>
Put the above code on your index.php where you would like for the top five articles to appear.

You can see this code in action here:  http://www.authenticorlando.com
Logged

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD] Most Popular Articles (Dynamic) (sNews 1.4)
« Reply #1 on: July 09, 2006, 10:12:43 am »

i'm not quite sure what version do you use, but this is a quick fix for snews 1.4

put this function in your snews.php, just above //CENTER
Quote
// MOST POPULAR ARTICLES BY VIEWS
function popular_articles() {
   $query = "SELECT articles.id, articles.title, articles.category, categories.seftitle, articles.seftitle, articles.views FROM articles LEFT JOIN categories ON articles.category = categories.id ORDER BY articles.views DESC LIMIT 5 ";
   $result = @mysql_query ($query);
   while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
      $category = $row[3] <>'' ? $row[3].'/' : 'home/';
      echo ''.$row[1].'
';
   }
mysql_free_result ($result);
}
edit:

usage: put this snippet somewhere inside your index.php
Quote
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

4Sandrix

  • Hero Member
  • *****
  • Karma: -13
  • Posts: 597
    • http://fedrick.deviantart.com
[MOD] Most Popular Articles (Dynamic) (sNews 1.4)
« Reply #2 on: July 09, 2006, 12:10:22 pm »

Thx to Both of you
Logged
I'm kind of like Han Solo always strokin' my own Wookiee
I'm the root of all that's evil yeah but you can call me Cookie

dracko

  • Jr. Member
  • **
  • Karma: 0
  • Posts: 57
    • http://www.gritala.com
[MOD] Most Popular Articles (Dynamic) (sNews 1.4)
« Reply #3 on: August 04, 2006, 09:11:30 pm »

thank you.. just what i was looking for
Logged

bryn

  • Hero Member
  • *****
  • Karma: 2
  • Posts: 934
    • http://www.cssugly.com
[MOD] Most Popular Articles (Dynamic) (sNews 1.4)
« Reply #4 on: August 04, 2006, 09:13:17 pm »

ooh just found this..very handy mika..thank you ;)
Logged
Over 1,000 posts of joy, sNews is not only brilliant, but fun too! thanks guys :D

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD] Most Popular Articles (Dynamic) (sNews 1.4)
« Reply #5 on: August 04, 2006, 10:47:06 pm »

thx, but the credits should go to the urby ;)

(btw, i like your signature, bryn :D )
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

bryn

  • Hero Member
  • *****
  • Karma: 2
  • Posts: 934
    • http://www.cssugly.com
[MOD] Most Popular Articles (Dynamic) (sNews 1.4)
« Reply #6 on: August 05, 2006, 02:38:32 pm »

yeah good work urby..this was mentioned quite some time ago as a needed mod..now e just have to perfect the related articles thingy, and we're pretty much set me thinks?

on that front anyway! ;)
Logged
Over 1,000 posts of joy, sNews is not only brilliant, but fun too! thanks guys :D

urbitasmedia

  • Newbie
  • *
  • Karma: 0
  • Posts: 32
    • http://www.urbitasmedia.com
[MOD] Most Popular Articles (Dynamic) (sNews 1.4)
« Reply #7 on: August 05, 2006, 04:36:44 pm »

Quote from: bryn
now e just have to perfect the related articles thingy
Can you explain the requirements for this?  I may be able to throw some code together.
Logged

iatbm

  • Sr. Member
  • ****
  • Karma: 0
  • Posts: 251
    • Public domain photos
[MOD] Most Popular Articles (Dynamic) (sNews 1.4)
« Reply #8 on: October 20, 2006, 07:13:30 pm »

Can someone make this for 1.5 ?

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD] Most Popular Articles (Dynamic) (sNews 1.4)
« Reply #9 on: October 20, 2006, 10:27:18 pm »

I have it running on my site ;)
you see, my mod expands original new_articles function, so please give me a day or 2 to write user manual for this, okay?
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

iatbm

  • Sr. Member
  • ****
  • Karma: 0
  • Posts: 251
    • Public domain photos
[MOD] Most Popular Articles (Dynamic) (sNews 1.4)
« Reply #10 on: October 21, 2006, 01:00:04 am »

great mika I appreciate if you do this !

Fotrane

  • Newbie
  • *
  • Karma: 1
  • Posts: 28
[MOD] Most Popular Articles (Dynamic) (sNews 1.4)
« Reply #11 on: October 23, 2006, 04:44:04 pm »

I'm not sure if this should be in a new post or not, but for 1.5 I used the following code:

Around line 270 or so, look for
Code: [Select]
$position = $r['position'];Add:
Code: [Select]
$views = $r['views'];Then, below the section starting with:
Code: [Select]
if ($r['displaytitle'] == 'YES') {I added:
Code: [Select]
if ($article){
$views++;
$query = "UPDATE articles SET views='$views' WHERE id = '".$r['id']."'";
mysql_query ($query);
}
Seems to work fine as far as counting the number of views. However -- this mod will not be as reliable as it was in 1.4 because 1.5 uses the "[BREAK]". I am probably goin g revert my 1.5 back to using the autobreak method.
Logged

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[MOD] Most Popular Articles (Dynamic) (sNews 1.4)
« Reply #12 on: October 23, 2006, 05:05:47 pm »

update sql should go in center function; in a routine activated after user starts viewing full article... gimme a couple of days to get my book fully online and i'll post my mod (or continue to develop yours :) )
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
[MOD] Most Popular Articles (Dynamic) (sNews 1.4)
« Reply #13 on: November 22, 2006, 12:56:43 am »

Hi Mika.. progress report? Just a friendly reminder!

hehe sorry to hassle!  :D
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

Armen

  • Sr. Member
  • ****
  • Karma: 41
  • Posts: 338
    • http://www.funnydays.ru
[MOD] Most Popular Articles (Dynamic) (sNews 1.4)
« Reply #14 on: February 12, 2007, 09:01:42 am »

Quote from: piXelatedEmpire
Hi Mika.. progress report? Just a friendly reminder!

hehe sorry to hassle!  :D
Mika, where are you?

We neeeed you!
Logged
Now ogres, oh, they're much worse. They'll make a suit from your freshly peeled skin. They'll shave your liver, squeeze the jelly from your eyes... Actually, it's quite good on toast.
Pages: [1] 2