Quote:
Originally Posted by jgrietveld
Why can't I just enter code here? I know exactly where i want my forum titles to appear so why do I have to find a Hook and still create a plugin?
|
Well, the answer really is because the template compiler doesn't allow php - in fact it checks for php code to stop you from doing that. I don't know why that decision was made, but that's the way it is. (There was a mod that allowed you to put php code in a template, but I don't know if it works with the latest versions).
One thing you can do is write an external php script to do what you want, then include it using instructions from the vbulletin manual:
https://www.vbulletin.com/docs/html/..._externalfiles . But that's really to allow existing php scripts to be used without rewriting them, and you probably wouldn't want to write new stuff that way.
But you could use the same idea - use that hook location, put in your query instead of the ob_start/ob_end thing, and when you have a variable set, use the preRegister line like in that example. The downside of that is that it will do that work on every page instead of just the page that is using it, but you could get it working then worry about the efficiency later.
Edit: like
PHP Code:
$results = $db->query_read("SELECT title FROM " . TABLE_PREFIX . "forum WHERE forumid = 1");
while ($forum = $db->fetch_array($results))
{
// Do something to format the titles
$forumtitles .= $forum['title'] . "<BR/>";
}
vB_Template::preRegister('vbcms_page', array('forumtitles' => $forumtitles));