Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Author Topic: [MOD] menu_articles() - only one category (sNews 1.5 - sNews 1.6) by philmoz  (Read 3066 times)

Armen

  • Sr. Member
  • ****
  • Karma: 41
  • Posts: 338
    • http://www.funnydays.ru

Time to tell everyone who's new to sNews and is using sNews 1.6 that there's a very handy modification, made by Philmoz:

http://snewscms.com/forum/index.php?topic=2129.msg16218#msg16218

It's compatible with sNews 1.5xx to 1.6.
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.

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA

thanks for the repost of this Armen :)
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

Bernty

  • Newbie
  • *
  • Karma: 0
  • Posts: 1

My solution:
Code: [Select]
function menu_articles($start, $size) {
$cat_id = retrieve('id', 'categories', 'seftitle', get_id('category'));
$query = "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND published = 1";
$query .=($cat_id != '') ? " AND category = $cat_id" : "";
$query .= " ORDER BY date DESC LIMIT $start, $size";
$result = mysql_query($query);
if (!$result || !mysql_num_rows($result)) {
echo '<li>'.l('no_articles').'</li>';
}
else {
$home = l('home_sef');
while ($r = mysql_fetch_array($result)) {
$date = date(s('date_format'), strtotime($r['date']));
$categorySEF = find_cat_sef($r['category']);
$title = $r['category'] == 0 ? $home : retrieve('name', 'categories', 'seftitle', $categorySEF);
echo '<li><a href="'.db('website').$categorySEF.'/'.$r['seftitle'].'/" title="'.$title.' ('.$date.')">'.$r['title'].'</a></li>';
}
}
}

Logged