EDITED W/Solution! Woohoo! 😀
One of our biggest gripes about our queue was always that we couldn’t tell how long stories had been sitting there. After successfully applying Ealdwulf’s 2.0 queue modification (thank you), I decided to bite the bullet, dig out my PHP book, and figure it out myself for 3.3.1. I hope this is as useful to others as it is for us! Before starting, back up your database AND the submitted.php file in your admin folder, AND stories.php.
Step One: Database Modification
In your fanfiction_chapters table, you want to add a field. I named mine "submittime" just to help keep things straight. Here's what you will add (essentially the same as the 2.0 edit):
FIELD: SUBMITTIME
TYPE: DATETIME
NULL: NOTNULL
I used phpMyAdmin to do this, although I am sure there are other ways. 🙂
Step Two: Edit submitted.php
In your admin folder, open submitted.php. Look for this:
$result = dbquery("SELECT story.title as storytitle, chapter.uid, chapter.sid, story.catid, chapter.chapid, chapter.inorder, chapter.title, "._PENNAMEFIELD." as penname FROM (".TABLEPREFIX."fanfiction_chapters as chapter, "._AUTHORTABLE.") LEFT JOIN ".TABLEPREFIX."fanfiction_stories as story ON story.sid = chapter.sid WHERE chapter.validated = '0' AND chapter.uid = "._UIDFIELD." ORDER BY story.title");
EDIT the code to look like this:
$result = dbquery("SELECT story.title as storytitle, chapter.uid, chapter.sid, story.catid, chapter.wordcount, chapter.chapid, chapter.inorder, chapter.title, chapter.submittime, "._PENNAMEFIELD." as penname FROM (".TABLEPREFIX."fanfiction_chapters as chapter, "._AUTHORTABLE.") LEFT JOIN ".TABLEPREFIX."fanfiction_stories as story ON story.sid = chapter.sid WHERE chapter.validated = '0' AND chapter.uid = "._UIDFIELD." ORDER BY story.title");
In the next line, change this:
if(dbnumrows($result)) {
$output .= "<table class="tblborder" cellspacing="0" cellpadding="0" style="margin: 0 auto; width: 90%;"><tr class="tblborder"><th>"._TITLE."</th><th>"._AUTHOR."</th><th>"._CATEGORY."</th><th>"._OPTIONS."</th></tr>";
to read this:
if(dbnumrows($result)) {
$output .= "<table class="tblborder" cellspacing="0" cellpadding="0" style="margin: 0 auto; width: 90%;"><tr class="tblborder"><th>"._TITLE."</th><th>"._WORDCOUNT."</th><th>".Submitted."</th><th>"._AUTHOR."</th><th>"._CATEGORY."</th><th>"._OPTIONS."</th></tr>";
And now look for this line:
if(isset($story['title'])) $output .= " <b>:</b> <a href=""viewstory.php?sid=$story[sid"]&chapter=$story[inorder]">".stripslashes($story['title'])."</a>";
AFTER that line, add these two:
$output .= "<td class="tblborder">".$story['wordcount']."</td>";
$output .= "<td class="tblborder">".$story['submittime']."</td>";
Modifications to stories.php
On or around line 187, change
$query2 = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_chapters (title, inorder, notes, endnotes, validated, wordcount, sid, uid, storytext) VALUES('".addslashes(($chaptertitle != "" ? $chaptertitle : $title))."', '$inorder', '".addslashes(format_story($notes))."', '".addslashes(format_story($endnotes))."', '$validated', '$wordcount', '$sid', '$uid', '".addslashes($storytext)."'");
to
$query2 = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_chapters (title, inorder, notes, endnotes, validated, wordcount, sid, uid, storytext, submittime) VALUES('".addslashes(($chaptertitle != "" ? $chaptertitle : $title))."', '$inorder', '".addslashes(format_story($notes))."', '".addslashes(format_story($endnotes))."', '$validated', '$wordcount', '$sid', '$uid', '".addslashes($storytext).", now()'");
And on or around line 201, change
$insertchapter = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_chapters (title, inorder, notes, endnotes, validated, wordcount, sid, uid) VALUES('".addslashes(($chaptertitle != "" ? $chaptertitle : $title))."', '$inorder', '".addslashes(format_story($notes))."', '".addslashes(format_story($endnotes))."','".($validated ? 1 : 0)."', '$wordcount', '$sid', '$uid'");
to
$insertchapter = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_chapters (title, inorder, notes, endnotes, validated, wordcount, sid, uid, submittime) VALUES('".addslashes(($chaptertitle != "" ? $chaptertitle : $title))."', '$inorder', '".addslashes(format_story($notes))."', '".addslashes(format_story($endnotes))."','".($validated ? 1 : 0)."', '$wordcount', '$sid', '$uid', now())");
Disclaimer: This works on my site. If it doesn't for you, I will probably not know why as I just started learning PHP Saturday. So I hope it works. Ealdwulf mentioned in the 2.0 version that it may make a difference whether your stories are in the DB or in files on the server--ours are in the stories folder. So if your eFic is set up different, it may not work for you.
URL to your eFiction: http://www.mickiclark.com/efiction33
Version of eFiction: 3.3.1
Have you bridged eFiction, if so with what?: SMF
Version of PHP:
Version of MySQL: MySQL 4.1.14
I figured out how to get them to display on the submitted page. When I am finished figuring out how to get it to write the timestamp to the table, I will post the rest of it.
EDIT: OK, I figured it out, so the modifications to stories.php are in the original post now.
URL to your eFiction: http://www.mickiclark.com/efiction33
Version of eFiction: 3.3.1
Have you bridged eFiction, if so with what?: SMF
Version of PHP:
Version of MySQL: MySQL 4.1.14
What does one mean by "submitted page"? :S
archive:
site:
Available for skin/mod commission! 🙂
Sorry--I meant that at first all I that figured out was how to create the columns in the table on submitted.php, but not how to make it display the correct timestamp in the column. It took me a bit longer to do that, but it's all in the original post now.
URL to your eFiction: http://www.mickiclark.com/efiction33
Version of eFiction: 3.3.1
Have you bridged eFiction, if so with what?: SMF
Version of PHP:
Version of MySQL: MySQL 4.1.14
I attempted to do this for 3.x, but gave up on it, so I'm glad to see someone else didn't! I've successfully got it working at my archive with no trouble.
I made one small change, however. In your very first change, right at the end, I changed ORDER by story.title to ORDER by chapter.submittime, so that it would sort by the time the chapter was submitted, since that's how the mods liked it. It seems to be working fine with my tests.
Given the 3.4 update, how should this be modified?
This is line "187" (now 231) with the part that's different from 3.3.x bolded:
$query2 = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_chapters (title, inorder, notes, endnotes, validated, wordcount, sid, uid, storytext) VALUES('".addslashes(($chaptertitle != "" ? $chaptertitle : $title))."', '$inorder', '".addslashes(format_story($notes))."', '".addslashes(format_story($endnotes))."', '$validated', '$wordcount', '$sid', '$uid', '".addslashes($storytext)."')");
This is line "201" (now 246) with the part that's different from 3.3.x bolded:
$insertchapter = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_chapters (title, inorder, notes, endnotes, validated, wordcount, sid, uid) VALUES('".addslashes(($chaptertitle != "" ? $chaptertitle : $title))."', '$inorder', '".addslashes(format_story($notes))."', '".addslashes(format_story($endnotes))."', '".($validated ? 1 : 0)."', '$wordcount', '$sid', '$uid')");
I wasn't sure if the endings were what was preventing this mod to work for me. Thanks in advance for any modifications you come up with!
Hi,
The topic title indicates adding word count to the submission page but in looking through your instructions, i don't see anything that adds it in. Am I just missing something? (I'm going to wait to implement this until we're sure we know how to make it work for 3.4.1.
My Site:
eFiction: v3.4.3
PHP: 5.2.4
MySQL: 5.0.27-standard
Mods: Challenges, Submit Time and Word Count
IntheMoonlight, you do add the word count to your submissions table. Since it already exists in fanfiction_chapters, you don't have to create the new field.
I've bolded the parts of the code that is used to include word count:
submitted.php:
$result = dbquery("SELECT story.title as storytitle, chapter.uid, chapter.sid, story.catid, chapter.wordcount, chapter.chapid, chapter.inorder, chapter.title, chapter.submittime, "._PENNAMEFIELD." as penname FROM (".TABLEPREFIX."fanfiction_chapters as chapter, "._AUTHORTABLE.") LEFT JOIN ".TABLEPREFIX."fanfiction_stories as story ON story.sid = chapter.sid WHERE chapter.validated = '0' AND chapter.uid = "._UIDFIELD." ORDER BY story.title");
if(dbnumrows($result)) {
$output .= "<table class="tblborder" cellspacing="0" cellpadding="0" style="margin: 0 auto; width: 90%;"><tr class="tblborder"><th>"._TITLE."</th><th>"._WORDCOUNT."</th><th>".Submitted."</th><th>"._AUTHOR."</th> <th>"._CATEGORY."</th><th>"._OPTIONS."</th></tr>";
$output .= "<td class="tblborder">".$story['wordcount']."</td>";
stories.php already contains wordcount information so there's nothing pertaining to that that you need to modify.
I think I've got it...
For the timestamp mod for 3.4.0+
submitted.php remains the same as 3.3.1.
In Stories.php:
Find this (around line 231):
$query2 = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_chapters (title, inorder, notes, endnotes, validated, wordcount, sid, uid, storytext) VALUES('".addslashes(($chaptertitle != "" ? $chaptertitle : $title))."', '$inorder', '".addslashes(format_story($notes))."', '".addslashes(format_story($endnotes))."', '$validated', '$wordcount', '$sid', '$uid', '".addslashes($storytext)."')");
and replace with:
$query2 = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_chapters (title, inorder, notes, endnotes, validated, wordcount, sid, uid, storytext, submittime) VALUES('".addslashes(($chaptertitle != "" ? $chaptertitle : $title))."', '$inorder', '".addslashes(format_story($notes))."', '".addslashes(format_story($endnotes))."', '$validated', '$wordcount', '$sid', '$uid', '".addslashes($storytext)."', now())");
Find this (around line 246):
$insertchapter = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_chapters (title, inorder, notes, endnotes, validated, wordcount, sid, uid) VALUES('".addslashes(($chaptertitle != "" ? $chaptertitle : $title))."', '$inorder', '".addslashes(format_story($notes))."', '".addslashes(format_story($endnotes))."', '".($validated ? 1 : 0)."', '$wordcount', '$sid', '$uid')");
and replace with:
$insertchapter = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_chapters (title, inorder, notes, endnotes, validated, wordcount, sid, uid, submittime) VALUES('".addslashes(($chaptertitle != "" ? $chaptertitle : $title))."', '$inorder', '".addslashes(format_story($notes))."', '".addslashes(format_story($endnotes))."', '".($validated ? 1 : 0)."', '$wordcount', '$sid', '$uid', now())");
Works fine for me 🙂
Hey Marauder by Midnight:
I'm stuck! I was able to create the new field and was able to update submitted but when i try to find the code in stories, (I'm using the find function in notepad) it says it can't find it. I checked my stories.php file from 3.3.1 and got the same results (as in it can't find it).
Scratch that! I was looking at the wrong file! I thought we were still in admin..duh! *smacks self*. I apologize for my uber stupidness
EDIT: Ok so it works. I unvlidated myself and then submitted just to test. I went into the admin paenl and it said i had 2 chapters waiting when I only had 1. Does anyone know if this a bug or even related to the mod?
My Site:
eFiction: v3.4.3
PHP: 5.2.4
MySQL: 5.0.27-standard
Mods: Challenges, Submit Time and Word Count
Just adding in that I have changed everything to what has been said here, and the mod works for me. For a new user of the mod (like I am), when you forst change the code, any stories in the Submissions queue will have a date and time set at 0, but all new submissions will show up the correct date and time 🙂
Thanks to everyone who fixed/changed/updated this mod, it will come in handy for me 🙂
I know this is a stupid question but I cannot figure out how to do the database insert, can anyone show me a jpg view of the steps? I find it much easier that way 🙂 or at least explain how to add a field into fanfic chapters
Thank you so much for this. Worked perfect right away.
I have a question on how to take this one step further.
We use the “Tracker” mod that allows you to track stories and on story info you find when you last read the story. To make this mod way more useful I would like to use the new “SUBMITTIME” field on the wiewstory.php so that each chapters submit time is displayed next to the chapter name, author and word count. How would I best achieve this? Any ideas?
