PDA

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


mokujin
12-23-2009, 08:53 PM
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
12-23-2009, 09:29 PM
And the error is?

ragtek
12-24-2009, 01:25 AM
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
01-09-2010, 05:39 PM
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
01-09-2010, 05:51 PM
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
01-12-2010, 08:52 AM
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.