Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
TXP Forum? -- Small plugin w/ possible solution [needs work]
This thread has been replaced by the TXPhorum thread here.
Thanks,
- Ben
DISCLAIMER: I’m posting this because I keep seeing people asking about integrating forum software. The information below is given with the knowledge that you will have to muddy through it, that I don’t even know the reasons why I did certain things anymore, that it was never tested thoroughly, that there might be serious security issues and that it is rough and needs polishing.
Finally, ask the folks using Email-on-Post and Newsletter Manager how much time I am spending on updates … None, recently. This is not something I’m “maintaining” though if I can help out of course I will.
The idea is that the information presented be used as “seed” information for the community to develop a plugin/method/set of instructions on how to use TXP to power a forum on your site (in addition to its regular duties). If you work something out using the information and plugin below, please post to this thread and share your success. We can update this document as new ideas or fixes are found.
<hr>
This article describes how to use Textpattern and a Textpattern Section to power a forum.
If your needs aren’t too complicated — and you are willing to roll up your sleeves and dig in — I don’t think there’s any reason you can’t have a functional forum that isn’t integrated into your site but is a part of your site, using only Textpattern and some well-known plugins (plus a few special tags I created). Design it and style it however you like, and TXP will handle the rest.
<br><Br>TEST FORUM
<br><br>BEGINNING
Following the advice of this excellent article on using Textpattern as an e-commerce tool, we redefine the taxonomy of Textpattern. From here on out, an “article” is equal to a “topic.” A “comment” is equal to a “reply.” That’s the basics of how this works.
<br><br>FIRST STEPS
- Install the plugin bab_forum. This creates two new tags: bab_forum_form (a “Post From the Live Site” form, which accepts a form attribute so you can set it up however you like), and bab_forum_comments_form (a special comments tag).
- Copy one of your site’s basic Page’s to a new Page and call it “forum.”
- Create a new Section called “forum”; set it to call Page “forum.”
- Create a new article category called “forum”
- Comments have to be set correctly: this faq is helpful here. What I’ve done is duplicated the comments and comments_form forms, and made slight changes to each. Also, you have to set your preference to “Don’t automatically append comments” and then follow the directions in the faq to make sure your comments are still appended where they are supposed to be. However, once you’ve done this, your forum replies and your regular site comments can be treated differently.
<br><br>CREATE YOUR INDEX AND SINGLE TOPICS TEMPLATE
In the new Page called “forum,” replace the content with something like the following:
<code>
<txp:if_individual_article>
<txp:article form=“forum_form_1” />
<txp:else />
Forum Index
<div style=“border:groove;border-width:thin;margin-bottom:5px;”>
<table><tr>
<td width=“200”><P><b>Topic</b></P></td><td width=“80”><P><b>Replies</b></P></td><td width=“255”><P><b>Posted By</b></P></td>
</tr></table>
</div>
<txp:article_custom category=“forum” form=“forum_form_2” /><br />
<txp:ign_if_logged_in>
<txp:ign_logged_user /> [click to logout]<div id=“post_new_box”><txp:bab_forum_form /></div></div>
<txp:else />
<div id=“login_box”><txp:ign_show_login login_msg=“The ability to post new topics or reply to topics in the forum is restricted to registered users, please log in or register below. “ /></div><P>Or register a new account:</p><txp:mem_self_register_form wraptag=“div id=register_box” isize=“20” label=“Register” namewarn=“Name is required” userwarn=“Username is required” emailwarn=“Email address is required” form“self_register_form” />
</txp:ign_if_logged_in>
</txp:if_individual_article>
</code>
<br><br>LET’S BREAK IT DOWN
The following code represents a single topic page. The code says, if we are on a single article page, display a link back to the forum index, and display the article using the form “forum_form_1”.
<code>
<txp:if_individual_article>
<txp:article form=“forum_form_1” />
<txp:else />
</code>
<br><br>The following code creates the Forum Index page. The code says, if it’s NOT a single article page, display ALL articles in the category “forum”, with the form “forum_form_2”.
<code>
<txp:else />
Forum Index
<div style=“border:groove;border-width:thin;margin-bottom:5px;”>
<table><tr>
<td width=“200”><P><b>Topic</b></P></td><td width=“80”><P><b>Replies</b></P></td><td width=“255”><P><b>Posted By</b></P></td>
</tr></table>
</div>
<txp:article_custom category=“forum” form=“forum_form_2” /><br />
</code>
<br><br>The following code says, if the user is logged in — using ign_password_protect plugin — then display the “Post New Topic” form (using the bab_forum_form tag) and some more information available through ign_password_protect (including “number of users currently logged in — very much like PunBB :).
<code>
<txp:ign_if_logged_in>
<txp:ign_logged_user /> [click to logout]<div id=“post_new_box”><txp:bab_forum_form /></div></div>
<txp:else />
</code>
<br><br>The following code says if the user is NOT logged in (through ign_password_protect), then do NOT display the “Post New Topic” form. Instead, display the ign_password_protect default message and sign-in form, and a register box (using mem_self_register, set to use the ign_password_protect database table).
<code>
<txp:else />
<div id=“login_box”><txp:ign_show_login login_msg=“The ability to post new topics or reply to topics in the forum is restricted to registered users, please log in or register below. “ /></div><P>Or register a new account:</p><txp:mem_self_register_form wraptag=“div id=register_box” isize=“20” label=“Register” namewarn=“Name is required” userwarn=“Username is required” emailwarn=“Email address is required” form“self_register_form” />
</txp:ign_if_logged_in>
</txp:if_individual_article>
</code>
<br><br>Elsewhere on the page I’ve got the following, which displays the names of all users currently online, plus a link to logout (if logged in), plus a change your password field:
<code>
<div id=“sidebar-1” style=“margin-top:40px” ><p><txp:ign_usr_online>Users Online:</txp:ign_usr_online></p><P style=“padding-top:20px” >Account<br />Management:</p><P><txp:ign_logged_user /></p><p><txp:ign_self_edit /></p>
</div>
</code>
<br><br>RECAP
So, to recap, the Page template “forum” will be called when someone comes to Section “forum.” If they are just on the section page, they will get a list of all articles with category “forum” (all articles Posted with the bab_forum_form tag will have this category) displayed by a special form that breaks up the parts into a table, with column headers Name, Title, Date, etc. If your user clicks on the title and goes to the single article page, then a link back to the forum index is followed by the “post” and any replies made to that post. At the bottom of each post page is a “Reply to this topic” form.
<br><br>DISCUSSION IDEAS
- Obviously, this is pretty basic — but just as obviously, you may style it pretty much any way you like. The examples I have given are only examples (comment forms and the like) — and since you can style comment forms and article forms, you can just make this look however you like. Honestly, with some effort, there’s no reason you can’ make the bones of this forum look and feel just like any other forum software. Except if you put in the effort, it will come out exactly the way you want it to look, within the parameters of the site you are working on — if you want a forum without using tables, just make it.
- What are the security issues raised by posting articles from the live site? The code is essentially the same as on the article page, so it doesn’t necessarily seem like there would be too many, but I don’t know. Is wrapping the post form with ign_password_protect enough?
- I think you could just create different sections for different “boards” — I haven’t really thought this through but I’m pretty sure that’s doable.
- No editing? I think the bab_forum plugin could be tweaked very easily tp allow for editing the articles, but what about comments? Or maybe there’s a plugin already?
- I couldn’t get the search one section only to work — I got errors. But once that’s been worked out, you can use TXP’s built-in search function to search the forum.
- Because it’s just regular TXP, you can use other plugins to fill out capabilities; for example, for author information (for a user profile, maybe) you can use Rob Sable’s rss_author_info plugin … or to creater only an author mailto: link, Rob Sable’s rss_author_email plugin.
- We’d need a sort of forumfaq for users — how to change your password using mem_self_edit, etc.
- More plugins could be developed to add capabilities that more complex forums have now, like instant messaging or something.
- The bab_forum_form tag doesn’t actually HAVE to be used this way. It’s basically a mechanism for posting to your database from the live site instead of the admin site, and with that in mind there might be other uses I haven’t thought of (here’s one I did think of, though — Classified Ads). Again, for better capabilities, you’ll have to tweak the code.
- Added benefits — your posts are included in TXP search, if you like. Using ign_password_protect database keeps your forum users separate from your admins. More, but I have to stop thinking right now.
- If you have a popular forum, you are going to be overrun with articles Posted by users. Perhaps a special txp DB table would be better? The reason it’s currently so “simple” is that TXP is handling all the replies and everything. A special DB table would require syncing that up; I don’t know how complicated that would be off the top of my head. Or maybe there’s a way to have two TXP installations running on one site? Have a second installation running and pull that info into a frame or something?
- Moderating. Replies are comments which you can moderate. I couldn’t find a plugin to moderate articles but I’m sure there is/could be one. New Topics are articles, and these will show up in your article list, so you can manually “moderate” these from within your admin, but just something to keep in mind.
<br><br>OTHER PLUGINS REQUIRED
<b>ign_password_protect</b>
<blockquote>
I made some changes to ign_password_protect and mem_self_register having to do with the “refresh” issue above, and another issue which was they were taking me away from the forum page (redirecting me to the front page or something)—but I don’t know exactly what those changes were. Parts of those plugins where it redirects you is probably the place to start if you run into trouble there.
I cheated to make the test forum work — I found the tweaked ign_password_protect file. However, I couldn’t figure out where the differences were, and I can’t be sure they won’t effect current usage, so …
</blockquote>
<b>mem_self_register</b>
<blockquote>
Because mem_self_register sends you to the front page upon submit, you have to place the mem_self_register tag on the front page in order for it to send the confirmation email and add the user to the db. I set it to form=“empty” and then created form “empty” and put just an empty space in it. That seemed to do the trick.
</blockquote>
<br><br>KNOWN ISSUES
- When you first login, the page doesn’t refresh so it doesn’t show immediately — you have to click on a link and come back to the index before it shows the post new topic form. This is a problem with the code which I can’t figure out; it might have to do with ign_password_protect though so perhaps someone knowledgeable there could help.
- New users names are not always showing up in my mock-up … There are issues in two places. On the index, the name will appear by their FIRST post, but when they make a second post, their name will appear THERE but disappear on the first one. It repeats with each additional post. I’ve tried to fix it but I can’t figure it out. On the topic page, their name won’t appear. But both of these issues are NOT happening with user “Ben” so I know this one can be resolved.
<br><br>FORMS USED (WITH EXAMPLES)
<b>forum_form_1</b>
<code>
<a href=”/index.php?s=forum”>Forum Index</a> ›<span class=“regular_font”><b><txp:title /></b></span>
<div id=“topic_box”>
<div style=“background: yellow”><small>Posted: <txp:posted /></small></div>
<div>
<table><tr><td width=“100” valign=“top” ><P><txp:author /></p>
</td><td width=“380” valign=“top” ><P style=“margin-left:5px” ><txp:body /></p></td></tr></table>
</div>
<txp:comments_invite wraptag=“p” />
<txp:if_comments>
<txp:comments form=“forum_comments” />
</txp:if_comments>
<div id=“reply_box”>
<txp:if_comments_allowed>
<p><txp:comments_form form=“forum_comment_form” /></p>
<txp:else />
<p><txp:text item=“comments_closed” /></p>
</txp:if_comments_allowed>
</div>
</div>
</code>
<br><br><b>forum_form_2</b>
<code>
<table style=“border:groove;border-width:thin;margin-bottom:5px;” >
<tr>
<td width=“200”><span class=“small_font”><P><txp:permlink><txp:title /></txp:permlink></p></span></td><td width=“80”><p><span class=“small_font”><center><txp:comments_count /></center></span></p></td><td width=“255”><P><span class=“small_font”><b><txp:author /></b> · <txp:posted /></span></p></td>
</tr>
</table>
</code>
<br><br><b>forum_comments</b>
<code>
<div style=“background: yellow”><small>Posted: <txp:comment_time /></small></div>
<div>
<table><tr><td width=“100” valign=“top” ><P><b><txp:comment_name /></b></p>
</td><td width=“380” valign=“top” ><txp:message /></td></tr></table>
</div>
</code>
<br><br><b>forum_comment_form</b>
<code>
<txp:comments_error /> <txp:ign_if_logged_in>
<h3>Reply to this Topic:</h3>
<P>
<table cellpadding=“4” cellspacing=“0” border=“0”>
<tr> <td valign=“top” align=“right”> <label for=“message”><txp:text item=“Reply” /></label> </td> <td valign=“top” colspan=“2”> <txp:comment_message_input /> </td>
</tr>
<tr> <td align=“right” valign=“top”> </td> <td valign=“top” align=“left”>
<txp:comments_help /> </td> <td align=“right” valign=“top”>
<txp:bab_forum_comments />
<txp:comment_preview />
<txp:comment_submit /> </td>
</tr> </table>
</p>
<txp:else /><txp:ign_show_login /></txp:ign_if_logged_in>
</code>
<br><br>Hope someone can take all this raw material and work up a really great working model, and then we won’t need to talk about integration! Once folks install TXP, if they want a forum they can just follow the simple directions we are going to distill from experience, and voila, done.
Last edited by benbruce (2007-01-23 00:45:14)
Offline
Re: TXP Forum? -- Small plugin w/ possible solution [needs work]
Ben,
This is a great concept! I have this slight deja vu feeling that I’ve seen something attempted elsewhere with an earlier release of TXP, but I didn’t bookmark it…
I plan to test this out very soon, and will certainly post back here, but I have one question for you: How big a forum do you reckon this can handle?
I have a real life application in mind, but my guess is that we could be looking at 600+ posts/comments (combine) per year. Will TXP cope with that do you think?
Cheers
Offline
#3 2006-06-12 10:58:13
- stdmedia
- Member
- From: Canada
- Registered: 2006-01-05
- Posts: 51
Re: TXP Forum? -- Small plugin w/ possible solution [needs work]
Wow, this is crazy neat. I’m just going to sit back and watch untill this is a little more “varified”, nice work indeed though.
Offline
Re: TXP Forum? -- Small plugin w/ possible solution [needs work]
NeilA,
I found this in the faq — it suggests that there is no limit to how many articles TXP can handle. So in that sense there’s absolutely no reason this implementation wouldn’t be able to handle the forum you’re describing. The only other thing that comes to mind is that these posts are all going to appear in your article list so … that doesn’t seem like an issue to me but it could be for some.
Offline
Re: TXP Forum? -- Small plugin w/ possible solution [needs work]
Thanks Ben… I got a quick test version up and running last night.
I don’t think it’s suitable for the immediate project I have in mind, but there is something else coming up where it could worl very nicely.
My big struggle will be styling it properly (you’re speaking to a heavy user of TXP templates here!)
But thanks for your work, because I think it will be an excellent base for others of us to build on.
Cheers
Offline
Re: TXP Forum? -- Small plugin w/ possible solution [needs work]
NeilA,
I hear you about the templates. I think the ideal situation would be to have someone who can design, designs a default template for the forum … then you can simply set up the default and go. And for those who want to fix it up, that’s entirely possible.
Would you mind posting a link to your test forum? Just to see how it came out?
Also, did you run into any issues with ign_password_protect or mem_self_register as I described? Maybe I just missed something when setting those up …
Thanks,
– BenOffline
Re: TXP Forum? -- Small plugin w/ possible solution [needs work]
Hi Ben,
Yep, the template idea is a good one…
I would post a link, but in my fiddling around, I broke something, so will fix and then post. ;-)
Cheers
Offline
Re: TXP Forum? -- Small plugin w/ possible solution [needs work]
Such impressive work! Looking forward to trying it out when an upcoming project needs that kind of solution!
Cool work! Thumbs up!
Offline
Re: TXP Forum? -- Small plugin w/ possible solution [needs work]
I need to go back through the article posted above and edit it to reflect new changes, but the Test Forum is coming along pretty nicely (you’ll see rough edges, but it’s pretty much all there).
Editing is the last sort of “fundamental” function that remains (according to me) — I’ve managed to add an “Edit” link that will only appear if you are the author, and adds an edit form. This needs some testing but the initial tries worked ok. Notice that this is only for the original post, not the replies. I don’t think working out the same thing for the replies should be too hard.
I’ve started calling it TXPHORUM, but other ideas are welcome.
– BenLast edited by benbruce (2006-06-22 00:15:43)
Offline
Re: TXP Forum? -- Small plugin w/ possible solution [needs work]
Nice work Ben!
I really need to get back into my version (and perhaps steal your CSS!), but I may not have a chance for a couple of weeks.
But thanks for pushing this on, I think it’s a winner.
Cheers
Offline
Re: TXP Forum? -- Small plugin w/ possible solution [needs work]
I’m very much impressed, and very much convinced txp rocks!
~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~
Offline
#12 2006-10-30 20:48:45
- Wolfman
- New Member
- Registered: 2006-10-10
- Posts: 2
Re: TXP Forum? -- Small plugin w/ possible solution [needs work]
Hi,
I’m very interested in using this plugin. I looked at your sample forum, and I was wondering if there is a way to setup subforums? One thought I had was to have a different section for each forum I want and then use a section list as a menu. Is there a better way?
Here’s kinda what I’m after:
________________________________
- subforum1
- subforum2
- subforum3
________________________________
Thank you also for working on this plugin.
Wolfman
Offline