The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
[HOW TO] Add additional fields
This guide will show you how to add additional fields to your threads. This feature has been requested many many times and can be very powerfull. Imagine that you want to add additional fields to your threads, such that every time a user create a new thread has the opportunity to fill these fields. This requires HTML and PHP experience, so be prepared! Add additional fields The very first step is to the the HTML code of the additional fields into newthread template. This can be done by adding HTML code directly into the HTML code right after the Title field: HTML Code:
<input type="text" class="primary full textbox" name="subject" id="subject" value="{vb:raw subject}" maxlength="{vb:raw vboptions.titlemaxchars}" tabindex="1" /> <img id="display_posticon" src="{vb:raw selectedicon.src}" alt="{vb:raw selectedicon.alt}" /> </div> HTML Code:
<input type="text" name="additionalField" />
Catch additional fields values Now that you have add some fields to newthread template, you need to catch them before adding them to the database. This can simply be done by hooking newthread_post_start and catching the field value: PHP Code:
Add additional fields values to post/database Now we have catched the field value ($value) and are ready to save it to the database or to the post. Personally I prefer to add it to the post, because it will be searchable by default and can be done very easily (easier than adding it to an extra database table) Once you cashed the field variable as described above, you can add it to the post by: PHP Code:
Extra BBcodes If you want to wrap $value with some extra HTML codes, then you need to create some custom BBcodes and wrap it around the value: PHP Code:
Case study Let's say we want to add an additonal field that will carry the source URL of an article. First we add: HTML Code:
<input type="text" name="additionalFieldURL" />
Then create a plugin (something similar to the following). PHP Code:
And you are done! Note: the plugin is just to show you how this works and by no mean is supported or ready for production. Got a question, suggestion or improvment? don't hesitate to let me know |
#12
|
|||
|
|||
Can you show how to add the new value to a separate field in the thread table?
thanks in advance |
#13
|
|||
|
|||
what about CMS additional fields?
|
#14
|
|||
|
|||
how to add field before username
|
#15
|
|||
|
|||
I would advice you to wait until custom type, which is going to be released soon.
--------------- Added [DATE]1283604974[/DATE] at [TIME]1283604974[/TIME] --------------- It depends on what you are trying to achieve. |
#16
|
|||
|
|||
which version it will be?
|
#17
|
|||
|
|||
|
#18
|
|||
|
|||
I need how-to guide for Extra Post Fields similar to extra thread fields written in this article.
Thanks |
#19
|
|||
|
|||
How would you use $value = $vbulletin->input->clean_gpc('p', "additionField", TYPE_STR); to get both the value and text from a dropdown list?
Never mind. Figured it out. |
#20
|
|||
|
|||
Glad I found this article. Too bad I have yet to figure out what I'm trying to do. Hopefully someone here can help.
I'm trying to add a field in the template "calendar_edit" for people to add an image url to calendar events. I got the field visible when creating an event by using the following: Code:
<div class="blockrow"> <label for="imgfield" class="full">Enter IMG URL:</label> <input type="text" class="primary full textbox" id="imgfield" name="imgurl" value="{vb:raw img_url}" tabindex="1"/> <p class="singledescription">This field is important. It will place this image on our Forum Home page's "Upcoming Events" side block.</p> </div> Eventually, I want to place this image in a sideblock for upcoming events but it's not saving the field entered data. --------------- Added [DATE]1290186736[/DATE] at [TIME]1290186736[/TIME] --------------- Here is the product I have edited. PHP Code:
Does everything else look right? Do I need this for what I'm trying to accomplish?: PHP Code:
And here is my Forum Block: PHP Code:
|
#21
|
|||
|
|||
How do i save it as separate column in post or thread table instead of modifying post message? It could be much more useful i think.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|