Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-17-2008, 01:55 AM
VodkaFish VodkaFish is offline
 
Join Date: Oct 2003
Posts: 125
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default $post in 3.7

While on my journey from 3.6 to 3.7 I'm having some trouble with a script I have that looks at some extra checkboxes below a post.

In the newpost_process hook I take $post['message'] and parse it for a variety of things based on the checkboxes below the post.

So I'd have this in my template:
HTML Code:
<div><label for="cb_parsethis"><input type="checkbox" name="parsethis" value="1" id="cb_parsethis" tabindex="1" $checked[parsethis] />Parse this</label></div>

Then in the hook I'd have:
PHP Code:
if ($post['parsethis'])
{
echo 
"parsethis";

Checked off or not, I'm never getting within that if statement. If I can't use $post['parsethis'] what can I use to see if parsethis was checked off?
Reply With Quote
  #2  
Old 08-17-2008, 09:44 AM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The users have to "submit" the form, it won't just run the code automatically when you tick the box.

Note: Including forms inside posts, will cause conflicts with the inline moderation form (the one that allows you to check the boxes in the corner of a post). That is if you are a user with inline moderation permissions.
Reply With Quote
  #3  
Old 08-17-2008, 11:39 AM
VodkaFish VodkaFish is offline
 
Join Date: Oct 2003
Posts: 125
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm sorry, I didn't explain what I was doing properly.

This is a checkbox I've added to the misc area for when you make a new post, right under "Automatically parse links in text" that all vB new posts have. It's not a form within a form, just an additional input field.
Reply With Quote
  #4  
Old 08-17-2008, 12:24 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh, I see. You need to clean the input ( Using the vBulletin Input Cleaner) from the checkbox. TYPE_BOOL will probably be the one you want. Then you check it like so:
PHP Code:
if($vbulletin->GPC['parsethis'])
{
    
// parse away

Reply With Quote
  #5  
Old 08-17-2008, 01:44 PM
VodkaFish VodkaFish is offline
 
Join Date: Oct 2003
Posts: 125
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The odd thing is if I put print_r($post) in the newpost_process hook, I see everything in the $post array, and [parsethis] is nowhere to be found. For some reason the field is not being submitted.
Reply With Quote
  #6  
Old 08-17-2008, 04:14 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Use the information I gave you in my previous post, you could just add it to $post yourself...

If you want to see what vBulletin is doing with your code, start with the form submission. (Look at where the form posts too, you can find it by looking at the HTML code for the form.) Follow it through the relevant PHP files and see what vBulletin is doing to it.

Most likely the following files will be appropriate:

newreply.php
newthread.php
functions_newpost.php
Reply With Quote
  #7  
Old 08-21-2008, 03:58 AM
VodkaFish VodkaFish is offline
 
Join Date: Oct 2003
Posts: 125
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Opserty View Post
Use the information I gave you in my previous post, you could just add it to $post yourself...
That's what I'm trying to do, or should I say that's what I was doing previously. $post would just include any input field I added to the form in the newthread template. I assume I need to do something in the hook I'm using (newpost_process) or another one that gets hit first. I tried to "clean" it, but it's not even being passed along to clean, so obviously vbulletin is ignoring the field - where can I tell it to look for it?

(thanks for your help so far)
Reply With Quote
  #8  
Old 08-21-2008, 07:53 AM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$post is a variable used within a function... you need to clean it and pass it to the function using another hook. It won't look for it, you need to do the same thing vBulletin does to the other variables.

I think instead of my trying to explain it, it would just be easier to look in the PHP file, follow it from where the form has been submitted.
Reply With Quote
  #9  
Old 08-21-2008, 12:26 PM
VodkaFish VodkaFish is offline
 
Join Date: Oct 2003
Posts: 125
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, I just have to figure out how to pass it. In 3.6.x it was passed automatically.

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

Ok, ok. A cleaning was all that was necessary, and then I was able to access it (just using the method you did above).

Sample for those reading this:
PHP Code:
$vbulletin->input->clean_array_gpc('p', array('parsethis' => TYPE_BOOL));

if(
$vbulletin->GPC['parsethis'])
{
    
// parse away

Using $vbulletin->GPC['parsethis'] instead of $post['parsethis'] is no big deal, just a few search and replace changes.

Thanks again for the help.
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:06 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.06787 seconds
  • Memory Usage 2,250KB
  • 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_html
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)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
  • 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