1 (edited by 2011-07-06 18:35:19)

Topic: [HACK] List Categories

Name: List categories
Author: unknown
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: Add a list of categories on your site. Each category will link articles from that category.

make a file. Call it "list_cats.php" and put it in the CuteNews root directory.
<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'><?PHP
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

// If it is set to FALSE, the categories wont be displayed
// after a visitor click some category to see the news from it
  $display_categories_when_showing_news = TRUE;
$display_news_under_list = TRUE;

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Main Part (Do not edit below)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
$cutepath =  __FILE__;
$cutepath = preg_replace( "'\\\list_cats\.php'", "", $cutepath);
$cutepath = preg_replace( "'/list_cats\.php'", "", $cutepath);


if(($show_cat != "" and $display_categories_when_showing_news == TRUE) or $show_cat == ""){
    $cat_lines = file("$cutepath/data/category.db.php") or die("Can not open $cutepath/data/category.db.php");
    foreach($cat_lines as $cat_line){
        $cat_arr = explode("|", $cat_line);
        echo "[url=]{$cat_arr[1]}[/url]
if(isset($_GET['show_cat']) && preg_match('/^[1-9]{1}[0-9]{0,}$/', $_GET['show_cat'] && $display_news_under_list)){
    $category = $show_cat;
After making this file, add the following code so the list of categories may appear on your site

include( 'path_to_cutenews/list_cats.php' );

now use the following code for your CN include code if you don't want a list of articles in  the chosen category to appear under the category list, but shown instead of regualr news.

if(isset($_GET['show_cat']) && preg_match('/^[1-9]{1}[0-9]{0,}$/', $_GET['show_cat']))
$category = $_GET['show_cat'];

and change the value from true to false.

$display_categories_when_showing_news = TRUE;

Re: [HACK] List Categories

Name: Excluding categories from the list
Author: FUNimations
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: In case you want to keep 1 or more categories secret.
Requirements: List categories
in list_cats.php find

$cat_arr = explode("|", $cat_line);

When excluding 1 category add below

if( $cat_arr[0] == # ) continue;

where # must be the category ID

When excluding more then 1 category add below

if( in_array( $cat_arr[0], array( #,#, ) ) ) continue;

where #,#, must be replaced by the category ID's