View Full Version : How difficult would it be .. (First Post on Threadbit)
noonespecial
12-07-2005, 08:36 AM
How difficult would it be to pull the first post of a thread (with bbcode formating) and put it on forumdisplay (threadbit template to be exact). I'm looking to duplicate it for my news page, and $threadpreview works for a really cheapo way of doing it - but I would like to do it in a much better way .. any ideas? It'd be a huge help.
If anyone is actually interested, and wants more info .. this is the page (http://www.absolutepunk.net/newsdisplay.php?f=165&page=1) and as you can see it's duplicating my main page's news (www.absolutepunk.net) - and I am going to use this version (the newsdisplay.php) as a news archive with ajax buttons at the bottom to scroll through news posts.
I have made a simple index.php page (vbulletins index.php -> forumhome.php) which achieves basically what you want.
http://www.ozfortress.com/ - pulled from a single forums you specify, it is run through the postbit class, and treated just like a post (which you could then run some kind of string limiting / cutting function over it) and inserts it into a custom postbit template (newsbit iirc).
Are you interested?
noonespecial
12-07-2005, 09:26 AM
That does look like what I need .. I am.
The script doesnt currently support pagination (ive never needed it) and is limited to a fixed number of items.
index.php should look something like:
<?php
/*================================================= =====================*\
|| ################################################## ################## ||
|| # ozfortress custom news index script # ||
|| # written to run on a vBulletin installation # ||
|| # ---------------------------------------------------------------- # ||
|| # Copyright ?2005 merkworx.com # ||
|| ################################################## ################## ||
\*================================================ ======================*/
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'index_news');
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();
// get special data templates from the datastore
$specialtemplates = array(
'smiliecache',
'bbcodecache');
// pre-cache templates used by all actions
$globaltemplates = array('GENERIC_SHELL', 'index_postbit', 'postbit_onlinestatus', 'bbcode_code', 'bbcode_html', 'bbcode_php', 'bbcode_quote');
// pre-cache templates used by specific actions
$actiontemplates = array();
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once(DIR . '/includes/functions_bigthree.php');
require_once(DIR . '/includes/class_bbcode.php');
require_once(DIR . '/includes/class_postbit.php');
$newsitems = $vbulletin->db->query_read("
SELECT thread.* , post.*, user.username AS uname,
IF(user.displaygroupid=0, user.usergroupid, user.displaygroupid) AS displaygroupid
FROM `thread`
LEFT JOIN `post` ON ( thread.firstpostid = post.postid )
LEFT JOIN `user` ON ( post.userid = user.userid )
LEFT JOIN `deletionlog` ON (deletionlog.primaryid = thread.threadid AND deletionlog.type = 'thread')
WHERE thread.forumid = 9
AND deletionlog.primaryid IS NULL
ORDER BY thread.dateline DESC
LIMIT 15");
$foruminfo = fetch_foruminfo(9);
$postbit_factory =& new vB_Postbit_Factory();
$postbit_factory->registry =& $vbulletin;
$postbit_factory->forum =& $foruminfo;
$postbit_factory->cache = array();
$postbit_factory->bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
while ($newsitem = $vbulletin->db->fetch_array($newsitems))
{
$postbit_obj =& $postbit_factory->fetch_postbit('index_postbit');
$HTML .= $postbit_obj->construct_postbit($newsitem);
}
$vbulletin->db->free_result($newsitems);
$navbits = construct_navbits(array(
'' => "news index"));
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('GENERIC_SHELL') . '");');
?>
You will need a template, index_postbit, which basically can contain anything the normal postbit template contains. (i copy/pasted then modified)
You should change the forumid in the query and fetch_foruminfo() functions to one that matches your forum for news.
You will also need to add a hook into postbit_factory with the contents:
if($postbit_type == 'index_postbit')
{
$out =& new vB_Postbit_Post();
$out->templatename = 'index_postbit';
$handled_type = true;
}
Aside from that, it should just work - you will obviously need to modify it slightly if you only want some of the pagetext to show - something you're probably going to have to get a bit dirty with, I'd stab a guess at the best place to do it would be postbit_display_complete (maybe postbit_display_start) checking for $this->templatename == 'index_postbit' to make sure you're working on a news postbit.
Maybe I should tidy it up more and release it, but eh ;)
noonespecial
12-08-2005, 04:59 AM
I've been looking through the code .. not sure if I can use it to do what I want.
I just parsed bbcode for $threadpreview in functions_forumdisplay.php and it worked exactly how I wanted.
If it worked then it doesnt matter does it ;)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.