You are here

function theme_answers_list in Answers 5.2

1 theme call to theme_answers_list()
answers_list in ./answers.module

File

./answers.module, line 269
Enables the creation of question nodes that can be answered by posting answer nodes.

Code

function theme_answers_list($filterunanswered = FALSE) {
  $header[] = array(
    'data' => t('Quests'),
    'field' => 'n.nid',
    'sort' => 'DESC',
  );
  $sql = 'SELECT n.nid, n.vid FROM {node} n WHERE n.type = "answers" ' . tablesort_sql($header);
  $result = pager_query($sql, 30, 0);
  if (!$result) {
    $output = "No quests available.";
  }
  $count1 = 0;
  $count2 = 0;
  while ($qnode = db_fetch_object($result)) {
    $nodedata = node_load($qnode->nid);
    $nodeview = node_view($nodedata, TRUE, FALSE, TRUE);
    $answercount = answers_count_answers($nodedata->nid);
    $odd_or_even1 = $count1 & 1;
    $odd_or_even2 = $count2 & 1;
    if ($filterunanswered) {
      if ($answercount < 1) {
        if ($odd_or_even1 == '0') {
          $output .= "<div class='even'><br>" . $nodeview . "</div>";
        }
        else {
          $output .= "<div class='odd'><br>" . $nodeview . "</div>";
        }
        $count1++;
      }
    }
    else {
      if ($answercount >= 0) {
        if ($odd_or_even2 == '0') {
          $output .= "<div class='even'><br>" . $nodeview . "</div>";
        }
        else {
          $output .= "<div class='odd'><br>" . $nodeview . "</div>";
        }
        $count2++;
      }
    }
  }
  $output = '<div class="quest-list">' . $output . '</div><br /> ';
  $pager = theme('pager', NULL, 30, 0);
  if (!empty($pager)) {
    $output .= $pager;
  }
  return $output;
}