Solved

Treat phpbb topics as drupal nodes

Posted on 2011-02-23
7
562 Views
Last Modified: 2012-05-11
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
Comment
Question by:Emanuele_Ciriachi
  • 4
  • 2
7 Comments
 
LVL 9

Assisted Solution

by:oliverpolden
oliverpolden earned 500 total points
ID: 34961954
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
 
LVL 1

Author Comment

by:Emanuele_Ciriachi
ID: 34962014
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
 
LVL 9

Accepted Solution

by:
oliverpolden earned 500 total points
ID: 34962122
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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 1

Author Comment

by:Emanuele_Ciriachi
ID: 34962146
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
 
LVL 9

Expert Comment

by:oliverpolden
ID: 34962173
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
 
LVL 9

Expert Comment

by:oliverpolden
ID: 34962180
Oh, and maybe worth mentioning the obvious, there will be a lot more tutorials etc for Drupal 6
0
 
LVL 1

Expert Comment

by:Observer_123
ID: 35430435
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now