SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How expensive is curl? ....embedding a forum in a CMS

    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?

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    To be clear, is the forum hosted on the same machine as the CMS?

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes. Forum and CMS both on the same virtual dedicated CentOS, or any other such LAMP setup

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    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.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    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.

  6. #6
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  7. #7
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Am I right in supposing the existing target forum is archived?

    In which case all you want to do is grab the stream of html, extract the necessary text and then cache that as text files?

    Is that your scenario?

    Or, are all these 15k topics "live" and likely to be needed "on the fly" so to speak?

  8. #8
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  9. #9
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    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.

    Maybe someone else has another idea?

  10. #10
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Streams looks interesting. I'm going to have to think about this.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •