Home N-13 News Forums Help Search
RegisterForgot password?
How to add image to post necklacesdiscou
Known bugs - 4.0.3 necklacesdiscou

Latest N-13 News 4.0.3

What is N-13 News?
Where can I get help?
Known bugs

Forums Help & Support Pagination problem with restricted categories
Sallyc
Posted on 18 Apr 2011, 00:12:20

Access: Member
Total Posts: 61
Joined: 2011-02-25

I am trying to implement the N-13 Wiki code sample that allows you to "Show articles that are NOT assigned to specified categories." It works fine on my test page except that clicking on any link in the Older News section, which should show you the rest of the articles not assigned to specified categories, shows all articles.

I think this is related to my having friendly URLs, but I can't figure out how to modify the template so this works.

Chris, RayC or anyone - please?
#3434
Sallyc
Posted on 20 Apr 2011, 17:22:20

Access: Member
Total Posts: 61
Joined: 2011-02-25

Has anybody implemented the Wiki help code and needed more than one page to show results?

The code is:
<?php
require_once('news/db.php');
require_once('news/config.php');


// Specify here which categories you DON'T want to use
$nocats = array();
$nocats[] = "Cat1";
$nocats[] = "Cat2";
$nocats[] = "Cat4";

// Grab all existing categories so we can check if the ones specified above exists or not
$allcats = DataAccess::fetch("SELECT id, name FROM " . NEWS_CATS);
$j = 0;
$nocatids = array();
foreach($allcats AS $acat){
if(in_array($acat['name'],$nocats)){
// Categories which do exist get added to the $nocatids array
$nocatids[] = $acat['id'];
$j++;
}
}

// Implode the $nocatids array so that it can be used in a query to select all other categories
$nocatids = implode(",", $nocatids);
$nocats = DataAccess::fetch("SELECT name FROM " . NEWS_CATS . " WHERE id NOT IN ($nocatids)");

unset($cat);
$cat = array();
foreach($nocats AS $nocat){
// Assign all the selected categories to the $cat array
$cat[] = $nocat['name'];
}

include 'news/index.php';
?>

but if there's more than one page of code and you are using Friendly URL's, clicking on the next page link brings you articles in the $nocatids group. What I need is a way to limit the next page to the categories not listed in $nocatids.

I'm really stuck here - any help would be appreciated.
#3436
Network-13.com © 2013