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: [MOD] Display Extra Articles on Category pages (sNews v1.4)  (Read 2705 times)

gomisan

  • Full Member
  • ***
  • Karma: 0
  • Posts: 194
    • http://fish-cam.net/
[MOD] Display Extra Articles on Category pages (sNews v1.4)
« on: April 15, 2006, 10:37:53 am »

I wanted to be able to show just a few 'latest articles' on the home pages, but when viewing a particular category I wanted to be able to see more articles. So I banged together the following mod.

Instead of using center(4) I now use, extra_center(4,12), which displays 4 articles on the Home page, and 12 on any other category.

First, pop this function in just after get_id or one of the other similar functions.

Code: [Select]
// FIND CATEGORY'S ID THROUGH SEF TITLE
function find_cat_id($categorysef) {
$query = "SELECT id FROM " .s('prefix'). "categories WHERE seftitle = '$categorysef'";
$result = mysql_query($query);
  while ($r = mysql_fetch_array($result)) {
  $cat_id = $r['id'];  
}
if (isset($cat_sef)) {
$cat_sef_title = $cat_sef;

}
return $cat_id;
}

then, add the following function. I added it just after 'display_categories' but only because I was in a hurry :)

Code: [Select]
// DISPLAY EXTRA CENTER ARTICLES
function extra_center($cat_zero, $cat_other) {
$current_sef = get_id('category');
$current_id = find_cat_id($current_sef);
if ($current_id <> 0) {
center($cat_other);
} else {
center($cat_zero);
}
}

now instead of center use:

Code: [Select]


Hope someone finds this useful, or perhaps a similar thing could be included in a release version, as it's pretty simple function to include for versatility. If it's likely to break anything, can someone let me know !!

(Edited to show sNews version this applies to)
Logged
Check out my sNews powered Tropical Fishtank site, live Fish-Cam !!

bryn

  • Hero Member
  • *****
  • Karma: 2
  • Posts: 934
    • http://www.cssugly.com
[MOD] Display Extra Articles on Category pages (sNews v1.4)
« Reply #1 on: April 15, 2006, 11:33:01 am »

nice work gomisan..not tested this yet but if it works and doesnt cause any problems it's a nice mod to have ;D
Logged
Over 1,000 posts of joy, sNews is not only brilliant, but fun too! thanks guys :D