Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Treat phpbb topics as drupal nodes

Posted on 2011-02-23
7
568 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 10

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 10

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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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 10

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 10

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

856 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