I've searched a simple dynamic method to sort taxonomy pages on 'created by'.
I public my solution here for others;
edit modules/taxonomy.module and add the following lines
at the beginning of the function taxonomy_page() write
$taxonomy->order = arg(4);
and at the beginning of the function taxonomy_select_nodes($taxonomy, $pager = 1) write
$order = "DESC";
if ($taxonomy->order == "ASC" {
$order = "ASC";
}now replace the SQL Strings in this function. You must replace the $sql = ...ORDER BY static DESC, created DESC"; with ...ORDER BY static DESC, created $order";. There are two sql strings.
After you made these changes, you can change the sort order of a taxonomy page with a link like this;
http://www.yourpage.yourdomain/?q=taxonomy/page/or/28/ASC
or
http://www.yourpage.yourdomain/?q=taxonomy/page/or/28,40,20/ASC
Comments
re: Sort order for taxonomy pages
Punchy,
This looks very usefull indeed. I think that if you made a patch out of it and placed it in drupal's issue tracker, it would make a fair chance of getting in drupal (propably not 4.5 though).
Some small questions: does this also work for the 'and'? your examples only show 'or'.
Do the feeds follow these sort orders too?
[Ber | Drupal Services webschuur.com]
does this also work for the 'and'
I've tested it with the 'and' and it works for this also.
http://www.mypage.ch/?q=taxonomy/page/and/22,28/ASCWhat you mean exactly with the 'feeds'?
And nedjo; thanks for opening the issue.
Relevant issue created
Thanks for the tips. I've created an issue at http://drupal.org/node/10839 about node sort order in taxonomy display.
theme based solution
Hi all,
i think i have solution for this issue and u need not to patch taxonomy module. I did it with overriding the theme_taxonomy_term_page() fucntion.
1) So in my template.php file, i created my own phptemplate_taxonomy_term_page() based on that one from core module.
2) i changed the bottom code $output .= taxonomy_render_nodes($result); to $output .= _modified_taxonomy_render_nodes($result);
3) i created new function _modified_taxonomy_render_nodes() based on the taxonomy_render_nodes(), but i created in it an array (in while cycle) to save node nid and title in that array, so i can then sort the array by a title.
This is my cation:
Hope it ll help u - sorry guys for my english..its terrible, i know :\
Squelle Group, s.r.o. - Drupal web development, consulting and training.
just one thing
I guess I'm looking for same feature. But your solution is not correct for me. Cause $result contains defined number of nodes (by default it is 10) and you parse and order nodes only for current page. So it doesn't work for multi page output of result correctly.
Sorting the node by modified date
I wanted the node to be displayed in the "modified" order. The most recent modificated one on top.
I know it's not "good" to modify core module function but didn't find any other way, since i didn't want to add yet another module.
So i modified the taxonomy_select_nodes function in /modules/taxonomy/taxonomy.module file.
I added a join just before the foreach loop adding the order by:
$query->join('node', 'n', 'n.nid = t.nid');That way i join my "taxonomy_index" table, used by the taxonomy module which only has the created date, with the "node" table. The join being on the node id.
And i changed the parameter that was passed in the function from
't.created' => 'DESC'to'n.changed' => 'DESC'That way i make the order by the "changed" column from the "node table" date instead of "created" column from the "taxonomy_index" table.
So it's a really quick change.
Here the full function after edit:
I have similar problem. Since
I have similar problem. Since I don't want add another module I modified the core module (the taxonomy_select_nodes function in /modules/taxonomy/taxonomy.module file) same as WilliamB.
Is there any other way that is better or more elegant?