[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Treat phpbb topics as drupal nodes

Posted on 2011-02-23
7
Medium Priority
?
578 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
[X]
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
  • 4
  • 2
7 Comments
 
LVL 10

Assisted Solution

by:oliverpolden
oliverpolden earned 2000 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 2000 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
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

649 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