Thread: vBindex v2.1
View Single Post
  #1597  
Old 12-31-2003, 02:38 AM
Harlequin's Avatar
Harlequin Harlequin is offline
 
Join Date: Aug 2003
Posts: 78
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've been curious for awhile on how to have a simple column to the left or right on vBindex displaying just the titles from a forum (say, a "Review" forum) and using it on the main page to attract attention to that particular forum. I'm not sure if this has been posted here before, but here's nothing.

It's more or less the news code already embedded in NTLDR's code from Teck, but I'll go ahead and post up how I did it anyway for those of you that were curious: [instead of having to install a large, bulky article archive]



In vbindex.php, find

PHP Code:
// news (based on code by TECK)
// ------------------------- 

Above it, add:


PHP Code:
$articleforum "2";
$articleposts "10";
$maxarticletitlechars "22";
// ARTICLE (based on code by TECK/NEWS/VBINDEX)
// -------------------------

$articlequery=$articlequery=$DB_site->query("SELECT thread.*,threadpost.pagetext AS pagetext FROM thread LEFT JOIN post AS threadpost ON (thread.tpostid = threadpost.postid) WHERE forumid = '$articleforum' ORDER BY thread.dateline DESC LIMIT $articleposts");
while (
$article=$DB_site->fetch_array($articlequery)) {
  
$articlethreadid=$article[threadid];
  
$articleusername=$article[postusername];
  
$articleuserid=$article[postuserid];
  
$comments=$article[replycount];
  if (
$maxarticletitlechars!=0) {
     if (
strlen($article[title]) > $maxarticletitlechars) {
        
$article[title] = substr($article[title],0,$maxarticletitlechars);
        
$article[title] .= "..";
     }  
  }
$articletitle="<a href=\"$bburl/showthread.php?threadid=$articlethreadid\">$article[title]</a>";
  
// end avatar
  
eval("\$articlebits .= \"".gettemplate('home_articlebit')."\";");
}
eval(
"\$article = \"".gettemplate('home_article')."\";");

// -------------------------
// end article 

Set $articleforum as the forumID of the particular forum you're after for topics.
Set $articleposts as how many topics you'd like to display
Set $maxarticletitlechars to how many characters you'd like the subject to display [useful if you're in tight table quarters and want to make your topic look clean].


Add two templates, home_article and home_articlebit:


In home_article:

PHP Code:
<table cellpadding="0" cellspacing="0" width="100%" border="0" align="center">
<
tr>
<
td align="left"><img src="images/left2.gif"></td>
<
td align="center" width="100%" background="images/catbg2.gif" valign="bottom"><b><smallfont>reviews</smallfont></b></td>
<
td align="right"><img src="images/right2.gif"></td>
</
tr></table>
<
table cellpadding="0" cellspacing="0" border="0" bgcolor="{tablebordercolor}" width="100%">
<
tr>
    <
td>
     <
table cellpadding="4" cellspacing="1" border="0" width="100%"><tr><td bgcolor="{firstaltcolor}" align="left">
$articlebits     
</td></tr>
</
table>
</
tr>
</
table
Just noticed in the template above -- my layout uses the left/right/background table header graphics. You may have to adjust this to match your layout.


And add the second template:

In home_articlebit:


PHP Code:

<smallfont>
-
$articletitle<br>
</
smallfont



Modify the template where you'd like this to display on vBIndex [whether it be in the header, footer, home itself] and add..


PHP Code:
$article 
.. to the template. Load up your vBIndex and if there were existing posts already in the forum, they should begin displaying. Just thought I'd post this in case anyone was curious.



Now it's your job to keep everything on topic. :P
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01222 seconds
  • Memory Usage 1,816KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete