You are here

function _discussthis_get_topic in Discuss This! 7

Same name and namespace in other branches
  1. 5 discussthis.module \_discussthis_get_topic()
  2. 6 discussthis.module \_discussthis_get_topic()
  3. 7.2 discussthis.node.inc \_discussthis_get_topic()

Find forum topics attached to node.

Lookup the given nid in the discussthis db table, and return the corresponding forum topic nid, otherwise return the default for this node type

Parameters

$nid The node to be checked for a topic identifier.:

Return value

integer The topic nid or 0 if no topic is found

2 calls to _discussthis_get_topic()
discussthis_form_alter in ./discussthis.module
Implements hook_form_alter().
discussthis_node_view in ./discussthis.node.inc
Implements hook_node_view().

File

./discussthis.node.inc, line 316
File with node discussion display methods.

Code

function _discussthis_get_topic($nid) {
  $sql = 'SELECT topic_nid FROM {discussthis} WHERE nid = %d';
  $topic_nid = db_query('SELECT topic_nid FROM {discussthis} WHERE nid = :nid', array(
    ':nid' => $nid,
  ))
    ->fetchField();
  return $topic_nid ? $topic_nid : 0;
}