Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-01-2003, 12:28 AM
karmanis karmanis is offline
 
Join Date: Jun 2003
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default ...Last5posts instead of Lastpost, in Forumdisplay !

(a screenshot is attached at the end from a commercial site running vb)

Motivation: In newly created communities you have not many posts. So insted of demonstrating the number of posts, threads, and the lastpost for each forum, why not just serving the last 5 posts ? It gives the feeling that your board is active and the user is tempted to follow some links, so he will probably stay in the board for a while. :bunny:

Imagine a board with only 1000 posts ... with the number of posts beside the forums it seems almost empty. Using the last5posts bit, the user is not informed about the number of the posts, instead he is being served with some interesting links/threads to follow!



The stuff:
Let me describe what I have achieved so far about this.. clarifying that I have no knowledge of php or sql (however, I am fluent in some OOP). :alien:

Normally, in forumdisplay>forumbit_level1/2_post templates, the variable $forum[lastpostinfo] is called. This variable is evaluated in forumdisplay.php inside a while loop that generates all the info needed to display each row for the catecorized forums when foromdisplay is called. So, inside this loop you have $forum[forumid] stating the current forum proccessed in cache.

My idea was to nest another variable inside this loop that would run a query (Zzed helped me with this in this thread ) and get the last 5 posts for the currently proccessed forum.

The difficult part is that you don't have one thing to show but 5. The way I went was to make a function (assigned to our $last5posts) that would manage to parse the lastposts table and display the results with html links.

However, I found that "functions inside functions" (the main loop) is not a good idea in php, so I had to place my function outside the makeforumbit function that manages the loop for the displayed forums.

PHP Code:
//*********
$getlast5posts'';
function 
showlast5posts($forumpath,$forumid){
global 
$DB_site;
$templatesused='forumhome_lastpostby';
$last5postsshow='';
        
$getlast5posts=$DB_site->query("SELECT threadid,title FROM thread WHERE forumid = $forumid 
ORDER BY lastpost DESC limit 5"
);



        while(
$this5post=$DB_site->fetch_array($getlast5posts)) {
                     
$forumspathe=$forumspath;
                     
$tid=$this5post[threadid];
                     
$ttitle=$this5post[title];
                     eval(
"\$last5postsshow = \"".gettemplate('forumhome_lastpostby')."\";");
                    
        }

...and I state the guilty variable inside function makeforumbit ..

PHP Code:
$last5posts=showlast5posts($forumpath,$forum[forumid]); 
The template used (forumhome_last5posts) is just:

Code:
	<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr align="right">
		<td nowrap><smallfont>

<a href=\"$forumspath/showthread.php?s=&threadid=$tid\">$ttitle</a>

	</smallfont>
</td></tr></table>
<br>

The bad news : This crap does not show anything.

The good news: If you replace the "eval" with an echo ... :knockedout:

PHP Code:
echo "<font face=\"Verdana\" size=\"2\">-> <a href=\"$forumspath/showthread.php?s=&threadid=
$this5post[threadid]\">$this5post[title]</a></font><br>"
...it shows you perfectly the last5posts, but with a little problem: it brings them to the start of the page insted inside the appropriate table we want.

here comes...
The request:
Could someone of you, the php/sql/vb-mods experts, take a look at forumdisplay code and find the magick trick that would enbody the functionality the screenshot describes ? :lick:

many thanks ! (honestly)
Attached Images
File Type: jpg last5posts_beside_forumname.jpg (41.6 KB, 0 views)
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 02:36 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06331 seconds
  • Memory Usage 2,241KB
  • Queries Executed 12 (?)
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)bbcode_code
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)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_attachment
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • 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_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete