PDA

View Full Version : Add a new Block with PHP content?


mokujin
23 Dec 2009, 22:53
hello,
I just tried to add a new block (Forum Blocks Manager) with PHP content type but there is always error.
just tried:
$users = $vbulletin->db->query_read_slave("
SELECT userid,username,posts
FROM ".TABLE_PREFIX."user ORDER BY posts
");

Lynne
23 Dec 2009, 23:29
And the error is?

ragtek
24 Dec 2009, 03:25
Is this the only code you're using?
That wount work;)

1. You have to use vB::$db-> instead of $vbulletin->db
2. You'll need to fetch the query.
3. You'll need to add the results to an array or to a template
4. You'll need to return it

mokujin
09 Jan 2010, 19:39
Is this the only code you're using?
That wount work;)

1. You have to use vB::$db-> instead of $vbulletin->db
2. You'll need to fetch the query.
3. You'll need to add the results to an array or to a template
4. You'll need to return it
Can you please give me an example? Thank you

Lynne
09 Jan 2010, 19:51
If you want to see an example, here's a real simple block that just spits out the user's username:
$result = vB::$vbulletin->db->query_first("SELECT username, userid FROM user where userid = ". vB::$vbulletin->userinfo['userid'] ." LIMIT 1");

return $result[username];

Dunhamzzz
12 Jan 2010, 10:52
I've done things in a slightly different way....

I was making widget (not sure how these differ from sidebar blocks)

But I made completely blank template, with just {vb:raw output} in it, and in my php area just include() an external file and have the out stored in $output.

Means I can edit the included file however I want, and I can re-use that template too.