Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-07-2005, 08:36 AM
noonespecial noonespecial is offline
 
Join Date: Nov 2002
Posts: 250
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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.
Reply With Quote
  #2  
Old 12-07-2005, 09:23 AM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #3  
Old 12-07-2005, 09:26 AM
noonespecial noonespecial is offline
 
Join Date: Nov 2002
Posts: 250
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That does look like what I need .. I am.
Reply With Quote
  #4  
Old 12-07-2005, 09:37 AM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #5  
Old 12-08-2005, 04:59 AM
noonespecial noonespecial is offline
 
Join Date: Nov 2002
Posts: 250
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 12-08-2005, 07:46 AM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If it worked then it doesnt matter does it
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:03 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.03651 seconds
  • Memory Usage 2,232KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete