Entities and plugable backends for Advanced Forum

Events happening in the community are now at Drupal community events on www.drupal.org.
michelle's picture

I hit a point tonight where I decided I really need to get my website to Drupal 7 and that has pushed up working on changing AF over to using a pluggable back end / entities way sooner than I had planned. I decided to start this discussion to get some thoughts out there and also so people are aware of what I'm working on since the code won't be on d.o any time soon.

There's some early thoughts here, though that's dealing with the forums themselves being entities: http://drupal.org/node/755438

At the moment, I'm focused on making the posts entities. Some reasoning behind that, in no particular order:

  • Forum replies are not lesser than forum topic starting posts as they are with the old blog + comments idea.
  • Consistency in fields between topic starter and replies. Comments being fieldable was a leap forward and this isn't a huge issue, but it's nice to not have to redo field stuff on both.
  • Easier moderation. Can grab a section of posts and set it to be a new topic without having to change the type of the first post. Merge two topics together.
  • Easier to import from other forum software that doesn't distinguish between the starting post and the replies.
  • Any view / query that needs to deal with both the starting post and the replies is easier. In D6, you can't merge comments and nodes in a view. I don't know if that has changed in D7.
  • Search returns results from starter/replies.
  • Revision history on all posts. (Not sure if this is an issue with D7 comments)
  • Fined grained access control. Can do things like allow time limited access to editing.
  • Not overloading the node table with hundreds of thousands of nodes on busy sites with a lot of posts as Node Comments will do.

The pluggable part comes in because I don't want to completely ditch core forum. Well, ok, I want to, but I don't think it's a good idea. I think a big part of why AF became popular while other attempts didn't was that I presented it as a wrapper around core rather than this whole other "thing" that you were locked into. By decoupling the add-on parts of AF from the post storage / forum config stuff as much as possible, I should, in theory, be able to support both core forum with the node + comment system and the new entity system. If I can't, well, then I don't know. For my own site I will be using the new system and that is where my focus is. We'll cross that bridge if and when we come to it, I guess.

My first step is a lot of reading. I've barely paid any attention to D7 since I was so focused on D6 and I'm frightfully far behind. I need to get a good grasp on entities and working with them. Then I need to do some detective work in AF to figure out where it all hooks into core forum and see how much of that can be abstracted out. Then I need to make stuff work with entities in addition / instead. I'm going to be playing with this all in my own dev environment and won't be committing anything for a while. The 2.x branch is just barely in Alpha so I hate to officially branch now and deal with all that double duty in D7 on top of keeping D6 going. Once I have something worth showing, I may just do a sandbox or something with it until 2.x gets to a sensible branching point. We'll see. I'm only at the beginning stages of this so may change my mind once I get going.

Michelle

Comments

All of the bullet points look

catch's picture

All of the bullet points look exactly right to me. Comments in D7 don't have revisions, but a custom 'forum_post' entity type can.

Nice

HaloFX's picture

Your list looks right on to me.

On the right track

mpotter's picture

I think you are on the right track and your points look good. I'm glad to see you getting into the D7 stuff. Now you know why I was so excited about D7 forums at the BOF at Drupalcon.

I am at the same stage as you and am doing a lot of reading and research. I have also met with some local Drupal devs who are interested in this topic. Here is a summary of our thoughts related to yours:

  • Don't try to do the D7 entity stuff in Advanced Forum 2.x. Go ahead with a 3.x branch that will be D7 only. Let others who are really interested in AF 2.x in D7 help with maintenance, back-porting etc, but focus your main attention on the D7 future. You don't want to bring along a lot of D6 "baggage" forward to D7. And you won't want to be constrained by limits in D6 when working on new functionality for D7.
  • Is there a way to make an entity-based forum general enough where you could select which D7 entity should be used for the topic, and which entity is used for the reply (and select which field points to the parent entity). People who want AF to work with the existing Forum module would select the "node" entity for topics and the "comment" entity for replies. But other people could select their own custom entity for topics and/or replies. AF wouldn't need to care...it just handles them at the entity level. Doing this in a general way is important to allow AF to work with other D7 modules, such as Drupal Commerce where other new entity types exist. (for example, reviews and comments on "product" entities where each product class has it's own discussion forum)
  • I agree that "forums" should be their own entity type instead of just using taxonomy, with a way to handle compatibility/conversion
  • The D7 version of AF should use Views 3. I am wondering at what point we should be writing a new "view style" for displaying forums, etc, so that everything becomes a view. Then we can leverage all of the Views features for theming, caching, etc.
  • Views 3 requires the CTools module. This gives us a huge set of existing functionality that we can leverage. I'm still learning about a lot of this. But specifically CTools provides a plugin API that might be useful for forum "plugins". There is also a lot to learn about "context" with CTools and D7 where sidebar AF blocks can actually know what main forum post/reply is being displayed via context.

I'm still very interested in all of this for my own D7 forums. I've determined that a lot of the "improved user experience" stuff that I want can probably be better implemented as their own modules that hook into AF and use jQuery UI features for handling the front end.

As you say, there is still a lot of reading and research to be done. Remember that you have many interested people who are willing to help with this.

Don't try to do the D7 entity

michelle's picture

Don't try to do the D7 entity stuff in Advanced Forum 2.x.

I wasn't planning on it. There is some work I want to do in 2.x that will lay the foundation for the change and also make the module better in general, but the actual switch to entities will be in 3.x.

Is there a way to make an entity-based forum general enough where you could select which D7 entity should be used for the topic, and which entity is used for the reply (and select which field points to the parent entity).

Now that is something I hadn't even thought of. When I was thinking pluggable, I was thinking the whole back-end would be switched out. But your idea may work better. I won't know for sure until I can dig into this more.

The D7 version of AF should use Views 3.

Since there isn't a Views 2 for D7, that's kind of a no brainer. ;)

I am wondering at what point we should be writing a new "view style" for displaying forums, etc, so that everything becomes a view.

Everything except the forum list is already a view. Making the forum list a view was impossible in Views 2 because of the lack of grouping. It may be possible in Views 3 but I suspect the level of manipulation on that page will make using a view for it at least impractical if not impossible.

Views 3 requires the CTools module.

So does Advanced Forum, even in D6, and it will continue to do so.

But specifically CTools provides a plugin API that might be useful for forum "plugins".

AF has had forum plug-ins for a couple years. I don't know if troky ported them to D7, yet.

There is also a lot to learn about "context" with CTools and D7 where sidebar AF blocks can actually know what main forum post/reply is being displayed via context.

Yep, I'm quite familiar with context. I've been working with what became CTools since Drupal 5. :) I'm far from an expert in it because it sort of took off and went crazy and I didn't keep up but I have a good grasp on the basics anyway.

Michelle

Everything except the forum

mpotter's picture

Everything except the forum list is already a view. Making the forum list a view was impossible in Views 2 because of the lack of grouping.

That's what I meant about writing a new view "style" for the forum list (not just a custom "row style" but an entire "view style"). I've only played with custom view styles a bit, but it seems like it would be possible. Especially if Forums become entities themselves instead of just using taxonomy.

Forgot that AF 2 already required CTools. Since I always have CTools on my sites I just never noticed that dependency. Anyway, it's good that you have already played with CTools. There is some great stuff in there and I've found many developers who are not aware of it or who do not like CTools for whatever reason. Now that every D7 site will probably have CTools (because of Views 3) maybe using CTools will be less of an issue for people.

So the forum plugins in AF already use the CTools plugin API? If so, that's great! Still learning about CTools plugins myself.

.

michelle's picture

I don't think using Views to gather the data for the main forum page makes much sense, though I may change my mind once I have a chance to fully explore Views 3. There is quite a bit of manipulation that goes into aggregating post counts of children and formatting sub containers/forums differently than main ones and maintaining that tree as you dig down into it. I love Views but it's not a good fit for everything and I think this is one of those cases.

The entire style system in AF is dependent on CTools as is the Page Manager integration and various content types. It's an integral part of the module.

Michelle

Documentation on Advanced Forums for Drupal 7

jcchapster's picture

Michelle,

I am not a programmer, but I believe I could be of assistance with documentation.

General documentation, installation issues, caveats, etc.

Or if you made quick notes / drafts, etc, I'd be happy to tidy it all up.

I'd fire up D7 and work thru the installation and help test for documentation needs as well.

You might not want any help, just letting you know it is available.

  • John Chapman

.

michelle's picture

I always welcome help and will keep it in mind when I get to a point I have something to document. :)

Thanks,

Michelle

Other entity modules

michelle's picture

This is a note to do more research to see if there's any benefit to using http://drupal.org/project/entity and http://drupal.org/project/relation as building blocks for this. Feedback welcome if anyone already has experience with those.

Michelle