Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [mini-MOD] More Categories Lists 1.5, 1.6  (Read 1892 times)

Pali

  • Full Member
  • ***
  • Karma: 16
  • Posts: 111
    • LE-PAVON
[mini-MOD] More Categories Lists 1.5, 1.6
« on: August 30, 2007, 12:47:21 pm »

sNews: 1.5, 1.6
Purpose: sometimes we need to show only few categories - not all of them... sometimes we need to have 2 or more different lists of categories (this can be usable for http://snewscms.com/forum/index.php?topic=3450.0 )

Edited: 31.8.07 - old code was working only with sNews enhanced (Keyrock's)

This MOD is using catorder number definied in administration. We call function categories by a little different way. Example bellow will show only categories with numbers from 1 to 9...
Code: [Select]
<?php categories(1,9); ?>


Needed modification of snews.php:
Just replace old categories function with this one:
Code: [Select]
// DISPLAY CATEGORIES

# same as 1.5.31

function categories($cat_start,$cat_end) {
if (!$cat_start) {$cat_start = 0; $cat_end = 1000;}

$categorySEF = get_id('category');

$class = $category_title == $categorySEF ? ' class="current"' : '';

# disabled "Home" in categories (piXelatedEmpire)

// echo '<li><a'.$class.' href="'.db('website').'" title="'.l('home').'">'.l('home').'</a></li>';

$query = "SELECT * FROM ".db('prefix')."categories WHERE published = 'YES' AND catorder >= $cat_start AND catorder <= $cat_end ORDER BY catorder ASC";
 //     if using sNews enhanced comment line above and uncomment line bellow
 //       $query = "SELECT * FROM ".db('prefix')."".gl('categories_table')." WHERE published = 'YES' AND catorder >= $cat_start AND catorder <= $cat_end ORDER BY catorder ASC";

$result = mysql_query($query);

while ($r = mysql_fetch_array($result)) {

$calc_num_query = "SELECT * FROM ".db(prefix)."articles WHERE position = 1 AND category = $r[id] AND published = 1";

 //     if using sNews enhanced comment line above and uncomment line bellow
//      $calc_num_query = "SELECT * FROM ".db(prefix)."".gl('articles_table')." WHERE position = 1 AND category = $r[id] AND published = 1";
$cm_result = mysql_query($calc_num_query);

$num_rows = mysql_num_rows($cm_result);

$category_title = $r['seftitle'];

$class = $category_title == $categorySEF ? ' class="current"' : '';

echo '<li><a'.$class.' href="'.db('website').$category_title.'/" title="'.$r['description'].'">'.$r['name'];

echo (s('num_categories') == 'on' ? ' ('.$num_rows.')' : '').'</a></li>';

}}

Site using this MOD: www.travelpoint.sk (top menu is showing different categories as Katalog displayed on homepage...)
« Last Edit: August 31, 2007, 09:51:58 pm by Pali »
Logged
I like sNews!

Rui Mendes

  • Development,Testing, Support
  • Hero Member
  • *****
  • Karma: 195
  • Posts: 1009
  • sNews1.7
    • Comunidade Portuguesa
Re: [mini-MOD] More Categories Lists 1.5, 1.6
« Reply #1 on: August 30, 2007, 11:07:29 pm »

Smart  :D

Another Karma
Logged
Need a Job on Europe. Linkdin - Facebook / Group