The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Form Hack Details »» | |||||||||||||||||||||||||
Form Hack 4.1 Features: Ever wanted an online form that a user can fill out, which when submitted gets:
Or any combination or all of the above? Well, this is the hack for you! You can use this for:
Or anything you like - this hack is totally customizable via the AdminCP. The beauty of this hack is that once you install this hack, to make a new form all you need to do is copy the main hook, rename it to whatever you want, edit the variables in the hook, and you have a totally new form!!! You do not need to touch the templates again, but can always create new ones and use different templates for different forms. Format of the form:
This is customizable via the hook. Also:
INSTALLATION Easy - takes only a few minutes:
Done! Use this hack to make as many forms as you like! Enjoy! Updates: Version 4.0: (09/15/2006)
Version 4.1: (04/24/2008)
MAKE SURE YOU CLICK INSTALL! You will get an email when a new version is released. Abe1 with rights from Dr Erwin Loh Supporters / CoAuthors Show Your Support
|
Comments |
#262
|
|||
|
|||
this is really a great mod, i'm currently adjusting it to submit different kinds of content but have already completed one form which allows you to submit news, thanks very much abe!
The code is quite well commented already but i just wanted to do something in return so here is a quick overview on how to create a news submit form. The extra thing i've added here is the ability to insert a link to the source of the news (via a question in the submit form) and then a 'link' url at the end of the created thread. bit hard to understand, just take a look at the screenshots and you'll see what i mean, so let's get started with the code! 1.First of all install the mod, just follow the instructions. 2. then go to plugins> add plugin for the PHP code part. i created a plugin and named it 'submit_news', the name doesn't really matter, as long as it's understandable for you. set the hook to 'newthread_start'. Then paste this code into the Plugin PHP Code field: Code:
// To add more then one form, copy this whole text, and creat a new plug-in with the hook location 'newthread_start'. // After, change the form name. You can't have 2 forms with the same name. // Name of this form $formname = "submit_news"; if ($_REQUEST['do'] == $formname) { // ####################################################################### // ######################## CUSTOMIZE VARIABLES ########################## // ####################################################################### //////////////////////////////////////////////////////////////////////////////////////////////////// ////// BEGIN CUSTOMIZATION BELOW//////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //VARIABLES //Study how variables are add here to add or remove any. If you add a variable to your form, you must add it to part one and part two. //////////////////////////////////////////////////////////////////////////////////////////////////// // Part 1 $vbulletin->input->clean_array_gpc('p', array( 'normalanswer1' => TYPE_STR, //'radioanswer1' => TYPE_STR, //'radioanswer2' => TYPE_STR, //'radioanswer3' => TYPE_STR, //'radioanswer3other' => TYPE_STR, 'answer1' => TYPE_STR, //'answer2' => TYPE_STR, //'answer3' => TYPE_STR, //'dropdownanswer1' => TYPE_STR, //'checkboxanswer1_1' => TYPE_STR, //'checkboxanswer1_2' => TYPE_STR, //'checkboxanswer1_3' => TYPE_STR, //'longanswer1' => TYPE_STR )); // Part 2 $normalanswer1 = $vbulletin->GPC['normalanswer1']; //$radioanswer1 = $vbulletin->GPC['radioanswer1']; //$radioanswer2 = $vbulletin->GPC['radioanswer2']; //$radioanswer3 = $vbulletin->GPC['radioanswer3']; //$radioanswer3other = $vbulletin->GPC['radioanswer3other']; $answer1 = $vbulletin->GPC['answer1']; //$answer2 = $vbulletin->GPC['answer2']; //$answer3 = $vbulletin->GPC['answer3']; //$dropdownanswer1 = $vbulletin->GPC['dropdownanswer1']; //$checkboxanswer1_1 = $vbulletin->GPC['checkboxanswer1_1']; //$checkboxanswer1_2 = $vbulletin->GPC['checkboxanswer1_2']; //$checkboxanswer1_3 = $vbulletin->GPC['checkboxanswer1_3']; //$longanswer1 = $vbulletin->GPC['longanswer1']; //////////////////////////////////////////////////////////////////////////////////////////////////// //USERGROUPS ALLOWED //You can add or remove usegroups that are ALLOWED to use this form by changing the numbers below in the array. //To enable this feature, remove the '//' before the 'if'. //////////////////////////////////////////////////////////////////////////////////////////////////// // if (!in_array($vbulletin->userinfo['usergroupid'], array(2,5,6,7))) print_no_permission(); //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //NAME OF TEMPLATES - DO THIS BIT IF YOU ARE MAKING MORE FORMS AND WANT TO USE A DIFFERENT LOOKING TEMPLATE //////////////////////////////////////////////////////////////////////////////////////////////////// // Name of the main template $maintemplate = "newsform"; // Name of the answer template $answertemplate = "newsformanswers"; //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //CHOOSE WHETHER YOU WANT FORM TO BE POSTED IN A NEW THREAD, NEW POLL, REPLY TO EXISITING THREAD, PMed OR EMAILED /////////////////////////////////////////////////////////////////////////////////////////////////// //ENABLE FORM TO BE POSTED - 1 = yes, 0 = no $formforum = "1"; //FORUM TO POST NEW THREAD IN //You CAN make this number a variable. You can have a drop down menu or in the link like do=form&f=1. Make sure you add it the variables list. $formforumid = "24"; //ENABLE POLL TO BE CREATED - 1 = yes, 0 = no $formpoll = "0"; $polloption[1] = "Yes"; $polloption[2] = "No"; $polloption[3] = "Maybe"; //Make poll public - 1 = yes, 0 = no $pollpublic = "0"; //////////////////////////////////////////////////////////////////////////////////////////////////// //ENABLE FORM TO REPLY TO EXISTING THREAD - 1 = yes, 0 = no $formreply = "0"; //EXISTING THREAD ID FOR FORM TO REPLY IN $formreplythreadid = "12345"; //////////////////////////////////////////////////////////////////////////////////////////////////// //ENABLE FORM TO BE PMED (guests CANNOT use this option) - 1 = yes, 0 = no $formpm = "0"; //USERNAME TO PM TO (separate multiple usernames with a ';') $formpmname = "Abe"; //////////////////////////////////////////////////////////////////////////////////////////////////// //ENABLE FORM TO BE EMAILED - 1 = yes, 0 = no $formemail = "0"; //EMAIL ADDRESS TO EMAIL TO (separate multiple usernames with a ';') $formemailaddress = "youremail@yourforums.com"; //////////////////////////////////////////////////////////////////////////////////////////////////// //ENABLE ATTACHMENTS - 1 = yes, 0 = no //attachments can only be used if the form is going to make a new thread or post $allow_attachments = "1"; //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //REDIRECT OPTIONS: // 0 - thank you message (thread, reply, pm, or email) // 1 - redirect to post (thread or reply) // 2 - redirect to thread (thread only) // 3 - redirect to forum (thread only) // 4 - redirect to editpost (thread or reply) // // Feel free to change the thank you message if you choose option 0 //////////////////////////////////////////////////////////////////////////////////////////////////// $redirectoption = "0"; $errormessage = "Thank you for submitting news! you're content will be reviewed by our staff, so it might take a short time before it shows up."; //This is the thank you message //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //FORCE USER TO ANSWER ALL QUESTIONS - 1 = yes, 0 = no //If you added or deleted variables, you must edit what it checked for. Search for "$answerall ==" and edit 2 lines under it. //////////////////////////////////////////////////////////////////////////////////////////////////// $answerall = "0"; //////////////////////////////////////////////////////////////////////////////////////////////////// //TITLE OF FORM (do not use quotation marks or you will get a parse error, besides the quotes around the whole title) //////////////////////////////////////////////////////////////////////////////////////////////////// $formtitle = "Submit CG News"; //////////////////////////////////////////////////////////////////////////////////////////////////// //TITLE OF THREAD/POST/PM/EMAIL (do not use quotation marks in the title or you will get a parse error) //You may use variables from the form for this. //////////////////////////////////////////////////////////////////////////////////////////////////// $posttitle = "$normalanswer1"; //////////////////////////////////////////////////////////////////////////////////////////////////// //PURPOSE OF FORM (do not use quotation marks or you will get a parse error, besides the quotes around the whole text) //////////////////////////////////////////////////////////////////////////////////////////////////// $formpurpose = "Use the form below to submit Computer Graphics related news on tutorials, software releases and new technology. Your content will be reviewed so it will take a short time to show up, be sure to attach a small image as well."; //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //NORMAL INPUT BOX : QUESTION 1 (do not use quotation marks or you will get a parse error, besides the quotes around the whole text) //////////////////////////////////////////////////////////////////////////////////////////////////// $normalquestion1 = "fill in a descriptive, short title/heading:"; //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //RADIO BOX CHOICES : QUESTION 1 (do not use quotation marks or you will get a parse error, besides the quotes around the whole text) //////////////////////////////////////////////////////////////////////////////////////////////////// //$radioquestion1 = "Choose one of the following choices"; // The following choices must NOT have quotation marks //$radiochoice1a = "yes"; //$radiochoice1b = "no"; //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //RADIO BOX CHOICES : QUESTION 2 (do not use quotation marks or you will get a parse error, besides the quotes around the whole text) //////////////////////////////////////////////////////////////////////////////////////////////////// //$radioquestion2 = "Choose another one of the following choices"; // The following choices must NOT have quotation marks //$radiochoice2a = "good"; //$radiochoice2b = "bad"; //$radiochoice2c = "both"; //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //RADIO BOX CHOICES : QUESTION 3 (do not use quotation marks or you will get a parse error, besides the quotes around the whole text) //////////////////////////////////////////////////////////////////////////////////////////////////// //$radioquestion3 = "Is it yes or no? If yes, please elaborate"; // The following choices must NOT have quotation marks //$radiochoice3a = "yes"; //$radiochoice3b = "no"; //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //QUESTION 1 (do not use quotation marks or you will get a parse error, besides the quotes around the whole text) $question1 = "direct link to news "; $explain1 = "for example: http://www.enjoycg.com/article"; //QUESTION 2 (do not use quotation marks or you will get a parse error, besides the quotes //around the whole text) //$question2 = "What is your email?"; //$explain2 = "Please enter your real email here."; //QUESTION 3 (do not use quotation marks or you will get a parse error, besides the quotes //around the whole text) //$question3 = "What is your website?"; //$explain3 = "Please enter your URL here."; //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //DROP DOWN CHOICES : QUESTION 1 (do not use quotation marks or you will get a parse error, besides the quotes around the whole text) //////////////////////////////////////////////////////////////////////////////////////////////////// //$dropdownquestion1 = "What filetype are you uploading?"; // The following choices must NOT have quotation marks //$dropdownchoice1a = "image, .jpg, .gif, .png etc."; //$dropdownchoice1b = ".3ds, .obj, .max"; //$dropdownchoice1c = "other"; //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //CHECK BOX CHOICES : QUESTION 1 (do not use quotation marks or you will get a parse error, besides the quotes around the whole text) //////////////////////////////////////////////////////////////////////////////////////////////////// //$checkboxquestion1 = "This shows how to use checkboxes."; // The following choices must NOT have quotation marks //$checkboxchoice1_1 = "good"; //$checkboxchoice1_2 = "bad"; //$checkboxchoice1_3 = "both"; //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //LONG TEXT AREA INPUT: QUESTION 1 (do not use quotation marks or you will get a parse error, besides the quotes around the whole text) //////////////////////////////////////////////////////////////////////////////////////////////////// //$longquestion1 = "Please write down a paragraph about yourself."; //$longexplain1 = "For example, a bit about your experience in this area."; //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //VB TEXT AREA INPUT: You can only have ONE vb text question. (do not use quotation marks or you will get a parse error, besides the quotes around the whole text) //////////////////////////////////////////////////////////////////////////////////////////////////// $vbtextquestion = "Please describe your news in short, one or two sentences."; $vbtextexplain = "a link to the news is not neccessary, it will be added automatically."; } IMPORTANT: i didn't change the main script, you should insert it after this code, you can find the code in the original 'form hack' plugin. i'm not going to explain all of the changes but they are actually fairly simple, many questions were just taken out because i didn't need them, it's important to use this name though, so it matches when you want to load the form later: $formname = "submit_news"; |
#263
|
|||
|
|||
here's part 2 of the explanation, it was too long to fit in one post!
4.Alright, that's all for the code, now we need to adjust the templates, you can copy the code and after that make adjustments to it yourself. first the 'newsform' template, go to 'styles & templates> all template options' and select 'new template' name the template 'newsform'. The name 'newsform' is important, because this links back to the php code part! this will provide the look of the submit form, here's the entire code: Code:
$stylevar[htmldoctype] <html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]"> <head> $headinclude <title>$vboptions[bbtitle] - $formtitle</title> </head> <body> $header $navbar <!-- main --> <if condition="$preview"> <table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center"> <tr> <td class="tcat"> Preview </td> </tr> <tr> <td class="alt2"> $preview </td> </tr> </table> </if> <br /> <form name="vbform" action="newthread.php" method="post"<if condition="!is_browser('webtv')"> onsubmit="return vB_Editor['$editorid'].prepare_submit(0, $vboptions[postminchars])"</if>> <input type="hidden" value="$formname" name="do" /> <input type="hidden" value="submit" name="action" /> <input type="hidden" name="posthash" value="$posthash" /> <input type="hidden" name="poststarttime" value="$poststarttime" /> <table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center"> <tr> <td class="tcat" colspan="3"> $vboptions[bbtitle] - $formtitle </td> </tr> <tr> <td class="panelsurround" align="center" colspan="3"> <table class="panel" cellpadding="0" cellspacing="$stylevar[formspacer]" border="0" width="100%"> <tr> <td align="$stylevar[left]"> <fieldset class="fieldset" style="margin:0px"> <table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0"> <tr> <td> $formpurpose </td> </tr> </table> </fieldset> </td> </tr> </table> </td> </tr> <tr> <td class="alt2" colspan="3"> <b>$normalquestion1</b> <input type="text" size="30" value="$normalanswer1" name="normalanswer1" /> </td> </tr> <tr> <td class="alt2" valign="middle"> <b>Username</b>:<br /> Your Username.</td> <td class="alt2" valign="middle" colspan="2"> <b>$bbuserinfo[username]</b></td> </tr> <tr> <td class="alt2" valign="middle"> <b>$question1</b>:<br /> $explain1</td> <td class="alt2" valign="middle" colspan="2"> <input type="text" size="30" value="$answer1" name="answer1" /></td> </tr> <tr> <td class="alt2" valign="middle" colspan="3"> <b>$vbtextquestion</b><br /> $vbtextexplain <div align="center"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td> $messagearea </td> </tr> </table> </div> </td> </tr> <if condition="$attachmentoption"> <tr> <td class="alt1" colspan="3" align="center"> <div style="width:$stylevar[formwidth]" align="$stylevar[left]">$attachmentoption</div> </td> </tr> </if> <tr> <td valign="top" colspan="3"> <p align="center"> <input type="submit" value="Submit" name="submit" style="font-family: Verdana; font-size: 10pt" class="button" /> <input type="submit" value="Preview" name="submit" style="font-family: Verdana; font-size: 10pt" class="button" /> <input type="reset" value="Reset" name="reset" style="font-family: Verdana; font-size: 10pt" class="button" /> </p></td></tr> </table> </form> $footer </body> </html> 5.Now the final template called 'newsformanswers' (again, the name is important, it's linked to the PHP code part!) use the same procedure as with the other template but now use this simple code instead: Code:
$vbtextanswer link Alright, i know this explanation is quite simple but if you use the exact same code it should work fine, i hope you found this usefull, if you have any questions don't hesitate. I've taken this a bit further myself by using vbadvanced CMPS, it's free and quite good for what i need, the submitted news goes into a forum, and the CMPS then takes that data from the forum and posts it in a news layout on a different page. One thing i would like to implement is a sort of browse button to directly add attachments, any idea if that's possible? |
#264
|
||||
|
||||
That did it - all working in conjuncton with your newthread button hack, thanks.
|
#265
|
|||
|
|||
Love the mod, but I'm now getting crazy spam through this. I use it as a "contact us" which gets posted in a mod-only section. PLEASE -- is there any way to add Captcha or some other human-entry question that must be answered correctly to prevent the spam?
Thanks -vissa |
#266
|
|||
|
|||
Unfortunately not for me. As soon as I want to edit the main hook I get:
Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, service@xxxxxxdotde and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. |
#267
|
||||
|
||||
Is this hack use usergroup permissions?
|
#268
|
|||
|
|||
Quote:
Peace |
#269
|
|||
|
|||
The attachments are a great improvement but do you think it's possible to also include the thread rating (stars) in the form?
I'm using it as a 'write a review' form and it would be nice to have the rating included in the database instead of using static content. |
#270
|
|||
|
|||
Quote:
Am I just stupid or what do I need to change to get this to work? |
#271
|
|||
|
|||
Is there a way to make the $posttitle one of the inputs? For instance, if I create a field called "Title" and allow a user to type a title, how do I make that show up as the actual $posttitle?
EDIT: I figured it out It works great now. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|