The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#11
|
|||
|
|||
Where did you put your code for creating a forum? If you are already including vbulletin's global.php, or if you are writing a plugin, then you probably don't have to explicitly include anything. If this is a custom script that doesn't include vbulletin's global.php then that's more of a problem. In that case it may turn out to be too difficult to use any vbulletin code since it mostly depends on having included global.php, which has a lot of overhead associate with it.
ETA: OK, I see you said above that you're creating a custom page. So if you're not already including vbulletin global.php then you'd have to think about adding it if you want to use the above code. |
#12
|
|||
|
|||
I have made it practice to include global.php. There's a lot of usage I've done with that one included.
Fatal error: Call to undefined function can_administer() in /home/xxxxxxxxx/xxxxxxxx/forum/admincp/forum.php on line 31 This is a fully functional custom template and I'm logged in. This is close to the developed page. However, I would like to use it on a separate page for the Jquery function to send header requests to, due to my liking of Jquery. |
#13
|
|||
|
|||
You should not be including admincp/forum.php. If you're trying the code I posted above, try it without including anything (ETA: I mean anything more than you are already). The one thing you might need before that code, if your code is inside a function, is
Code:
global $vbulletin; |
#14
|
|||
|
|||
It works great. I need to figure out how to edit it next haha.
I had to add the global variable and all is good. Here's an example for others to follow if interested Code:
<?php // ####################################################################### // ####################################################################### // ####################################################################### // ############### CUSTOM TEMPLATE FOR YOUR USE ########################## // ############### COMMENTED FOR READABILITY ########################## // ############### IF YOU WANT THE AUTH FUNC ########################## // ############### CONTACT ME ON THE VBULLETIN.ORG FORUM: Medi0cr3 ########################## // ####################################################################### // ####################################################################### // ####################################################################### // ####################################################################### // ####################################################################### // ####################################################################### // ####################################################################### // ####################################################################### // ####################################################################### // ####################################################################### // ####################################################################### // ####################################################################### // ####################################################################### // ####################### SET PHP ENVIRONMENT ########################### error_reporting(E_ALL); ini_set("display_errors","true"); // #################### DEFINE IMPORTANT CONSTANTS ####################### define('THIS_SCRIPT', 'A_Atest'); //Not sure if using the extension is required. I utilze A_ in the filename for my php file as its easy to find in the /forum directory. Ex. "A_test" define('CSRF_PROTECTION', true); // change this depending on your filename // ################### PRE-CACHE TEMPLATES AND DATA ###################### // get special phrase groups $phrasegroups = array(); // get special data templates from the datastore $specialtemplates = array(); // pre-cache templates used by all actions $globaltemplates = array('Atest',); //Not totally required.. Style & Template -> Style Manager -> Edit/Add Custom Template -> Custom Template Name Must be This. // pre-cache templates used by specific actions $actiontemplates = array(); // ######################### REQUIRE BACK-END ############################ // if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line // chdir ('/path/to/your/forums'); require_once('./global.php'); require_once('A_p.php'); //I have database connection code here. require_once('A_fnc.php'); // I keep all my functions here. // ####################################################################### // ######################## START MAIN SCRIPT ############################ // ####################################################################### global $vbulletin; $navbits = construct_navbits(array('' => 'Atest')); //Style & Template -> Style Manager -> Edit/Add Custom Template -> Custom Template Name Must be This. $navbar = render_navbar_template($navbits); // ###### YOUR CUSTOM CODE GOES HERE ##### $pagetitle = 'Atest'; //I have an Authorization function that looks at usergroupids in the database and allows access based off that. If this name is not the same name as in the database, the code will not run. $templateColor = 'silver'; //Main template text color. // ########## START DATABASE CONNECTION ############## if(!$con) { die("Database connection services failed connection: <font size='4'> $pagetitle</font> " . mysql_error()); } mysql_select_db("xxxxxxxxxxxxxxx", $con) or die("Database selection name fail: <font size='4'> $pagetitle</font> " . mysql_error()); // ########## END DATABASE CONNECTION ############## $forumdata =& datamanager_init('Forum', $vbulletin, ERRTYPE_SILENT); $forumdata->set(title, 'test forum'); $forumdata->set(description, 'This is a test'); $forumdata->set(link, ''); $forumdata->set(displayorder, 1); $forumdata->set(parentid, -1); $forumdata->set(daysprune, -1); $forumdata->set(defaultsortfield, 'lastpost'); $forumdata->set(defaultsortorder, 'desc'); $forumdata->set(showprivate, 0); $forumdata->set(newpostemail, ''); $forumdata->set(newthreademail, ''); $forumdata->set_bitfield('options', moderatenewpost, 0); $forumdata->set_bitfield('options', moderatenewthread, 0); $forumdata->set_bitfield('options', moderateattach, 0); $forumdata->set_bitfield('options', styleoverride, 0); $forumdata->set_bitfield('options', canhavepassword, 1); $forumdata->set_bitfield('options', cancontainthreads, 1); $forumdata->set_bitfield('options', active, 1); $forumdata->set_bitfield('options', allowposting, 1); $forumdata->set_bitfield('options', indexposts, 1); $forumdata->set_bitfield('options', bypassdp, 0); $forumdata->set_bitfield('options', allowhtml, 0); $forumdata->set_bitfield('options', allowbbcode, 1); $forumdata->set_bitfield('options', allowimages, 1); $forumdata->set_bitfield('options', allowvideos, 1); $forumdata->set_bitfield('options', allowsmilies, 1); $forumdata->set_bitfield('options', allowicons, 1); $forumdata->set_bitfield('options', allowratings, 1); $forumdata->set_bitfield('options', countposts, 1); $forumdata->set_bitfield('options', showonforumjump, 1); $forumdata->set_bitfield('options', prefixrequired, 0); $forumdata->set_bitfield('options', displaywrt, 1); $forumdata->set_bitfield('options', canreputation, 1); $forumdata->set(styleid, 0); $forumdata->set(imageprefix, ''); $forumdata->set(password, ''); $forumid = $forumdata->save(); //########################### START AUTHORIZATION FUNCTION ########################### //#################################################################################### //if $pagetitle var, up top, is not exactly what is in the database, it will not load the Authorization. $usergroupfield = $vbulletin->userinfo[usergroupid]; //Gets the usergroupid before authorization function is ran. $NavAuth = getAuth($pagetitle,$usergroupfield,$con); //Runs the Authorization function. //#################################################################################### //#################################################################################### //********* END DATABASE CONNECTION *************** mysql_close($con); //********* END DATABASE CONNECTION *************** $templater = vB_Template::create('Atest'); //Style & Template -> Style Manager -> Edit/Add Custom Template -> Custom Template Name Must be This. $templater->register_page_templates(); $templater->register('navbar', $navbar); $templater->register('pagetitle', $pagetitle); $templater->register('NavAuth', $NavAuth); $templater->register('templateColor', $templateColor); //$template_hook[parse_templates] .= $templater->render(); print_output($templater->render()); ?> |
Благодарность от: | ||
kh99 |
#15
|
||||
|
||||
I figured you were trying to automate the creation of forums. Be aware that the system will start to break down around 2000 total forums + usergroups, in any combination. By break down, I mean have too much overhead for data to be processed reguarlly.
|
#16
|
|||
|
|||
Quote:
*update: I'm still working on systematic stuff for the above code I pushed. I'm trying to figure out exactly what the minimum requirement of code of the "template". You'll see how I broke down a lot of it already. I would like to know break it down further to use the datamanager like I'm expecting to. |
#17
|
||||
|
||||
It's a forumcache issue, the forumcache as programmed into vb by default is horribly inefficient in that it loads the entire forumcache into memory (i.e. permissions for all groups for all forums) even if you only are looking at one forum for a small subset of groups. We ran into this bottleneck a while back and had to rewrite the forumcache to not have the massive overhead.
|
#18
|
|||
|
|||
Thanks for everybody's help on this. I know have a decent understanding of the datamanagers. And the overhead issue with the forumcache.
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|