View Full Version : Grab Template?
Can someone give me the command to grab a template onto my own PHP page? IE: not a vb Page...it's for a hack I'm working on...
This is untested, and possibly not 100% correct, but the theory is there :).
You'll need to do something like this:
<?php
require("forums/global.php");
$DB_site->query("SELECT all, of, the, things, you, want, FROM table WHERE yadda, yadda");
eval("echo(\"".gettemplate("template_name")."\");");
?>
The theory is that you'd include global.php, connect to the database, and call the template you want.
That's the best I can do off the top of my head. The code depends on what is it you want to do more than anything else.
-jim
I used this:
require("global.php");
$DB_site->query("SELECT * FROM template");
eval("echo(\"".gettemplate("savethread")."\");");
And got this:
Fatal error: Cannot redeclare class db_sql_vb in admin/db_mysql.php on line 6
Any idea whats wrong? I created a "savethread" template and as it turns out the global.php file is in the same directory as my file.
Okay, I think I know what's wrong.
In global.php up towards the top you'll see a whole bunch of function definitions. Add this somewhere in there (I added mine below "Start dovars" and above "start standarderror":
// ####### Start Save Thread Hack #####
function savethread($title="") {
// This is where you put all the variables that you use in your template
global $header,$footer,$cssinclude,$fivelinks,$forumjump, $timezone,$bbtitle,$hometitle,
$bburl,$homeurl,$copyrighttext,$privacyurl,$contac tuslink,$titleimage,$replyimage,$newthreadimage,
$closedthreadimage,$lastvisitdate,$timenow;
makeforumjump();
eval("\$returnval = dovars(\"".gettemplate("savethread")."\");");
return $returnval;
}
And then in your page, you would put this:
require("global.php");
eval("echo savethread(\"".gettemplate("savethread")."\");");
As I was typing this, I decided to try it out on my test board.
What I did was put the second code snippet into a file called savethread.php, and put it in my /forums/ directory. Then I created a simple template called "savethread", and used some of the standard variables. You can see an example here:
http://www.bronx-bombers.com/testforum/savethread.php
I think that was what you were trying to do, so I hope that helps :)
-jim
[Edited by JimF on 09-19-2000 at 01:50 PM]
TWTCommish - Did this work?
I'm sorry Jim! I never got around to it - til now.
Works great! Thanks a lot! Hopefully I'll be able to finish my pathetic exscuse for a hack now. :)
One quick problem: how do I integrate the two together? IE: I have some SQL queries to make here, but I can't just stick em in the template, can I? I don't think the rest of vB is like that...
The problem is whatever I have printed out shows up at the bottom, below the template...
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.