Hi everyone. I've been working on a mod/block for eFiction to add a "Table of Contents" listing to the story listing pages using the "storyblock" hook.
I copied most of Tammy's viewstory.php code as pertains to the index (I've added "c" before most variables just to make sure there are no collisions), and it works great on my index.php "recent" block. However whenever I load it on the "listings" pages like browse.php?type=titles it wipes out all the other field (except for read count). I'm pasting my code below as well as a screenshot of what the page looks like when it tries to load the code.
You can see a full example of it working on this index page: http://lgtales.com/stories/index.php
modules/miscblocks/toc.php:
if(!defined("_CHARSET")) exit( );
$cinfo = dbquery("SELECT chap.* FROM ".TABLEPREFIX."fanfiction_chapters as chap WHERE sid = '".$stories['sid']."' AND chap.validated > 0 ORDER BY inorder");
$ccount = 0;
while($chap = dbassoc($cinfo)) {
$tpl->newBlock("tocblock");
$tpl->assign("cchapternumber", $chap['inorder']);
$tpl->assign("ctitle", "<a href=""viewstory.php?sid=".$stories['sid'"]."&chapter=".$chap['inorder']."">".$chap['title']."</a>");
$tpl->assign("cprinticon", "<a href=""viewstory.php?action=printable&textsize=$textsize&sid=".$stories['sid'"]."&chapter=".$chap['inorder']."" target="_blank"><img src="'".(isset($printer)" ? $printer : "images/print.gif")."' border='0' alt='"._PRINTER."'></a>");
if($reviewsallowed) {
$tpl->assign("creviews", "<a href=""reviews.php?type=ST&item=".$stories['sid'"]."&chapid=".$chap['chapid']."">"._REVIEWS."</a>");
$tpl->assign("cnumreviews", "<a href=""reviews.php?type=ST&item=".$stories['sid'"]."&chapid=".$chap['chapid']."">".$chap['reviews']."</a>");
}
$tpl->assign("cwordcount", $chap['wordcount']);
$tpl->assign("ccount", ($chap['count'] ? $chap['count'] : 0) );
$tpl->assign("coddeven", ($ccount % 2 ? "odd" : "even"));
$tpl->gotoBlock("_ROOT");
$ccount++;
}
I've stepped through the code and it seems to always happen when it calls "$tpl->newBlock("tocblock");" could this be a problem with TemplatePower and Nested Blocks? It kills the same information no matter where I place the tocblock data into the listings.tpl file
Here is a snapshot of a listing with ToC turned on, where it drops all the other data: 
Here is the same listing with ToC turned off, that shows how/which fields should be populated: 
Edit -- I've found a way to do what I wanted to do, but using a modified code that allows less control, (but I would DEFINATELY like to know if anyone can fix the above code):
if(!defined("_CHARSET")) exit( );
$cinfo = dbquery("SELECT chap.* FROM ".TABLEPREFIX."fanfiction_chapters as chap WHERE sid = '".$stories['sid']."' AND chap.validated > 0 ORDER BY inorder");
$ccount = 0;
$tocbloc="<OL>";
while($chap = dbassoc($cinfo)) {
$tocbloc .= "<LI><b><a href=""viewstory.php?sid=".$stories['sid'"]."&chapter=".$chap['inorder']."">".$chap['title']."</a></b>";
if($reviewsallowed) {
$tocbloc .= " [<a href=""reviews.php?type=ST&item=".$stories['sid'"]."&chapid=".$chap['chapid']."">"._REVIEWS."</a>";
$tocbloc .= " - <a href=""reviews.php?type=ST&item=".$stories['sid'"]."&chapid=".$chap['chapid']."">".$chap['reviews']."</a>]";
}
$tocbloc .= " (".$chap['wordcount']." words)</LI>";
}
$tocbloc .= "</OL>";
$tpl->assign("tocbloc", $tocbloc);
StoryPortal Fiction Network -
TG Fiction dot NET | T* Fiction Archive -
LG Tales | TG Style Fiction for LG's -
Just FYI, As I mentioned in my edit of the original post, I managed to find away around this, and I've since extended it a bit:

What I've done is put in a "Latest Chapter" {latbloc}
Then below it the "Table of Contents" {tocbloc}
But if you look at the difference between Single chapter and multi chapter stories, what I did was this...
If it's a single chapter story, it only gets one "Read Story" block, and instead of the "Chapter" title I use the "story title" since single chapter stories don't have chapters π
What I'd like to know is this... Is there any interest in me releasing this code as a proper module, or even just a MOD hack?
-Piper
StoryPortal Fiction Network -
TG Fiction dot NET | T* Fiction Archive -
LG Tales | TG Style Fiction for LG's -
Seems useful enough. Someone e-mailed me on my site about something similar.
Skins made by Kali are no longer supported!
I think I'm close to releasing the code for a new module called GravEL or Gravatar eFiction Link π
More info can be seen here -- http://dev.storyportal.net/projects/gel/wiki/README
As soon as that code is ready, I'll post a forum posting on how to do the TocBloc mod with code samples π
If I can come up with a few more simple similar mods, I will turn them all into a "misc blocks" module π
-Piper
StoryPortal Fiction Network -
TG Fiction dot NET | T* Fiction Archive -
LG Tales | TG Style Fiction for LG's -
