Log in

View Full Version : Trouble Altering Code for Vbulletin Plugin


sheep92032
07-21-2009, 09:56 AM
I'm trying to port one of my scripts over to vbulletin so I can use it's templating system. All I need to do is include either of two files based on the GET. Maybe there are special vbulletin function I need to use?

This is my script:


require_once('global.php');
include('accountdb/includes/config.php');

if ($vbulletin->userinfo['userid'] != 0 and in_array($vbulletin->userinfo['usergroupid'],$usergroup_access)) {

if(!empty($_GET['do'])){

if($_GET['do'] == 'add'){
include('accountdb/includes/add.php');
exit;
}

if($_GET['do'] == 'list'){
include('accountdb/includes/list.php');
exit;
}

}

}


The scripts work if I include them separately like this:


ob_start();
include ('accountdb/includes/add.php');
$include_contents = ob_get_contents();
ob_end_flush();

cono1717
07-21-2009, 01:09 PM
I am not too sure if this help but

if($_GET['do'] == 'list')

I think should be

if($_REQUEST['do'] == 'list')

Then if your list.php file can be used in the template system you can add this in the if statement

eval('print_output("' . fetch_template('LIST') . '");');

So the code would be

if($_REQUEST['do'] == 'add'){
eval('print_output("' . fetch_template('add') . '");');
exit;
} else if($_REQUEST['do'] == 'list'){
eval('print_output("' . fetch_template('list') . '");');
exit;
} else

{
else
{
eval('print_output("' . fetch_template('default_template') . '");');
}




That final else is if someone doesn't visit yourfile.php?do=list or ?do=add they get that files home page. You just have to create the corresponding templates in vBulletin (list, add, default_template)


You may find this better in the Programming Discussion Section, mine is just a guess.

sheep92032
07-21-2009, 01:28 PM
I just want to include list.php and add.php. I don't want to make templates for them because they're PHP generated HTML.

Marco van Herwaarden
07-21-2009, 01:40 PM
And what doesn't work? What is actually the question?

cono1717
07-23-2009, 02:29 PM
To include PHP I think you have to make a new hook or plugin since the templates don't like the include function or any php for that matter.