I want to change the sort order of ALL nodes to alphabetical (i.e. by title). Doing anything with teh taxonomy_select_nodes doesn't make sense since that is limited to taxonomy. I want the order to be alphabetical throughout the site. Can't find appropriate function to do that?

I want o make the changes in the template.php file itself so that I need not hack into the core. Is this possible?

Comments

dan33’s picture

I was thinking hook_db_rewrite_sql, but it appears it's limited to join, where, and distinct. I'd be kind of curious as to the answer of this as well.

subir_ghosh’s picture

Yeah. And it doesn't make sense to create 50,000 Views if a single line (or maybe 10 lines) in template.php can do the needful.

-----------------------------
Subir Ghosh
www.subirghosh.in

subir_ghosh’s picture

I tried to introduce this in the template

function node_page_default() {
    $result = pager_query(db_rewrite_sql('SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.title DESC'), variable_get('default_nodes_main', 10));
}

Gives error:

Cannot redeclare node_page_default() (previously declared in /home/twatch/public_html/modules/node/node.module:2374) in /home/twatch/public_html/themes/tourismwatch/template.php on line 143

-----------------------------
Subir Ghosh
www.subirghosh.in

subir_ghosh’s picture

I got tired of trying to tinker around with template.php. So I changed line 2374 of node.module to

$result = pager_query(db_rewrite_sql('SELECT n.nid, n.sticky, n.title FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.title ASC'), variable_get('default_nodes_main', 10));

Of course, it works.

I would have liked to do the same in template.php.

-----------------------------
Subir Ghosh
www.subirghosh.in