vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   How difficult would it be .. (First Post on Threadbit) (https://vborg.vbsupport.ru/showthread.php?t=102409)

noonespecial 12-07-2005 08:36 AM

How difficult would it be .. (First Post on Threadbit)
 
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/newsdisp...p?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.

merk 12-07-2005 09:23 AM

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.

merk 12-07-2005 09:37 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 Code:

<?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($vbulletinfetch_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:
PHP Code:

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.

merk 12-08-2005 07:46 AM

If it worked then it doesnt matter does it ;)


All times are GMT. The time now is 10:40 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01129 seconds
  • Memory Usage 1,751KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete