Retrieveing created data for forums and containers?

andrewsuth - July 3, 2009 - 10:46
Project:Advanced Forum
Version:6.x-1.1
Component:Miscellaneous
Category:support request
Priority:minor
Assigned:Unassigned
Status:closed
Description

I am trying to display the date the forums themselves were created as part of the advf-forum-list.tpl.php template.

I can easily retrieve individual post submitted data with the following code:

<?php
print $created;
?>

But I can't figure out how to do the same with the forum or containers.

I believe it will be necessary to load the individual forum node and then retrieve the $created variable. I tried the following but it seems to break the code:

<?php
$node
= load_node($child_id);
?>

Can someone point me in the right direction as to how I can retrieve this data? I am going about it in the right way or have I missed a fundamental step?

#1

Michelle - July 3, 2009 - 13:13
Status:active» fixed

Forums aren't nodes, they're taxonomy terms. As far as I know, there isn't any record of when a term gets created outside of possibly a log entry. That's all I know and this isn't anything to do with Advanced Forum. You might want to try the forums to see if anyone else has an idea.

Michelle

#2

andrewsuth - July 3, 2009 - 15:25

I didn't realise they were taxonomy terms but it makes a lot of sense that it works that way.

You're right, no creation date information is stored for terms. It looks like I will have to create an initial post for each new forum and then use a custom function to retrieve the date from it.

Thanks for your help.

#3

Michelle - July 3, 2009 - 15:44

If you know PHP, you might want to look and see if there's a hook when terms are saved. You could then do a variable_set with the forum (term) id and a timestamp.

Michelle

#4

andrewsuth - July 4, 2009 - 16:44

In the end I wrote snippet of PHP to do the job and put it into template.php:

<?php
function THEMENAME_forum_first($tid) {

 
$sql = "SELECT n.created FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.created > %d ORDER BY created";
 
$sql = db_rewrite_sql($sql);
 
$nid = db_result(db_query_range($sql, $tid, NODE_NEW_LIMIT, 0, 1));

  return
$nid ? $nid : 0;
}
?>

#5

Michelle - July 4, 2009 - 14:14

Cool, glad you found a solution. :)

Michelle

#6

System Message - July 18, 2009 - 16:50
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.