The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Show username from a certain thread
Hopefully a simple bit of help required.
Say I wanted to show a simple text of the username with a post id = 1000000 i.e. the member posted our millionth post how would you do this ? |
#2
|
|||
|
|||
You can of course find post 1000000 by going to showtrhead.php&p=1000000. You could also do a db query, like:
Code:
SELECT username FROM post WHERE postid=1000000 but it sounds like maybe you want code to automatically display it somewhere? |
#3
|
|||
|
|||
I understand that element what I struggle with is once I have the $result is how to get this into the vb system to show within the head template.
PHP Code:
I'm using no 5 in the above to see if it shows the right result. |
#4
|
|||
|
|||
I think I'd create a plugin using hook parse_templates, and code like this:
Code:
$million = $vbulletin->db->query_first("SELECT username FROM " . TABLE_PREFIX . "post WHERE postid = '5'"); if (!empty($million)) { vB_Template::preRegister('header', array('million' => $million['username'])); } then in the header template, use {vb:raw million}. |
#5
|
|||
|
|||
Didn't work - got an error 'Call to undefined method vB_Database::query_read_first()'
so removed the 'first' and no error but its not showing up. |
#6
|
|||
|
|||
Oops, yeah, it's just query_first. I fixed the above code.
|
#7
|
|||
|
|||
Thanks thats working now.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|