Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Design and Graphics Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-25-2013, 10:46 AM
CesarMcd CesarMcd is offline
 
Join Date: Mar 2012
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Plugin - Problems

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..
Reply With Quote
  #2  
Old 03-25-2013, 03:57 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 03-25-2013, 07:49 PM
CesarMcd CesarMcd is offline
 
Join Date: Mar 2012
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ahh. thanks for the tips..
I will try this.


--------------- Added [DATE]1364241814[/DATE] at [TIME]1364241814[/TIME] ---------------

Code:
$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_post',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?
Reply With Quote
  #4  
Old 03-26-2013, 12:23 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What are these lines supposed to do? (And I don't believe you spelled threadinfo correctly.)

PHP Code:
$numericvar1 intval($vbulletin->treadinfo('threadid'));
$numericvar2 intval($vbulletin->postinfo('postid')); 
Reply With Quote
  #5  
Old 03-26-2013, 12:50 PM
CesarMcd CesarMcd is offline
 
Join Date: Mar 2012
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!
Reply With Quote
  #6  
Old 03-26-2013, 05:38 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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].
Reply With Quote
  #7  
Old 03-26-2013, 06:32 PM
CesarMcd CesarMcd is offline
 
Join Date: Mar 2012
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

activity_view_start is the hook location.
Reply With Quote
  #8  
Old 03-26-2013, 09:47 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:36 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07482 seconds
  • Memory Usage 2,230KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete