Please login or register.

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

Author Topic: [MOD] Popular articles (snews 1.5)  (Read 14858 times)

Andrey Voev

  • Newbie
  • *
  • Karma: 0
  • Posts: 8
    • http://www.live-in-vegas.com
[MOD] Popular articles (snews 1.5)
« Reply #15 on: May 03, 2007, 08:12:25 AM »

is there any way to put the "popular articles" mod to work ONLY on home "category" ?
I mean - on home - you got the 5 most popular articles,and on the other categories,you have the usual article order ?
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [MOD] Popular articles (snews 1.5)
« Reply #16 on: October 02, 2007, 01:27:35 PM »

Houston?
I think we've got a problem with required Page view counter mod.

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [MOD] Popular articles (snews 1.5)
« Reply #17 on: October 03, 2007, 02:06:45 PM »

 ???

H.A.C

  • Jr. Member
  • **
  • Karma: 20
  • Posts: 86
  • i love snews community for its great members
    • Chasoft Corporation
[MOD] Popular articles (sNews 1.6)
« Reply #18 on: November 02, 2007, 12:28:49 PM »

The original popular_articles function is so simple. And I would like to display a list of top read articles .. look like the newest articles. And this is the working function that I'm using.

Version 1: Display the top read articles list - looks like the the new articles list (just the decoration issue)

Code: [Select]
<?php
// POPULAR ARTICLES
function popular_articles($size) {
# select all published articles ordered by view column and limiting the output with numeric $size variable
$query "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND published = 1 ORDER BY views DESC LIMIT $size";
$result mysql_query($query);
# "home" title defined outside while-loop
$home s('home_sef');
    while (
$r mysql_fetch_array($result)) {
    
# find category SEF title (used to build links)
    
$categorySEF find_cat_sef($r['category']);
    
# defining category name: if zero, we're at home, else retrieve category name
    
$categoryName $r['category'] == $home retrieve('name''categories''seftitle'$categorySEF);
    echo 
'<li><a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/">'.$r['title'].' </a><a style="color:#FF0000;">('.$r['views'].' '.l('views').')</a></li>';}
}

?>
« Last Edit: November 03, 2007, 05:02:18 AM by H.A.C »
Logged
I'm not available ....until the end of the year 2009!
----------------------------
The largest website powered by sNews is in its way to become the biggest!
My great personal website powered by sNews 1.6
http://www.chasoft.net
Come to see how it's great!

H.A.C

  • Jr. Member
  • **
  • Karma: 20
  • Posts: 86
  • i love snews community for its great members
    • Chasoft Corporation
[MOD] Popular articles (sNews 1.6)
« Reply #19 on: November 03, 2007, 05:03:09 AM »

Version 2: Display the top read articles list - looks like the the new articles list (just the decoration issue)
This plus a feature that will display a list of top read articles list according to where you are browsing

- when you are in home, it's a list of top read articles list ranging all your articles in your snews site.
- when you are in a specific category, it's a list of top read articles list ranging all your articles in that category.

I think this is a better way to show a list of top read articles to solve the problem that when the a article is top read, then it will always the top read article and other articles have no changes to express themselves.

Code: [Select]
<?php

// POPULAR ARTICLES
function popular_articles($size) {
    
$categorySEF get_id('category');
    
$cat retrieve('id','categories','seftitle',$categorySEF);
# select all published articles ordered by view column and limiting the output with numeric $size variable
$query "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND published=1";
if ($categorySEF != $home){ $query .= " AND category = $cat";}
$query .= " ORDER BY views DESC LIMIT $size";
$result mysql_query($query);
# "home" title defined outside while-loop
$home s('home_sef');
    while (
$r mysql_fetch_array($result)) {
    
# find category SEF title (used to build links)
    
$categorySEF find_cat_sef($r['category']);
    
# defining category name: if zero, we're at home, else retrieve category name
    
$categoryName $r['category'] == $home retrieve('name''categories''seftitle'$categorySEF);
    echo 
'<li><a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/">'.$r['title'].' </a><a style="color:#FF0000;">('.$r['views'].' '.l('views').')</a></li>';}
}
?>
Logged
I'm not available ....until the end of the year 2009!
----------------------------
The largest website powered by sNews is in its way to become the biggest!
My great personal website powered by sNews 1.6
http://www.chasoft.net
Come to see how it's great!

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
[MOD] Popular articles (sNews 1.6)
« Reply #20 on: November 05, 2007, 01:10:52 AM »

HAC, are these MODs you have posted for sNews 1.5 or 1.6? If 1.6, I think it would be a good idea to post them in the 1.6 forums as there is currently no 1.6 port posted :)
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

H.A.C

  • Jr. Member
  • **
  • Karma: 20
  • Posts: 86
  • i love snews community for its great members
    • Chasoft Corporation
[MOD] Popular articles (sNews 1.6)
« Reply #21 on: November 05, 2007, 05:40:06 AM »

Actually, I did those for my sNews 1.6 and it works fine.
Logged
I'm not available ....until the end of the year 2009!
----------------------------
The largest website powered by sNews is in its way to become the biggest!
My great personal website powered by sNews 1.6
http://www.chasoft.net
Come to see how it's great!

Fyner

  • Newbie
  • *
  • Karma: 0
  • Posts: 28
Re: [MOD] Popular articles (snews 1.6)
« Reply #22 on: October 10, 2008, 01:29:18 PM »

I have small problem with this MOD, does't work :P

I add this to snews.php

Code: [Select]
// POPULAR ARTICLES
function popular_articles($size) {
# select all published articles ordered by view column and limiting the output with numeric $size variable
$query = "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND published = 1 ORDER BY views DESC LIMIT $size";
$result = mysql_query($query);
# "home" title defined outside while-loop
$home = s('home_sef');
    while ($r = mysql_fetch_array($result)) {
    # find category SEF title (used to build links)
    $categorySEF = find_cat_sef($r['category']);
    # defining category name: if zero, we're at home, else retrieve category name
    $categoryName = $r['category'] == 0 ? $home : retrieve('name', 'categories', 'seftitle', $categorySEF);
    echo '<li><a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/">'.$r['title'].' </a><a style="color:#FF0000;">('.$r['views'].' '.l('views').')</a></li>';}
}


and this to index.php

Quote
  <?php popular_articles(8); ?>


May be it's prefix??
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: [MOD] Popular articles (snews 1.6)
« Reply #23 on: October 10, 2008, 03:04:08 PM »

I have small problem with this MOD, does't work :P
May be it's prefix??

Welcome Fyner.
Did you review the instructions in the first post of this topic... and particularly... install the Page view counter mod before applying this mod?
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Fyner

  • Newbie
  • *
  • Karma: 0
  • Posts: 28
Re: [MOD] Popular articles (snews 1.5)
« Reply #24 on: October 10, 2008, 03:53:43 PM »

Hi Keyrocks.
And thx for Your help, don't I noticed this line :/
Now everything is ok ;)

Edit:

Hmm, someone knows how add successive numbers before article title??
« Last Edit: October 10, 2008, 04:15:54 PM by Fyner »
Logged

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: [MOD] Popular articles (snews 1.5)
« Reply #25 on: October 11, 2008, 08:36:53 PM »

Article number 1, 2, 3... n ? As in comments?

Well, how is working the pagination?
What you know about:
 1. - in center function, you can find how many articles you have published (the total number of your published articles - per category or per entire blog - both possible),
 2. - how many articles are displayed on a page (from settings table),
 3. - what is the current number page (from pagination).
So, you can know what is the starting number for first article from your current page. Then, you can increment it inside while cycle for every displayed article on that page. The single (little) problem is to make it working only when is in a category or on "news" page, both or only one, at your choice...
« Last Edit: October 24, 2008, 03:31:15 PM by funlw65 »
Logged
Pages: 1 [2]