View Full Version : Additional Options
ykkrox
09-06-2011, 01:35 AM
HI!
My first question here after much googling..:p
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!
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.
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.
ykkrox
09-06-2011, 08:07 PM
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!
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.
ykkrox
09-08-2011, 03:50 AM
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!
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[].
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.
ykkrox
09-11-2011, 12:39 AM
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.
OK, I guess I probably misunderstood the question.
ykkrox
09-11-2011, 04:21 AM
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/showthread.php?t=236417&highlight=display+certain+pages
<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?
HMBeaty
09-11-2011, 04:26 AM
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/showthread.php?t=236417&highlight=display+certain+pages
<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!
Open up the php file ;) For example, open blog.php in a text editor and see where it says:
if (!defined('THIS_SCRIPT')) { define('THIS_SCRIPT', 'blog'); }
The main part you want to look for in that is:
define('THIS_SCRIPT', 'blog');
And you would enter blog as part of that array :)
ykkrox
09-17-2011, 11:50 AM
sweet! thanks peeps!
One last thing I was trying to achieve is to keep the legacy posts with an available thumbnail attachment option available.
But for the new posts, I don't need to view the thumbnail attachments.
I tried this bit of code and it didn't hide the thumbnails in the template postbit.
<vb:if condition="$show['thumbnailattachment'] && $postinfo['dateline'] < *epoch time* ">
Am I updating the wrong template??
ALSO - I wanted to know if there is any way for an Admin to post Javascript in a post. Is this possible?
I'm trying to use it with BB Code, but Javascript:functionName() is always replaced with javascript<b></b>:functionName()
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.