• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 579
  • Last Modified:

Treat phpbb topics as drupal nodes

I have a phpbb forum which I use as the main publishing platform of my website; my site is configured so that only the posts from one of the sub-forums are shown as news item in the home page.

Essentially, I have a mysql query that I use to retrieve the posts to display in the home page, sorted by creation date.

Is there a way to "feed" this into Drupal, that is, to make a node out of them?

I am new to Drupal, but I'm an experienced software developer - do not hesitate to suggest learning how to write my own Drupal module.
0
Emanuele_Ciriachi
Asked:
Emanuele_Ciriachi
  • 4
  • 2
2 Solutions
 
oliverpoldenCommented:
If your forum could produce a feed of the posts you want to create nodes for then you could use the aggregation module to import them:

http://drupal.org/project/aggregation

Alternatively, yes you could use your query together with a custom module.  I would do something like check the post id to see if you need to create a new node, and check an md5 of the post text and title to see if you need to update a node.

Essentially:

Run your query
Foreach item, see if a corresponding node exists  (you may want to create your own table consisting of post id, nid, md5 of title and text)
If it exists, check if you should create a new node, or update a node
Build a node object and save it

There are great tutorials on creating modules and you'll probably find it pretty easy to make your own.  Just bear in mind that Drupal is a framework not just a CMS so there's lots it can do for you rather than you having to write your own code, just have a google around.

http://api.drupal.org/api/drupal/modules--node--node.module/function/node_save/6
http://drupal.org/developing/modules
0
 
Emanuele_CiriachiAuthor Commented:
Thank you, this is the kind of answer I was looking for.

One last question before releasing the points: from your answer it seems to be implicit that a node is stored on the database separately from the forum thread record.

I find this to be redundant and unnecessary; can't I write a module that treats the records returned from my query as nodes without having to store them twice somewhere else in a different format?
0
 
oliverpoldenCommented:
Yes it probably is redundant and unnecessary. In that case, you probably don't want to create nodes.  Perhaps you just want to create a module that provides a block for you.

Are you doing this in Drupal 6 or 7?  The reason I ask is that version 3 of the Views module can query an external data source.  In fact having a look at the module page there is also a version 3 for Drupal 6.

http://drupal.org/project/views

Views is a very powerful module, it allows you to create queries and have them displayed as pages or blocks.  Well worth looking at and you may find it useful for other parts of your site too.

If you want to go the custom module and block route here are a couple of links:
http://drupal.org/node/965684
http://www.coderintherye.com/creating-a-new-custom-module-in-drupal-6

In my words:

Create your module folder e.g. latestposts
Create the relevant files:
latestposts.info (enter all relevant info, see creating a module)
latestposts.module (the main code for your module)
latestposts.install (optional but this is where you would create a table)

In latestposts.module you'll need a hook_block() e.g. latestposts_block()
Fill out 'list' and 'view' as in http://drupal.org/node/965684

Under 'view' you can do something like:
$blocks['content'] = latestposts_getposts();

Then you can do whatever you want in latestposts_getposts(), i.e. run your query and generate the contents of the block.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Emanuele_CiriachiAuthor Commented:
Drupal 7 - just started looking into it.

"Views is a very powerful module, it allows you to create queries and have them displayed as pages or blocks.  Well worth looking at and you may find it useful for other parts of your site too."

This looks _exactly_ what I need, thanks.
Is there anything else you have to add after learning my Drupal version?
0
 
oliverpoldenCommented:
No, the only thing is that a lot of modules aren't at full release state for Drupal 7, and there are some that simply aren't available yet.  They probably will be within a few months though. Just ensure that any examples or tutorials are aimed at the version you're using.  There are huge changes between Drupal 6 and 7.
0
 
oliverpoldenCommented:
Oh, and maybe worth mentioning the obvious, there will be a lot more tutorials etc for Drupal 6
0
 
Observer_123Commented:
See this one:
http://drupal.org/project/phpbbforum

also if you just want co run query, inatap php code module - to be possible to run php code as drupal page source, make a custom drupal block to fetch nodes and to display them.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now