Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [MOD] Dynamic Categories listing (sNews 1.5RC2)  (Read 4101 times)

Armen

  • Sr. Member
  • ****
  • Karma: 41
  • Posts: 338
    • http://www.funnydays.ru
[MOD] Dynamic Categories listing (sNews 1.5RC2)
« on: October 19, 2006, 07:43:07 PM »

My website is going to have tutorials, so, obviously, I need at least 2-level subdirectories.

At the moment I'm only able to use "categories" as "subpages" (sNews 1.5 RC2).

For the page, that will list all the tutorials and categories (except Home, for that was the idea) I wrote this (based on Sitemap function).

Just put it after any function.

Code: [Select]
//CATEGORYPAGE
function catpage() {
$link =  ' $query = "SELECT * FROM ".db('prefix')."articles WHERE position = 3 AND published = '1' ORDER BY id";
$result = mysql_query($query);
$home = s('home_sef');
$art_query = "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND published = '1'";
$query = $art_query." AND category = 0 ORDER BY date DESC";
$result = mysql_query($query);
echo '';
$cat_query = "SELECT * FROM ".db('prefix')."categories WHERE published = 'YES'";
$cat_result = mysql_query($cat_query);
while ($c = mysql_fetch_array($cat_result)) {
echo '

'.$c['name'].'

    ';
    $catid = $c['id'];
    $query = $art_query." AND category = $catid ORDER BY id DESC";
    $result = mysql_query($query);
    while ($r = mysql_fetch_array($result)) {
    $date = date(s('date_format'), strtotime($r['date']));
    echo '
  • ';
    echo $link.$c['seftitle'].'/'.$r['seftitle'].'/" title="'.$r['title'].'">'.$r['title'].'
  • ';
    }
    echo '
';
}}
It's also styleable, because it's a valid list now.

Add this to your Index.php to call the function:

Code: [Select]
Here's the result:

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.

BaCKStagE

  • Newbie
  • *
  • Karma: 0
  • Posts: 27
[MOD] Dynamic Categories listing (sNews 1.5RC2)
« Reply #1 on: October 19, 2006, 10:44:23 PM »

Hi

Thanks ur Mini Mod.

Himm maybe added your demo mod site ?
Logged
Himmmm?

Armen

  • Sr. Member
  • ****
  • Karma: 41
  • Posts: 338
    • http://www.funnydays.ru
[MOD] Dynamic Categories listing (sNews 1.5RC2)
« Reply #2 on: October 20, 2006, 08:16:20 AM »

Added a preview ;)
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.