Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Looking for pointers on new plugin

Hi all,

I run a large forum that, among other things, has a trading post section where members trade stuff.

Recently, Facebook has updated its groups UIs to include the ability to post items for sale. Since then, I've seen a bit of traffic go from the forums to Facebook groups of similar purpose. So I thought, it's not such a bad idea - the trading post SHOULD hold a bit more metadata and maybe have a cleaner interface for adding a price, location, photos, etc.

My question is, where would I start in terms of code for doing this? I've built a number of plugins for Vanilla, but nothing that has such a big impact on the underlying content.

My best guess at the moment is:

  1. Hook a function before create post and insert some additional UI with custom fields.
  2. Hook after discussion creation and persist those additional fields to a new table in the db along with the discussion ID it is associated with
  3. Hook before discussions list render function and tweak the render output to markup this additional metadata and display it in some manner
  4. Hook the before discussion render and markup the same information there + any other customisation I might want to make to the first post

Does that seem like a reasonable way to do it?

Just looking on some best-practices advice.

Cheers,
James

Comments

  • BleistivtBleistivt Moderator

    I would first take a look at the QnA plugin, because it defines a new discussion type (question) which is pretty much what you are doing too.
    http://vanillaforums.org/addon/qna-plugin
    The advantage of having a separate discussion type is that you can filter discussions by trading post the same way you can filter by questions.

    If your system could get more complex in the future, adding a new table would be the way to go. You should then also define a new model for trading posts.

    As long as you know that you only want to add a few more optional fields to a discussion, I would actually add new columns for these to the discussion table.

    The best example how to do that is probably the DiscussionExtender plugin
    http://vanillaforums.org/addon/discussionextender-plugin

    The discussions table also has an "attributes" column. You can save arbitrary data in discussion attributes (as long as it doesn't exceed the mysql "text" size which is 64k).

    Take a look at these functions in Gdn_Model: SaveToSerializedColumn, ExpandAttributes (since 2.2), CollapseAttributes (since 2.2)
    Note that you can not sort and query by attributes since they are serialized.

    A few advantages of using discussions:

    • No need for a new table & model
    • The trade item gets created and deleted with the discussion - no need to synchronize data
    • You can define permission by categoy for all of these actions
Sign In or Register to comment.