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.
Instructions:
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
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Configurations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
// 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);
require_once("$cutepath/inc/functions.inc.php");
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;
include("$cutepath/show_news.php");
}
?></div>
After making this file, add the following code so the list of categories may appear on your site
<?php
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'];
}
elseif(!isset($request['subaction']))
$category = DEFAULT_CATEGORY_HERE;
and change the value from true to false.
$display_categories_when_showing_news = TRUE;