I'm using the Taxonomy_context module to display a term, with its sub-terms, then the nodes below each sub-term. However, I'm perplexed about the order in which the nodes get displayed.

What I want, is to display the nodes ordered by title. What I get, is the nodes ordered by create date.

I thought, easy enough, just hack the module to sort the way I want. Trouble is a can't find where!!!

I thought, here is the place (only place I can find where taxonomy_context outputs nodes:

function taxonomy_context_show_nodes($tid) {
  static $context;
  if (!isset($context)) {
    $context = taxonomy_context_get_context();
  }
  $output = "";
  $sql = "SELECT DISTINCT(n.nid), n.title, n.body, n.type, " .
    "n.created, n.changed, n.uid, n.sticky, u.name FROM {node} n " .
    "LEFT JOIN {term_node} r ON n.nid = r.nid LEFT JOIN {users} u ON n.uid = u.uid " . node_access_join_sql() .
    " WHERE r.tid = %d AND n.status = '1' " . node_access_where_sql() .
    (variable_get("taxonomy_context_use_promote", 1) ? " AND n.promote = '1' " : "") .
    " ORDER BY sticky DESC, n.created DESC";
  $result = db_query($sql, $tid);
  while ($node = db_fetch_object($result)) {
    if(!strpos('<?', $node->body)) {
      $params = array("title" => node_teaser(strip_tags($node->body)));
    }
    if ($node->nid == $context->nid) {
      $params["class"] = "active";
    }
    $link = l($node->title, "node/". $node->nid, $params);
    $output .= "<li class=\"leaf\">" . $link . "</li>";
  }
  return $output;
}

But when I change "ORDER BY sticky DESC, created DESC" to "ORDER BY sticky DESC, n.title DESC" nothing happens. Am I looking in the right place?

I would be really grateful for any light anybody can shed on this as I am stumped.

Comments

jack_of_spades’s picture

I believe what you want is here:

http://drupal.org/node/10839

ñull’s picture

Nothing to do with your question, but I just wanted to know what version of Drupal you are using and the theme you use to display the context information. I use ver sion 4.5 and don't find any example theme I could use.

joel_guesclin’s picture

I'm using the Chameleon theme, and just realised that I should be able to resolve my sort order by the simple expedient of changing the publication date from the default!!

Much better than hacking the taxonomy module!

My dumb.

ñull’s picture

Do you see the Taxonomy description displayed? Somehow I don't manage to see it. You just installed the taxonomy_context module and that was it? Did you do something special?