You are here

function _classified_page_term in Classified Ads 6.3

Same name and namespace in other branches
  1. 7.3 classified.module \_classified_page_term()

Page callback for classified/<tid>.

Unlike the standard taxonomy term page, this one only accepts one term from the module vocabulary, and builds a breadcrumb trail based on the tree assumption for that vocabulary. It does NOT honor the sticky flag, the expiration date taking priority over it.

Parameters

object $term: A fully loaded term used as a Classified Ads category to list.

Return value

string The ads listing.

See also

classified_term_load()

1 string reference to '_classified_page_term'
classified_menu in ./classified.module
Implements hook_menu().

File

./classified.module, line 537
A pure D6 classified ads module inspired by the ed_classified module.

Code

function _classified_page_term($term) {
  $bc = _classified_get_breadcrumb_by_term($term, FALSE);
  drupal_set_breadcrumb($bc);
  unset($bc);
  $ret = '';
  $children = taxonomy_get_children($term->tid);
  $children_list = array();
  foreach ($children as $child_tid => $child_term) {
    $count = taxonomy_term_count_nodes($child_term->tid, 'classified');
    $children_list[] = t('!link (@count)', array(
      '!link' => l($child_term->name, taxonomy_term_path($child_term)),
      '@count' => $count,
    ));
  }
  unset($child_tid, $child_term, $children, $count);
  if (!empty($children_list)) {
    $ret = t('<p>Sub-categories: !cats<p>', array(
      '!cats' => implode(' ', $children_list),
    ));
  }
  $sq = <<<EOT
    SELECT n.nid, n.title, n.status,
      nr.body, nr.format,
      cn.expires
    FROM {node} n
      INNER JOIN {node_revisions} nr ON n.nid = nr.nid AND n.vid = nr.vid
      LEFT JOIN {classified_node} cn ON n.nid = cn.nid AND n.vid = cn.vid
      INNER JOIN {term_node} tn ON n.vid = tn.vid
    WHERE
      n.type = 'classified' AND tn.tid = %d AND n.status != 0
    ORDER BY
      cn.expires ASC, n.changed ASC, n.created ASC
EOT;

  // Work around limitations in pager_query regexp
  $sq = trim(str_replace("\n", ' ', $sq));
  $sq = db_rewrite_sql($sq);
  $q = pager_query($sq, 10, 0, NULL, $term->tid);
  $ret .= _classified_list_nodes($q);
  $ret .= theme_pager();
  return $ret;
}