View Single Post
  #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
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01213 seconds
  • Memory Usage 1,802KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_box_bit
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • 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
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete