You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 54 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - can't add/edit categories in the news module [ ]
 Forum FAQ  •  Search  •   •  Memberlist  •  Usergroups   •  Register  •  Profile •    •  Log in to check your private messages  •  Log in

 
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
Author Message
mdwong
Nuke Cadet
Nuke Cadet


Joined: Aug 07, 2005
Posts: 7


PostPosted: Thu Aug 11, 2005 9:18 pm Reply with quoteBack to top

ok I have 7.7 installed with patch 3 and i recently installed sentinal. For some reason I can't add or edit categories. It says "this category already exists". not sure whats going on.

I read a post in regards to 7.0 that says that you have to edit admin/modules/stories.php which is not there. I did look at modules/news/admin/index.php not sure if this is what I need to edit but the code looks similar. here's the code
Quote:
function SaveEditCategory($catid, $title) {
global $prefix, $db, $admin_file;
$title = ereg_replace("\"","",$title);
$result = $db->sql_query("select catid from ".$prefix."_stories_cat where title='$title'");
$catid = intval($catid);
$check = $db->sql_numrows($result);
if ($check) {
$what1 = _CATEXISTS;
$what2 = _GOBACK;
} else {
$what1 = _CATSAVED;
$what2 = "[ <a href=\"".$admin_file.".php\">"._GOTOADMIN."</a> ]";
$result = $db->sql_query("update ".$prefix."_stories_cat set title='$title' where catid='$catid'");
if (!$result) {
return;
}
}


Thanks in advance for any help
Find all posts by mdwongView user's profileSend private message
arnoldkrg
Major
Major


Joined: Aug 03, 2003
Posts: 936

Location: United Kingdom

PostPosted: Fri Sep 02, 2005 11:09 pm Reply with quoteBack to top

I have just discovered what appears to be a bug in the News module. I discovered this in a Nuke 7.7 patched 3.1 site but it may exist in an unpatched version. When you try to add a category the bug causes the category to be saved as News and not the category you tried to add. So when you next try to add another category, it again tries to save it as News (but that already exists because that is what the last category was saved as) and so it tells you that the category already exists.

The Bug will also cause any changes to the Category title to be saved as News when editing a category.

Here is an example of the bug at work when you try to add a category.

Right at the beginning of modules/News/admin/index.php you will find the following:
Code:
$query = $db->sql_query("SELECT title, admins FROM ".$prefix."_modules WHERE title='$module_name'");
list($title, $admins) = $db->sql_fetchrow($query);


This assigns the value News to $title and no matter which value of $title was passed to index.php, it will be reassigned the value News.

When we add a category the name of the Title field for the category is title thus:
Code:
."<input type=\"text\" name=\"title\" size=\"22\" maxlength=\"20\"> "


So the Title is passed as $title and is immediately assigned a new value News.

This can be fixed as follows (I have only done this for Adding a category, but similar changes can be made when editing a category too)

In modules/News/admin/index.php find
Code:
   function AddCategory () {
      global $admin_file;
      include ("header.php");
      GraphicAdmin();
      OpenTable();
      echo "<center><font class=\"title\"><b>"._CATEGORIESADMIN."</b></font></center>";
      CloseTable();
      echo "<br>";
      OpenTable();
      echo "<center><font class=\"option\"><b>"._CATEGORYADD."</b></font><br><br><br>"
      ."<form action=\"".$admin_file.".php\" method=\"post\">"
      ."<b>"._CATNAME.":</b> "
      ."<input type=\"text\" name=\"title\" size=\"22\" maxlength=\"20\"> "
      ."<input type=\"hidden\" name=\"op\" value=\"SaveCategory\">"
      ."<input type=\"submit\" value=\""._SAVE."\">"
      ."</form></center>";
      CloseTable();
      include("footer.php");
   }

and change to:
Code:
   function AddCategory () {
      global $admin_file;
      include ("header.php");
      GraphicAdmin();
      OpenTable();
      echo "<center><font class=\"title\"><b>"._CATEGORIESADMIN."</b></font></center>";
      CloseTable();
      echo "<br>";
      OpenTable();
      echo "<center><font class=\"option\"><b>"._CATEGORYADD."</b></font><br><br><br>"
      ."<form action=\"".$admin_file.".php\" method=\"post\">"
      ."<b>"._CATNAME.":</b> "
      ."<input type=\"text\" name=\"ctitle\" size=\"22\" maxlength=\"20\"> "
      ."<input type=\"hidden\" name=\"op\" value=\"SaveCategory\">"
      ."<input type=\"submit\" value=\""._SAVE."\">"
      ."</form></center>";
      CloseTable();
      include("footer.php");
   }

Above, I have changed the name of the _CATNAME field from title to ctitle.

Next find:
Code:
   function SaveCategory($title) {
      global $prefix, $db;
      $title = ereg_replace("\"","",$title);
      $result = $db->sql_query("select catid from ".$prefix."_stories_cat where title='$title'");
      $check = $db->sql_numrows($result);
      if ($check) {
         $what1 = _CATEXISTS;
         $what2 = _GOBACK;
      } else {
         $what1 = _CATADDED;
         $what2 = _GOTOADMIN;
         $result = $db->sql_query("insert into ".$prefix."_stories_cat values (NULL, '$title', '0')");


and change to:
Code:
   function SaveCategory($ctitle) {
      global $prefix, $db;
      $ctitle = ereg_replace("\"","",$ctitle);
      $result = $db->sql_query("select catid from ".$prefix."_stories_cat where title='$ctitle'");
      $check = $db->sql_numrows($result);
      if ($check) {
         $what1 = _CATEXISTS;
         $what2 = _GOBACK;
      } else {
         $what1 = _CATADDED;
         $what2 = _GOTOADMIN;
         $result = $db->sql_query("insert into ".$prefix."_stories_cat values (NULL, '$ctitle', '0')");


Above I have replaced all instances of $title with $ctitle.

Next find:
Code:
      case "SaveCategory":
      SaveCategory($title);
      break;


and change to:
Code:
      case "SaveCategory":
      SaveCategory($ctitle);
      break;


This will fix the bug when adding categories. Similar changes need to be made when editing categories too.

_________________
Image
Find all posts by arnoldkrgView user's profileSend private messageSend e-mailVisit poster's website
Evaders99
Site Admin
Site Admin


Joined: Aug 17, 2003
Posts: 12397


PostPosted: Sun Sep 04, 2005 7:29 pm Reply with quoteBack to top

Thanxs for the report - second confirmation of this problem
Hope we'll release a fixed version in the next Patched

_________________
Helping those that help themselves
Read FIRST or DIE!

"Fighting is terrible, but not as terrible as losing the will to fight."
Star Wars Rebellion Network - Need Help? Evaders Squadron Coding
Find all posts by Evaders99View user's profileSend private messageVisit poster's websiteAIM Address
scz
Nuke Soldier
Nuke Soldier


Joined: Apr 07, 2004
Posts: 27


PostPosted: Wed Sep 14, 2005 9:00 am Reply with quoteBack to top

how can i then select a specific category to show in the news homepage.

_________________
free articles
free article submission
Find all posts by sczView user's profileSend private messageVisit poster's website
Display posts from previous:      
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2005 phpBB Group

Ported by Nuke Cops © 2003 www.nukecops.com
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::
Powered by · TOGETHER TEAM srl ITALY http://www.togetherteam.it · DONDELEO E-COMMERCE http://www.DonDeLeo.com
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.249 Seconds - 232 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::