Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Author Topic: [Mini-MOD] Description under categories  (Read 2801 times)

centered

  • Guest
[Mini-MOD] Description under categories
« on: August 16, 2007, 12:16:44 pm »

If you want to show the category description under the category listing...

See the last line...
Code: [Select]
function categories() {
$categorySEF = get_id('category');
$class = $category_title == $categorySEF ? ' class="current"' : '';
// echo '<li><a'.$class.' href="'.db('website').'" title="'.l('home').'">'.l('home').'</a></li>';
$query = "SELECT * FROM ".db('prefix')."categories WHERE published = 'YES' 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";
$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>';
               // ADDED DESCRIPTION TO SHOW UNDER CATEGORY
echo '<li class="catdesc">'. $r['description'] .'</li>';
}}
For the css I just added:
Code: [Select]
.catdesc { padding-left: 10px; }And you get something like this:
« Last Edit: August 21, 2007, 08:00:55 pm by Phil Martin »
Logged

Ghassem Tofighi

  • Full Member
  • ***
  • Karma: 9
  • Posts: 104
    • http://ght.ir
[Mini-MOD] Description under categories
« Reply #1 on: August 16, 2007, 11:23:36 pm »

ok, nice mod. please add a feature. add a  field of icon for assigning an icon to category.
can you write a mod to do same for each article?
Logged
Be A Color Pencil For Painting The World !

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
[Mini-MOD] Description under categories
« Reply #2 on: August 17, 2007, 03:30:50 am »

Nice MOD centered it's useful :)
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

centered

  • Guest
[Mini-MOD] Description under categories
« Reply #3 on: August 17, 2007, 06:35:00 pm »

Thanks pixelated!

Ght, I am sure you can use CSS to add an icon for the categories, if you want it globally.  The categories and articles, if you want for each, may need some php, but I am sure it can be done. No promises though on my end.
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: [Mini-MOD] Description under categories
« Reply #4 on: August 21, 2007, 06:51:39 pm »

Description is useful for a lot of things. This is a great MOD, thanks.
Logged

centered

  • Guest
Re: [Mini-MOD] Description under categories
« Reply #5 on: August 22, 2007, 01:51:52 pm »

Hey no problem agent, I figured it was there, why not utilize it!!
Logged