Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #11  
Old 01-21-2015, 11:14 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #12  
Old 01-21-2015, 12:40 PM
Medi0cr3 Medi0cr3 is offline
 
Join Date: Aug 2014
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #13  
Old 01-21-2015, 12:47 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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;
Reply With Quote
  #14  
Old 01-21-2015, 01:17 PM
Medi0cr3 Medi0cr3 is offline
 
Join Date: Aug 2014
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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());
?>
Reply With Quote
Благодарность от:
kh99
  #15  
Old 01-21-2015, 03:10 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #16  
Old 01-21-2015, 04:38 PM
Medi0cr3 Medi0cr3 is offline
 
Join Date: Aug 2014
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Zachery View Post
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.
Haha, Sounds great. I don't ever think I'll be that high up. However this is a pretty interesting project as I do a lot of other customized pages that apply and utilize things that people do in the fourm. So I might find a breaking point in something along the way. I'm glad that you're pointing that out now. Its a good fact.

*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.
Reply With Quote
  #17  
Old 01-21-2015, 06:19 PM
squidsk's Avatar
squidsk squidsk is offline
 
Join Date: Nov 2010
Posts: 969
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Zachery View Post
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.
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.
Reply With Quote
  #18  
Old 01-21-2015, 06:36 PM
Medi0cr3 Medi0cr3 is offline
 
Join Date: Aug 2014
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for everybody's help on this. I know have a decent understanding of the datamanagers. And the overhead issue with the forumcache.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:51 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04188 seconds
  • Memory Usage 2,263KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (8)post_thanks_box
  • (1)post_thanks_box_bit
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete