2009-10-24, 01:30 AM
In the other display page end hooks that I've looked at (for instance the one in forumdisplay.php) all have the eval for the final output AFTER the plugin hook, allowing modification of the smaller sections that go into building the main section. I'll post code examples below.
NOTE: I've removed extra newlines from the following snippets for the sake of post size and neatness of presentability.
Forums (from forumdisplay.php)
Index (index.php)
And finally, the backwards (in my opinion) Threads Display (showthread.php)
I'm guessing this is/was probably just an oversight.
As a temporary workaround you can do this:
Change:
To:
[php] $plugins->run_hooks("showthread_pre_eval");
eval("\$showthread = \"".$templates->get("showthread")."\";");
$plugins->run_hooks("showthread_end");[/php
And just make your add_hook calls to the showthread_pre_eval of course. I did this for a plugin I'm writing that requires the ability to modify the $posts before it is driven into $showthread via the showthread template. Which also could use some work imo, I think the subject line should be moved to showthread_subject, and added into the threads via a variable ($subject) in the showthread.php file as posts are; replacing the thread subject template code with {$subject}. This would allow additions around the subject line as well. Perhaps I would even integrate the subject into the $posts variable instead of creating a new one. This would allow them to be sideboxed together.
NOTE: I've removed extra newlines from the following snippets for the sake of post size and neatness of presentability.
Forums (from forumdisplay.php)
}
$plugins->run_hooks("forumdisplay_end");
$foruminfo['name'] = strip_tags($foruminfo['name']);
eval("\$forums = \"".$templates->get("forumdisplay")."\";");
output_page($forums);
Index (index.php)
$forum_list = build_forumbits();
$forums = $forum_list['forum_list'];
$plugins->run_hooks("index_end");
eval("\$index = \"".$templates->get("index")."\";");
output_page($index);
And finally, the backwards (in my opinion) Threads Display (showthread.php)
}
eval("\$showthread = \"".$templates->get("showthread")."\";");
$plugins->run_hooks("showthread_end");
output_page($showthread);
I'm guessing this is/was probably just an oversight.
As a temporary workaround you can do this:
Change:
eval("\$showthread = \"".$templates->get("showthread")."\";");
$plugins->run_hooks("showthread_end");
To:
[php] $plugins->run_hooks("showthread_pre_eval");
eval("\$showthread = \"".$templates->get("showthread")."\";");
$plugins->run_hooks("showthread_end");[/php
And just make your add_hook calls to the showthread_pre_eval of course. I did this for a plugin I'm writing that requires the ability to modify the $posts before it is driven into $showthread via the showthread template. Which also could use some work imo, I think the subject line should be moved to showthread_subject, and added into the threads via a variable ($subject) in the showthread.php file as posts are; replacing the thread subject template code with {$subject}. This would allow additions around the subject line as well. Perhaps I would even integrate the subject into the $posts variable instead of creating a new one. This would allow them to be sideboxed together.