I want to embed a forum into my own home rolled CMS (or any other for that matter).
The problem:
Most if not all public domain forums create each page independently, with <html><head …> </head> <body> and </body></html> elements. Removing those elements is never easy in code. You might think you could simply eliminate those elements from what ever templating system is currently in use, but that breaks conditional branching that happens inside the <head> …if($what_ever) header(“Location: boobooday.php”). I argue that kind of conditional branching is too hard coded and coupled. In other words poorly written. Forums should be flexible. But that’s neither here nor there, because they all work that way anyway. All that I’ve seen.
Some forums (Vanilla) suggest using an IFRAME if you want the forum to appear as if it were inside a <div> …forum contents …</div>
But this causes serious SEO problems.
Another take would be to suck the forum page into a local string variable, using CURL, and then to use regular expressions to strip off the unwanted boilerplate elements, so the string could then be output as the contents of a main display division. Or is that a bad direction? Would that be prohibitively expensive? What other techniques am I not thinking of?
If they are on the same server you do not need cURL, which is very expensive. Just merge them together yourself. Or create a view the pulls data from the forum database.
As logic_earch says, you can just access the tables directly yourself.
I once used Vanilla a collaborative tool once for users to contribute and publish a finished document, it was relatively easy, so you should have no great problem extracting the data you want and displaying it in a way that suits you.
I have to say that Vanilla’s login and user management is very transparent and so easy to hack that you might benefit from investigating turning this problem on its head and ask “how can I add a CMS onto Vanilla”. Their forums are very well supported.
ps I was using the old Vanilla and I don’t remember which version this was, and the project I worked on was a proof of concept which never got approval for a variety of reasons.
pps what timing, I have been mulling over a spec for which I was thinking of using Vanilla again.
I used Vanilla as an example. I actually have about 15,000 posts in Phorum. Working with the existing schema, as suggested, is roughly equivalent to writing a new forum. I’ve done that. I had a files based forum I wrote from scratch, that ballooned up to 10,000 posts before I switched to Phorum. There are some bare bones simple open source forums out there, that would be easier to manipulate than Phorum, which works well enough, but exists as several hundred thousand miles of complex code evolution.
Drupal’s forum ends up as a division, <DIV> …forum… </DIV>
It’s a shame they don’t all work that way. I’d think about stealing from Drupal, but their node hierarchy is too abstract for me.
Everything is live. This is a boat building forum. Users frequently use the search button and then ask an new elaboration question to a post that might be five years old. I’ve had this going since 1999.
So your plan with curl was to grab the forum html stream as it would be presented to a browser, and then top and tail that stream and insert it back into your own top and tail.
Even though I have no experience of working with them it sounds like something that streams would possibly do faster/cheaper but I go blank when I think about how you could evoke that – perhaps some CLI PHP call? You would want something to prompt the forum script to query the db and get the data assemble the html stream but not flush it out till it had been top and tailed.