Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 09-06-2011, 01:35 AM
ykkrox ykkrox is offline
 
Join Date: Feb 2009
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Additional Options

HI!

My first question here after much googling..

I wanted to know what hook I should use to add a new "additional option" when a user is creating a new thread, editing a post or replying. (basically anytime when you post).

I'm creating a method to upload custom cropped icons to a post, but I don't know which hook I should use to have that option show up with the Additional Options.

This option can also be outside of the "additional options" box when posting. It doesn't have to reside within the same box.

Also, does anyone know which array variable I can access to get post information (i.e. - post ID, post date, etc) and the user info (i.e. - user ID, user sign up date, etc)?

Thanks!
Reply With Quote
  #2  
Old 09-06-2011, 01:27 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ykkrox View Post
I wanted to know what hook I should use to add a new "additional option" when a user is creating a new thread, editing a post or replying. (basically anytime when you post).
I don't know offhand, I'm looking at newthread.php to see how that works, and I see that the "disable smilies" option is set in the construct_edit_toolbar() function (in includes/functions_editor.php). You could use hook location editor_toolbar_end in that function to create your option html (render a template, for instance), and preRegister it to the newthread and newreply templates. Or you could use the newthread_form_complete and newreply_form_complete hooks (which get called just before the templates are rendered), but you'd have to do the same thing for both hooks to cover all posting options (well, the ones from the "advanced" editor).

All that just gets the html to show up on the form. To process it, I'd probably use hooks newthread_post_start/newreply_post_start to get the values and put them in the $newpost[] array, then use hook newpost_process to do something with them (they'll be in $post[] at that point), and if you detect an error at that point you just have to put an error message in $errors[] to stop the post from being saved.

I know that's a really short explanation of something that's a bit complicated. If you know php I'd recommend searching for fetch_hook('hook_name') (using whatever hook name you're interested in) to see what's going on at that point in the code.


Quote:
Also, does anyone know which array variable I can access to get post information (i.e. - post ID, post date, etc) and the user info (i.e. - user ID, user sign up date, etc)?

It depends on what hook location you're using. If you follow what I outlined above and use newpost_process to process your data, then everything about the post is in $post[]. The "current" (logged in) user's info is in $vbulletin->userinfo, but that could be different than the post if, say, an admin is editing someone else's post. I'm not sure if all the fields you mention are available. What I usually do if I'm wondering is I put in a print_r() to print the entire array into a file, then use it as a reference.
Reply With Quote
Благодарность от:
Lynne
  #3  
Old 09-06-2011, 08:07 PM
ykkrox ykkrox is offline
 
Join Date: Feb 2009
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks kh99 for the insight.

I don't want to replace the post icon that shows up when a user posts a message.
Rather, allow for a another or new icon that is independent of the VB post icon method.

In the "Additional Options" portion of the new, reply or edit post area, I'm trying to add a custom icon loading option. Since a post on my site will have many attachments of images, I want the user to have the freedom to crop their own representative thumbnail of the image.

Can I add a custom feature to the "Additional Options" box on the bottom of a posting page?

That is where I'm trying to find a hook perhaps to add this custom plugin.

Any clues or leads would help! Thanx!
Reply With Quote
  #4  
Old 09-06-2011, 08:29 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ykkrox View Post
Can I add a custom feature to the "Additional Options" box on the bottom of a posting page?
That's what I posted about above. But maybe someone else can explain it better.
Reply With Quote
  #5  
Old 09-08-2011, 03:50 AM
ykkrox ykkrox is offline
 
Join Date: Feb 2009
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Awesome! Your tips did lead me to right place.

My only question is where could I possibly get the actual "postid" of a new reply or new thread?

I noticed that in the $vbulletin->GPC there is a "postid" but it is of the postid of the previous thread in a reply (and 0 for a new thread).

You mentioned that the data will be in $post. I tried to print out the information, but I didn't get anything.

Where do I go about getting the final information from the actual post that was just created?

I'm assuming that I can obtain the current "postid" information of a post when editing a post using $vbulleting->GPC.

Thanks kh99, you've been a great help!
Reply With Quote
  #6  
Old 09-08-2011, 12:01 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The new threadid and postid will be in $post[] in build_new_post(), but not until after $dataman->save() is called. So if you create a plugin using hook newpost_complete you will be able to get the new postid.

You could also use plugins using hooks in newreply.php and newthread.php as long as they are after build_new_post() is called, and the postid will be in $newpost[].
Reply With Quote
  #7  
Old 09-10-2011, 08:44 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think $post[userid] or $newpost[userid] (depending on which hook you're using) will have the id of the original author of the post.

ETA: ...but now you've deleted the question for some reason.
Reply With Quote
  #8  
Old 09-11-2011, 12:39 AM
ykkrox ykkrox is offline
 
Join Date: Feb 2009
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks kh99 for the vigilance.
I deleted the post because I found which array contains the selected edited post info. *hint*hint*

The array is $postinfo[]
This contained all the information pertaining to the currently edited post regardless of who is logged in.
Reply With Quote
  #9  
Old 09-11-2011, 02:00 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, I guess I probably misunderstood the question.
Reply With Quote
  #10  
Old 09-11-2011, 04:21 AM
ykkrox ykkrox is offline
 
Join Date: Feb 2009
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Man I'm on the home stretch!

I'm stuck on doing the final display of a plugin.
Now I'm trying to have it show up on several sections and not others.

I found this VB snippet on another post
https://vborg.vbsupport.ru/showthrea...+certain+pages
Code:
<vb:if condition="in_array(THIS_SCRIPT, array('index', 'vbcms', 'blog'))">
stuff here
</vb:if>
What is in the "THIS_SCRIPT" to detect what page you are on?
Is there another array value that I can access to find out what page I'm on?

Thanks!


UPDATE!
I decided on using $vbulletin->script as the page detect method. Or, the replacement for "THIS_SCRIPT".
Is there a better value than that, that I can use?
Reply With Quote
Reply

Thread Tools
Display Modes

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 07:43 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06531 seconds
  • Memory Usage 2,254KB
  • Queries Executed 11 (?)
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
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete