Easily Extensible Thread Types

Wildcat Media

Well-known member
Right now, we have four thread types--discussion, article, question, poll.

Yet there is no easy way that I can see to create new thread types.

I am suggesting a way for use to be able to create a subset of templates so we can create our own thread types. I can think of two or three off the top of my head, where custom layouts would apply to these thread types that I wouldn't necessarily want in any other thread type. For some of these, I could possibly try the resource manager add-on but even there, we only really have layout for a single type of resource.

What I envision is an interface to first create a new thread type (which would include offering it as a selectable option, offer it as part of node where only that thread type is allowed, create "preview" similar to the article preview, and create appropriate permissions where needed), which would then open up a means to either copy over templates from existing thread types for us to modify, or allow us to create our own from scratch. Aside from things like the voting feature in the Questions thread type, or the Poll function, most of these are based on layout changes.

As it is now, I could easily modify templates to change appearance to do what I want for a couple of new thread types I need, but unless I used a crap ton of conditionals based on the node ID (which would be a major kludge), it's not all that easy to do.

With some sort of method to first create/register a new thread type, and offer us a distinct set of templates to customize each of our new thread types, that would help us improve the utility of our forums.

I've considered the resource manager and creating some major template changes for a couple of our use cases, but since we can only have one Resource Manager layout, that is similarly restrictive.
 
Upvote 7
what about these ? https://xenforo.com/docs/xf2/forum-thread-types/
as discussed here
 
I would add:

Hierarchical Posts
Hierarchical posts forums will contain a thread list with nested replies. This forum type will not have a separate page for threads.

A sample can be seen here:
 
We also went a bit farther and designed a new Category type that allows users to sort forums. It also have nested forums that open without going to a new page.

 
I'd be interested in this, you can already make new thread types, pretty easily. using:
PHP:
public function installStep1() {
    $this->insertThreadType();
}
But to actually use that custom ThreadType, it gets a little bit tricky. (Feel free to correct me if i'm wrong)
So you have two choices, you can:
a) Create a new ForumType to add that new ThreadType into public function getPossibleCreatableThreadTypes(Forum $forum): array[B][/B]
b) Manually edit the XF/ForumType/DiscussionHandler.php class adding in your new ThreadType.

Creating a new ForumType seems a bit extreme to me, but editing the XF files just feels dicey.


Edit: To add on to this, If you do choose option b) you will get file health check issues. So that really only leaves you with option a). :(
 
Last edited:
Yeah, both of those are beyond my coding skills, and I won't bother even attempting it. I also agree with your option "A" of being the better choice, and that is how add-on developers would do it. But, you would think this could also be simplified by giving us an admin option to add forum/thread types without needing to do any coding, perhaps with the option to use our own templates for each of those types. (Although that would also greatly complicate coding for the XF folks.)

I would attempt to get an add-on developed for us, but it's outside the budget. With hosting fees and everything else, it's not that important. We'll just have to hobble together what we can using a specific child style (templates) to get what we need.
 
b) Manually edit the XF/ForumType/DiscussionHandler.php class adding in your new ThreadType.
I was mistaken, I did a bit of digging, and you can just create a class extension, and just inject the thread_type like this:
PHP:
class DiscussionHandler extends \XF\ForumType\DiscussionHandler
{
    public function getPossibleCreatableThreadTypes(Forum $forum): array
    {
        $types = parent::getPossibleCreatableThreadTypes($forum);
       
        if (!in_array('threadTypeName', $types)) {
            $types[] = 'threadTypeName';
        }
       
        return $types;
    }
}

That did kind of ruin a point I was trying to make. :) But I still agree, even if they don't make the entire process easier. I'd settle for some kind of documentation, to walk you through the process. As the entire process isn't exactly beginner friendly.
 
I would actually like to see a Contest type thread that works sort of like the Question thread. The first post sets the conditions and the closing date, the following posts are the entries. People vote on an entry or multiple entries. When the thread closes the post with the most votes is moved into what is currently the Solution spot.

In the top bar you could have Open and Closed contests, and a list of contests you have won. Maybe a few other things.

And then, you could tie this into the Trophy system and actually make that useful instead of being the feature we all stick in the closet because we cannot figure out what to do with it.

EDIT: If there is a dev out there that wants to take this on and enough site owners willing to chip in, count me in as well. I am decent with some basic php but this one is probably beyond me too. Someone throw a price out there and we will see if there is enough interest.

EDIT 2: I will throw $100 into the pool tomorrow, if there are other people willing to jump in too.
 
Last edited:
I would actually like to see a Contest type thread that works sort of like the Question thread. The first post sets the conditions and the closing date, the following posts are the entries. People vote on an entry or multiple entries. When the thread closes the post with the most votes is moved into what is currently the Solution spot.

In the top bar you could have Open and Closed contests, and a list of contests you have won. Maybe a few other things.

And then, you could tie this into the Trophy system and actually make that useful instead of being the feature we all stick in the closet because we cannot figure out what to do with it.

EDIT: If there is a dev out there that wants to take this on and enough site owners willing to chip in, count me in as well. I am decent with some basic php but this one is probably beyond me too. Someone throw a price out there and we will see if there is enough interest.

EDIT 2: I will throw $100 into the pool tomorrow, if there are other people willing to jump in too.
I've not investigated it, but isn't that what this add-on does?

 
Outside of structured data / schema where applicable, I need it explained why we need to think of the different thread types.

A poll is just something tacked on to the top of a thread, why can’t you have a poll on an article, question or suggestion thread?

A question type thread is just a discussion type thread that can have vote. an answer marked as solution and OP tacked non to the top of every page.

Why can’t these just be options for discussion type threads?

An article is just a discussion thread but with twice as many characters, first post stuck to all pages and an enhanced grid/image view when you get a bunch of them in a forum view. Again why can’t those just be features you add to a discussion type thread?

So maybe someone can explain why we need these different “types” as opposed to just one type but with custom options to add:

  • Poll/survey
  • Voting
  • Solution marking
  • More characters allowed
  • Stick first post to all pages
  • Enhanced grid view
 
I do not see anything on that site that even remotely is like what we are talking about and with that annoying popup ad on the bottom I wont be investigating it much further. If you really want people to look at a site then don't have an ad that pops up over the top of the cookie announcement and then keeps coming back when you push it down.
 
Outside of structured data / schema where applicable, I need it explained why we need to think of the different thread types.

A poll is just something tacked on to the top of a thread, why can’t you have a poll on an article, question or suggestion thread?

A question type thread is just a discussion type thread that can have vote. an answer marked as solution and OP tacked non to the top of every page.

Why can’t these just be options for discussion type threads?

An article is just a discussion thread but with twice as many characters, first post stuck to all pages and an enhanced grid/image view when you get a bunch of them in a forum view. Again why can’t those just be features you add to a discussion type thread?

So maybe someone can explain why we need these different “types” as opposed to just one type but with custom options to add:

  • Poll/survey
  • Voting
  • Solution marking
  • More characters allowed
  • Stick first post to all pages
  • Enhanced grid view
Simply put for me, it's clarity. Sure we have a few thread types now, and they can be re purposed to what we need. But with custom thread types we would be able to make everything clearer, no more repurposing other thread types. If we wanted a new type of disucssion, we could just add a new thread type.

Art portfolios, Showcases, Guides, Creative Writing, Auctions, there are so many options.

Thread types, are one of the key features of a forum. Being able to create custom functionality easily, would let us all take our forums to the next step.

Final answer:
If the discussion thread was completely blank with no logic what so ever, I'd agree. We'd just be able to build off that, but the XF/ThreadType/AbstractHandler contains messaging logic, the XF/ThreadType/DiscussionHandler actually doesn't contain much code at all. The only thing it does it set an icon, and handle thread merges.

So we don't truely have complete control over thread types. We are from what I can see forced to have some kind of discussion baseline. Stopping us from creating thread types outside the discussion baseline.
 
Last edited:
Back
Top Bottom