Please upgrade here. These earlier versions are no longer being updated and have security issues.

Add new Field when creating new discussion

Hi,

Just wondering if there is a way or even a plugin, that can add a dropdown list field to the New Discussion.

For example add a field under the category like shown in this image:

Tagged:

Comments

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    You'll need to writ your own plugin, but believe me: this is really easy for what you are trying to do.

    Look at some simple plugins. Maybe that one: http://vanillaforums.org/addon/usersvanillaversion-plugin

    You'll have to have a function setup that adds a field to the discussion table. See how it is done in the example plugin above. You'll only need to know the name of the table and that is "Discussion" instead of "User".

    Afterwards, all you have to do in your plugin is showing the field at the right place. Download the plugin eventi. It will show a lot of information. Look at the place where you want your dropdown to appear and you will find something like "PostController_BeforeBodyInput_Handler" which is the name of the function that you have to put in your plugin in order to display the DropDown.

    Well, I admit I made it sound complicated... :(

    But believe me: it is really easy once you start by looking at some examples!


    Bleistivthgtonight
  • hgtonighthgtonight ∞ · New Moderator

    You know, I have a plugin that makes this super easy, but I haven't gotten around to releasing it publicly yet.

    You can find it attached. I plan on releasing it soonish.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

    Bleistivt
  • aaronkingaaronking New
    edited December 2014

    @R_J thanks for your suggestion I will look more into developing a plugin when I have some time.

    @hgtonigh, thanks heaps for your plugin. Just tried it out and does just what I want except if you have multiple Category's I want it so that it only shows some options based on the Category selected. Maybe make it ask what Category you want the field to show in, then if you select a different Category it will show different fields to fill in.

    For example:
    In my case I am using the forum for my app I wrote. Users seem to post questions but I don't know what version of a app they are referring to.

    I have multiple category's in my forum as I have multiple apps and I am using a category for each of my apps on my forum.
    Category1 = App 1
    Category2 = App 2

    However I might of released multiple versions of App 1 over time (such as version 1.0.0, Version 1.0.1)
    App 2 might have different version numbers (such as version 1.0.4, Version 1.0.5)

    I don't want people to select 1.0.4 if they are referring to App 1 since that version doesn't exist yet..
    I guess I can make it a textfield so they manually have to enter in the version number manually.

    Also maybe worth adding a Position called 'Before Title' so that you can put it between the 'Category' and 'Discussion Title'.

    I also noticed that you can't enter in dots between the text, such as if you wanted a dropdown list you can't enter in something like Version 1.0.0 as it will remove the dots when you save it. I had to do something like Version 1-0-0.

    Maybe these suggestions can be added when you have time, but other than that this plugin was really good and I like it. Good job!

  • hgtonighthgtonight ∞ · New Moderator
    edited December 2014

    @aaronking said:
    I also noticed that you can't enter in dots between the text, such as if you wanted a dropdown list you can't enter in something like Version 1.0.0 as it will remove the dots when you save it. I had to do something like Version 1-0-0.

    That is because I specifically remove them. You could make a small modification to it to not remove them. Find the line

    $Options = explode("\n", preg_replace('`[^\w\s-]`', '', $Options));
    

    in /plugins/DiscussionExtender/class.discussionextender.plugin.php (Mine was on line 121). Replace it with

    $Options = explode("\n", preg_replace('`[^\w\s\.-]`', '', $Options));
    

    Test to see if it works.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

    vrijvlinder
  • Thank you.. changing that code now allows me to use dots.

Sign In or Register to comment.