I've been searching and searching but cannot find 1 clear, easy to follow solution.
Currently I have an external PHP file (i.e. sitting outside the vB /forum/ folder) that can create a NEW Posts against an EXISTING Thread. Referenced:
--------------------------------------
Create Posts
https://vborg.vbsupport.ru/showthrea...highlight=Data
And for Using vBulletin-powered scripts outside vBulletin Directory...
[How-To] vBulletin API Basics: Creating Custom Pages & Misc.
https://vborg.vbsupport.ru/showthread.php?t=98009
--------------------------------------
Now I want to create a NEW Thread against an EXISTING Forum.
Referenced:
https://vborg.vbsupport.ru/showpost....3&postcount=39
Here's my code thus far...
PHP Code:
<?php
// TODO~ Create new thread on existing forum
// change directory to the system path for the forums
// NOTE: add the following code in the beginning of any relative links: $vbulletin->options['homeurl']
chdir('/var/www/vhosts/example.net.au/subdomains/smb/httpdocs/forum');
// current directory
// echo getcwd() . "\n";
require_once('./global.php');
require_once('./includes/functions.php'); // for datamanager_init function, defined in functions.php
require_once('./includes/class_dm.php');
require_once('./includes/class_dm_threadpost.php');
// creating the thread data manager object
$threaddm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
// display object ID
//echo $threaddm . "\n";
// can also be grabbed this way? ~ $forumid = $vbulletin->GPC['fid'];
// https://vborg.vbsupport.ru/showpost.php?p=1365393&postcount=39
$forumdid= 1;
$foruminfo = fetch_foruminfo($forumid);
$threaddm->set_info('forum', $foruminfo);
$threaddm->set('forumid', $foruminfo['forumid']);
$threaddm->set('userid', 1);
$threaddm->set('title', 'Testtitle');
$threaddm->set('pagetext', 'a little test');
$threaddm->set('allowsmilie', 1);
$threaddm->set('visible', 1);
$threaddm->set('dateline', TIMENOW);
//$threaddm->save();
$threaddm->pre_save();
// check for errors
if (!empty($threaddm->errors))
{
$errorlist = '';
foreach ($threaddm->errors AS $index => $error)
{
$errorlist .= "<li>$error</li>";
}
echo $errorlist . "\n";
// ... additional code; $errorlist is outputted to the user
}
else
{
echo "No Errors";
// $threaddm->save();
$thread_id = $threaddm->save();
// ... additional processing code
}
?>
Thanks in advance for any suggestions
--------------- Added [DATE]1210826124[/DATE] at [TIME]1210826124[/TIME] ---------------
p.s. This is my first crack at using vBulletin - I need to write a custom API to communicate with vB (for now to create New Threads and New Threads with Posts). The vB manual has some handy information but it seems to lack 'clear' examples of USING DataManagers to achieve simple tasks such at creating a new post and/or thread and populating it with data (e.g. from a submitted form).
I know it's going to be possible to do... I just can't figure it out :|