Ok, I decided to give writing a news mod a try but I ran into a little bit of a snag....as I'm 90% done with it.
I've installed a test efiction site for this mod because I had to tinker with some tables....ok half of them.
I've inserted news categories into various tables and wrote the script for it so the news SHOULD have it something like this:
My news
this is my news article
By: Moonbrat Date: 2007.03.09 Category: General
And then in the archive, it SHOULD do:
News for: March 2007
And have all the news listed under that month to be shown...
And also have the option to display by category e.g. general (1)
In the admin section (I know it works) is the news categories...add/edit/delete and the news form....which brings me to my problem:
I have no idea how to get my news categories table to echo its variables for display (like in the story form)...as I'm not sure if it's just joined onto select * from news or if it's a complete different query to select * from newscategories. I have the jist of things, but joining tables gets way over my head....
So why I say SHOULD for my mod, is because I can't 100% test it if I can't select my categories to add my news for a test. The form is 100% done...like this:
author
title
category
text
(The category selection is set up identical to the storyform but it's showing blank >_< and the only real thing I've changed with the categories code is adding news infront of categories for the table, my news table now has category and catid added into it.)
I like life, it's something I do when I'm bored
@}----- http://www.midnight-sonnet.net ----
So your mod is to add categories for news?
When asking for mod help, you should probably post the code you are using and modified.
Whoever said nothing is impossible never tried slamming a revolving door.
url: https://www.potionsandsnitches.org/fanfiction
php: 7.4.33 msql: 5.6.51-community GPL
efic version: 3.5.5 latest patches: yes
bridges: none mods: challenges, tracker, story end, beta, word
Yes it's a mod for the setting up news categories to neaten up the news archives and easier to refer to e.g. site changes, new features etc. instead of wading through countless news items trying to remember what day something was posted or what page shows it.
I purposely didn't post the news code here cos I kept tinkering with it... but anyways, here is the news form file--forgive the messiness, I'm still tinkering with it:
<?php
// ----------------------------------------------------------------------
// eFiction 3.2
// Copyright (c) 2007 by Tammy Keefer
// Valid HTML 4.01 Transitional
// Based on eFiction 1.1
// Copyright (C) 2003 by Rebecca Smallwood.
// http://efiction.sourceforge.net/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
if(!defined("_CHARSET")) exit( );
$output .= "<div id="pagetitle">"._NEWS."</div>";
if(isset($_POST['submit'])) {
$title = addslashes(strip_tags(descript($_POST['title']), $allowed_tags));
$category = addslashes(strip_tags(descript($_POST['category']), $allowed_tags));
$author = addslashes(strip_tags(descript($_POST['author']), $allowed_tags));
$story = addslashes(strip_tags(descript($_POST['story']), $allowed_tags));
if($_GET['form'] == "new") $result = dbquery("INSERT INTO ".$tableprefix."fanfiction_news (catid, category, title, author, story, time) VALUES ('$catid', '$category', '$title', '$author', '$story', now())");
else $result = dbquery("UPDATE ".$tableprefix."fanfiction_news SET catid = '$catid', category = '$category' title = '$title', author = '$author', story = '$story' WHERE nid = '$_POST[nid]'");
if($result) {
$output .= write_message(_ACTIONSUCCESSFUL);
unset($_GET['form']);
}
else $output .= write_error(_ERROR." ".TRYAGAIN);
}
if(isset($_GET['delete']) && isNumber($_GET['delete'])) {
if($_GET['confirm'] == "yes") {
dbquery("DELETE FROM ".$tableprefix."fanfiction_news where nid = '".$_GET['delete']."'");
$output .= write_message(_ACTIONSUCCESSFUL);
}
else if ($_GET['confirm'] == "no") $output .= write_message(_ACTIONCANCELLED);
else {
$output .= write_message(_CONFIRMDELETE."<br /><br />
[ <a href=""admin.php?action=news&confirm=yes&delete=$_GET[delete"]">"._YES."</a> | <a href=""admin.php?action=news&confirm=no&delete=$_GET[delete"]">"._NO."</a> ]");
}
}
else if(isset($_GET["form"])) {
if($_GET["form"] != "new" && isNumber($_GET["form"])) {
$result = dbquery("SELECT * FROM ".$tableprefix."fanfiction_news WHERE nid = '".$_GET['form']."' LIMIT 1");
$newsitem = dbrow($result);
}
else $newsitem = array("title" => "", "category" => "", "author" => "", "story" => "");
$output .= "<form method="POST" enctype="multipart/form-data" action="admin.php?action=news&form=$_GET[form]">
<table align="center"><tr><td colspan="2" align="center"><b>".($_GET["form"] == "new" ? _ADDNEWS : _EDITNEWS)."</b></td></tr>
<tr><td>"._AUTHOR.": </td><td><INPUT type="text" class="textbox=" name="author" value="".stripslashes($newsitem['author']).""></td></tr>
<tr><td>"._TITLE.": </td><td><INPUT type="text" class="textbox=" name="title" value="".stripslashes($newsitem['title']).""></td></tr>
<tr><td>"._CATEGORY.": </td><td>";
if(!isset($catid)) $catid = array( );
$cats = explode(",", $stories[catid]);
if(count($cats) == 1) $newcat = "-1";
else $newcat = implode(",", array_dif($cats, array($catid)));
$output .= "<div style='width: 99.9%; float: left;'>rn
<div style='width: 40%; float: left;'><label for='catoptions'>"._CATOPTIONS."</label><br />
<select name='catoptions' id='catoptions' multiple='multiple' size='8' onchange='resetCats("catoptions");' style='width: 100%;'>";
$selectedCats = "";
foreach($catlist as $cat => $info) {
if($info['pid'] == -1)
$output .= "<option value='$cat'".(isset($info['locked']) ? " class='locked'" : "").">".$info['name']."</option>rn";
if((is_array($catid) && in_array($cat, $catid)) && $info['locked'] != 1) {
$selectedCats .= "<option value='$cat'>".$info['name']."</option>rn";
$cats[] = $cat;
}
}
$output .= "</select></div>
<div style='float: left; width: 20%; text-align: center; padding-top: 3em;'>
<input type='button' class='button' value='>' name='Select' onClick='addCat("catoptions", "selectCats");'><br /><br />
<input type='button' class='button' value='"._REMOVE."' onClick='removeCat("selectCats");'>
</div>
<div style='width: 40%; float: left;'>
<label for='catoptions'>"._SELECTCATS."</label><br />
<select name='selectCats' id='selectCats' multiple='multiple' size='8' style='width: 100%;'>".
(isset($selectedCats) ? $selectedCats : "")."</select></div>
</div>
<input type='hidden' name='catid' id='catid' value='".(isset($cats) ? implode(",", $cats) : "")."'>";
$output .="</td></tr>
<tr><td>"._TEXT.": </td><td><textarea class="textbox" name="story" id="story" COLS="45" ROWS="6">".stripslashes($newsitem['story'])."</TEXTAREA>";
if($tinyMCE)
$output .= "<div class='tinytoggle'><input type='checkbox' name='toggle' onclick="toogleEditorMode('story');" checked><label for='toggle'>"._TINYMCETOGGLE."</label></div>";
$output .= "</td></tr><tr><td colspan="2" align="center">".($_GET["form"] != "new" ? "<INPUT type="hidden" name="nid" value="".$_GET['form']."">" : "")."<INPUT type="submit" class="button" name="submit" value=""._SUBMIT.""></td></tr></table></form>";
}
else {
$output .= "<p align="center"><a href=""admin.php?action=news&form=new">"._ADDNEWS."</a></p>";"
$count = dbquery("SELECT COUNT(nid) FROM ".$tableprefix."fanfiction_news");
list($numrows)= dbrow($count);
$result = dbquery("SELECT n.*, UNIX_TIMESTAMP(n.time) as date, count(c.cid) as comments FROM ".$tableprefix."fanfiction_news as n LEFT JOIN ".$tableprefix."fanfiction_comments as c ON n.nid = c.nid GROUP BY n.nid ORDER BY time DESC LIMIT $offset, $itemsperpage");
if(file_exists("$skindir/newsbox.tpl")) $news = new TemplatePower( "$skindir/newsbox.tpl" );
else $news = new TemplatePower( "default_tpls/newsbox.tpl" );
$news->prepare();
$count = 0;
while($stories = dbassoc($result)) {
$news->newBlock("newsbox");
//assign values
$news->assign("newstitle" , "<a href=""news.php?action=newsstory&nid=".$stories['nid'"]."">".$stories['title']."</a>" );
$news->assign("newscategory" , "<a href=""news.php?action=newsstory&catid=".$stories['catid'"]."">".$stories['category']."</a>" );
$news->assign("newsstory" , $stories['story'] );
$news->assign("newsauthor", $stories['author'] );
$news->assign("newsdate", date("$dateformat $timeformat", $stories['date']) );
$news->assign("oddeven", ($count % 2 ? "even" : "odd"));
if($newscomments == "1")
$news->assign("newscomments", "<a href=""news.php?action=newsstory&nid=".$stories['nid'"]."">".$stories['comments']." "._COMMENTS."</a>");
if(isset($adminloggedin))
$news->assign("adminoptions", "<a href=""admin.php?action=news&form=".$stories['nid'"]."">"._EDIT."</a> | <a href=""admin.php?action=news&delete=".$stories['nid'"]."">"._DELETE."</a>");
$count++;
}
$news->gotoBlock("_ROOT");
$output .= $news->getOutputContent( );
if($numrows > $itemsperpage) $output .= build_pagelinks("admin.php?action=news&", $numrows, $offset);
}
?>
So, I need to write in somehow (cos I know its missing in the coding) this:
Select * from ".$tableprefix."fanfiction_newscategories WHERE catid = '".$_GET['form']."' LIMIT 1"
Or something like that...or use the join code with the news table selection...I'm still tinkering with the code but like I said, I need something to call the category field from the news table when displaying the news, and the categories from the news categories table...
Sounds complicated I know....but I thought I'd try using efiction's category set up since well this is an efiction mod....
I like life, it's something I do when I'm bored
@}----- http://www.midnight-sonnet.net ----
