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:
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:
$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?

Comments

michelle’s picture

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

andrewsuth’s picture

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.

michelle’s picture

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

andrewsuth’s picture

In the end I wrote snippet of PHP to do the job and put it into template.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;
}
michelle’s picture

Cool, glad you found a solution. :)

Michelle

Status: Fixed » Closed (fixed)

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