The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
...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:
PHP Code:
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:
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) |
#2
|
||||
|
||||
well firstly, you know that you will be looping the template 5 times, right? meaning you have FIVE tables instead of one... so you probably shouldn't use a table in your template, just the link, followed by a <br />
AND are you putting the $last5postsshow in the forumdisplay template to be displayed? Also, you need to eval EVERY variable u use in your templates... so it should look like this... Code:
while($this5post=$DB_site->fetch_array($getlast5posts)) { eval("\$forumspathe = \"".$forumspath."\";"); eval("\$tid = \"".$this5post[threadid]."\";"); eval("\$ttitle = \"".$this5post[title]."\";"); eval("\$last5postsshow = \"".gettemplate('forumhome_lastpostby')."\";"); } Code:
<table> $last5postsshow </table> Code:
<tr> <td> -- YOUR LINK TO POST -- </td> </tr> |
#3
|
|||
|
|||
thanks jamslam,
I'll take a further look at it to find out what happens with the templates. :cross-eyed: |
#4
|
||||
|
||||
Firstly, you don't need to eval all those variables. Remember that the scope of all those variables is local to that function, this results in the problem of nothing showing:
PHP Code:
|
#5
|
|||
|
|||
I am concerned of the many queries, and my worst fear is the case that I would need an additional query in the loop, to get the last threads not only from forumid but from it and all its child-forums aranoid:
Is there a way that I could modify the already used query to also include the subforums of $forumid ??? Code:
$getlast5posts=$DB_site->query("SELECT threadid,title FROM thread WHERE forumid = $forumid ORDER BY lastpost DESC limit 5"); many thanks |
#6
|
||||
|
||||
Quote:
i missed the global thing to, i get caught on that a lot, sorry about the false info |
#7
|
||||
|
||||
@jamslam: Don't worry about making mistakes as long as you learn from them
@karmanis: IMO the best way to achive this would be smiliar to Scott's hack that does this for the latest thread and modify it to store the last 5 instead of the last 1. |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|