Ning Developer Network

Fight With Tools

Exporting ALL Forum Topics and Replies

I have set up some php pages on our webdav site access that will export our network's forum topics, but would like help getting the rest of the content in our forum so we can easily look at data, contents etc and do some analysis.

I would like to know...
1. Does anyone have an example get command that will export forum replies / comments?
I'm assuming I can just export these in a similar way to the topics, most recent 100 comments etc, but don't know the syntax.

2. Has anyone been able to export all data from their forum (both forum topic and replies) and successfully thread all the pieces back together so comments are associated with their parent topics in some kind of handy file (csv, xls etc)?
If so, would you share how you did this?

Thanks for any and all help ~

Tags: comments, export, forum, php, replies, topics

Replies to This Discussion

I Do Not Know Of Anyone Who Has Been Able To Do This I Remember A Post In The Past About Someone Wanting To Do This But Couldn't Acomplish It
1) There is no strait forward command that I was able to find, however you can get the information using a few queries.
a) Obtain ID's for your Categories
b) Obtain Topics from Categories in a
c) Obtain Comments from Topics in b
d) obtain list of users

Using those, you can rebuild the entire forum structure. The trick that no-one seems to mention is how to piece together the reply of a reply

2) I was able to do this using the queries listed above.

Here are some examples;

//Get Your Categories
$query = XN_Query::create('Content');
$query->filter('owner');
$query->filter('type','eic','Category');
$query->order('createdDate','asc');
$categorys = $query->execute();

//for each category, get the topics
$query = XN_Query::create('Content');
$query->filter('owner');
$query->filter('type','eic','Topic');
$query->filter('my->categoryId','eic',$category->id);
$topics = $query->execute(); //all topics for given category

//get the comments assosciated with this topic
$query = XN_Query::create('Content');
$query->filter('owner');
$query->filter('type','eic','Comment');
$query->filter('my->attachedToType','eic','Topic');
$query->filter('my->attachedTo','eic',$topic->id);
$query->order('my->xg_forum_commentTimestampsForAscSort','asc');
$comments = $query->execute();

then you get to piece it all back together, important to note is 'thread of a thread' is done using $comment->my->xg_forum_commentTimestampsForAscSort , this value holds each time stamp so you can build the association back. If it is a reply to the Topic, it has a single timestamp entry, if it is a reply to another reply, it will contain First the Timestamp of the reply it's replying too, and then it will contain the timestamp when this reply was written, this continues for 3 deep, 4 deep, etc. It is rather complicated but hopefully this might be of some help to you.

The whole code to export all categories, with all topics, and all replies (including sub-threading) as a single HTML page is rather long and I have not worked on making it efficient or error handled yet.

RSS

We're Hiring

We are looking for talented and passionate individuals to join our growing team.

Visit our engineering jobs and see if Ning is right for you.

© 2008   Created by Ning Developer Admin

Badges  |  Report an Issue  |  Privacy  |  Terms of Service