PDA

View Full Version : Plugin - Problems


CesarMcd
03-25-2013, 09:46 AM
Hi..

I created a plugin called "foto_post".

this plugin is for return de ID of attachment inserted in a post.

The code:

$foto_post = $db->query_read("
SELECT attachmentid
FROM vb_attachment AS vb_attachment
LEFT JOIN vb_post AS vb_post
ON vb_post.threadid = vb_attachment.contentid
AND vb_post.threadid = intval(". $vbulletin->threadinfo(''threadid) .")
WHERE vb_attachment.contentid IN(". $vbulletin->postinfo(''postid) .")
LIMIT 1
");

In the template:

{vb:raw foto_post }



When I run this SQL in my database, the return is ok, but in the template dont work.

Please, help me..
Best regards..:confused:

Lynne
03-25-2013, 02:57 PM
If you are going to query_read, then you need to then fetch_array in order to get the data. If you are only returning one field (LIMIT 1), then use query_first instead and then you don't need to fetch_array.

CesarMcd
03-25-2013, 06:49 PM
Ahh. thanks for the tips..
I will try this.
;)

--------------- Added 1364241814 at 1364241814 ---------------

$numericvar1 = intval($vbulletin->treadinfo('threadid'));
$numericvar2 = intval($vbulletin->postinfo('postid'));

$foto_post = $db->query_first("
SELECT attachmentid
FROM vb_attachment AS vb_attachment
LEFT JOIN vb_post AS vb_post
ON vb_post.threadid = vb_attachment.contentid
AND vb_post.threadid = $numericvar1
WHERE vb_attachment.contentid IN ($numericvar2)");

vB_Template::preRegister('activitystream_forum_pos t',array('foto_post' => $foto_post));



This is intire code of my plugin. but don't work. :(

The error in activity stream is

Fatal error: Call to a member function treadinfo() on a non-object in /home/fazedore/public_html/forums/vb/activitystream/view.php(166) : eval()'d code on line 1


What you think about it?

Lynne
03-25-2013, 11:23 PM
What are these lines supposed to do? (And I don't believe you spelled threadinfo correctly.)

$numericvar1 = intval($vbulletin->treadinfo('threadid'));
$numericvar2 = intval($vbulletin->postinfo('postid'));

CesarMcd
03-26-2013, 11:50 AM
Well..
I'm learning Vbulletin :)


I want to show in the activity stream the last attach of the posts.
At moment i used a external script in PHP and call him in a IFRAME. But i want to use the functions of the VBulletin to do this.

see our site in vbulletin:

http://www.fazedoresdechuva.com/

Thanks a lot!

Lynne
03-26-2013, 04:38 PM
What hook location are you using? If one of the postbit_* ones, then the threadid and postid should already be available as $post[threadid] and $post[postid].

CesarMcd
03-26-2013, 05:32 PM
activity_view_start is the hook location.

Lynne
03-26-2013, 08:47 PM
Did you look that hook up in the code - vb/activitystream/view.php ? What are you expecting to get a threadid from at that point? No query has been run, so there isn't anything to get a thread or post id from.

I'm not really familiar with the activitystream code, and I'm about to be off on vacation, so hopefully if you have more questions someone else can help you out.