The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Determine thread position in the threadlist
I have some ideas running around in my head but can't put my finger on how to make it happen.
Anyway what I want to accomplish somehow is... possibly a conditional or a variable of some sort to determine a threads position in the threadlist. A conditional that I could use in SHOWTHREAD template. For example, In the showthread template I could add a line of code somewhere that says "Your thread is at X position in this forum" Where X would be the threads position in the thread list for that forum section. Or I could use a conditional somehow, if X >= 20 then display a message that says "your thread is no longer on the first page. Either way I'm just curious if there's any way to get the position of a thread, and have that be usable in the showthread template. |
#2
|
||||
|
||||
How would you determine which thread of the user's to check for? Would you just want it to check their "latest" thread?
--------------- Added [DATE]1360208626[/DATE] at [TIME]1360208626[/TIME] --------------- Will it be every forum, or just one? |
#3
|
|||
|
|||
I was thinking in just one forum for now, and yes that message would only show if it's their own thread.
I know how to show the message in certain forums, in the right spot and only for the thread owner, but can't for the life of me figure out a way to determine the thread's position so I can use that info too |
#4
|
||||
|
||||
Will it be for the user's most recent thread? or all threads like "your threads are in position 8 and 14" or "your thread is in position 4" for just their most recent?
|
#5
|
|||
|
|||
It will show ON the thread they are viewing.
For example - This thread is at position 7 |
#6
|
||||
|
||||
This also depends on your forum sort order. what would that be?
--------------- Added [DATE]1360212358[/DATE] at [TIME]1360212358[/TIME] --------------- This should help you A LOT. I am not sure if it needs to go into showthread_start or showthread_complete but the code is sound. may need a bit of tweaking. Hope it helps. Code:
$current_thread = $threadinfo['threadid']; $current_thread_forum = $threadinfo['forumid']; $thread_owner = $threadinfo['postuserid']; $current_user = $bbuserinfo['userid']; $forum_id = 2; if ($current_thread_forum == $forum_id) { if ($thread_owner == $current_user) { $query = $vbulletin->db->query_first('set @row_num = 0; SELECT @row_num := @row_num + 1 as row_number,threadid,postuserid,title FROM thread WHERE forumid = ' . $forum_id . ' AND postuserid = ' . $current_user . ' ORDER BY dateline DESC LIMIT 1;'); $position = $query['row_number']; $display = "This thread is at position: " . $position; vB_Template::preRegister('SHOWTHREAD',array('display' => $display)); } } |
#7
|
|||
|
|||
Thanks for the help I appreciate it!
Unfortunately that didn't work using either showthread_complete or showthread_start PS - My threads are sorted by start time |
#8
|
||||
|
||||
It does work, run this query inside phpmyadmin or whatever you use.
Code:
set @row_num = 0; SELECT @row_num := @row_num + 1 as row_number,threadid,postuserid,title FROM thread WHERE forumid = # AND postuserid = ## ORDER BY dateline DESC LIMIT 1; ## = userid , just make it one to run test on admin first user will return row of thread with its placement. if you remove "LIMIT 1" it will show more threads. --------------- Added [DATE]1360336817[/DATE] at [TIME]1360336817[/TIME] --------------- ill revise the code in a bit. i forgot something. --------------- Added [DATE]1360346941[/DATE] at [TIME]1360346941[/TIME] --------------- Here is the final working and tested code. It will show the position of the thread based on start date, not last reply. With new threads being position 1. (if you would like it the other way around change "DESC" to "ASC" in the $query) PHP Code:
Then add the following where you want it inside of SHOWTHREAD. {vb:raw display} I have added some span id's so you can style it how you'd like. Be sure to change $forum_id to the forum you'd like this running in. --------------- Added [DATE]1360347115[/DATE] at [TIME]1360347115[/TIME] --------------- Here is a sample CSS to add to additional.css Code:
p#pos-text-main { background: rgb(255, 202, 202); border: 1px solid rgb(184, 0, 0); margin: 10px 0; padding: 10px; } span#pos-num { font-weight: bold; } |
Благодарность от: | ||
addamroy |
#9
|
|||
|
|||
Perfect!
|
#10
|
||||
|
||||
forgot to add the p and span to final code check now
|
Благодарность от: | ||
obglobal.net |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|