avatar Guy C. Dev Jul 12. 2009. 7:37 am
Does anyone have a suggestion to add the ability to sort discussions alphabetically (by title of the discussion)? I have a need to have a discussion setup with the title of the discussions as the name of a person. I'd like to be able to sort the list of discussions using the title field. Thanks...
avatar Guy C. Dev Jul 28. 2009. 2:24 pm
bump
avatar Ilija Studen Staff Jul 29. 2009. 7:51 am
Hi Guy,

For this to work, you'll need to hack discussions manager class. You can find this class in models folder of discussions module. Please note that changes to this class will affect all projects.
avatar Guy C. Dev Jul 30. 2009. 12:57 pm
Thx Ilija - got it to work! I created an ascending sort for discussions grouped by category, and left the existing date sort for "all discussions". I sorted by "name" (the discussion subject / title).

Edit the file:
activecollab/application/modules/discussions/models/discussions/Discussions.class.php
At the bottom of the file, alter the function paginateByCategory, changing 'order' => 'boolean_field_1, datetime_field_1 DESC', to 'order' => 'name ASC',

The (single line of ) code change is as follows:

Was:

function paginateByCategory($category, $page = 1, $per_page = 30, $min_state = STATE_VISIBLE, $min_visibility = VISIBILITY_NORMAL) {
return ProjectObjects::paginate(array(
'conditions' => array('parent_id = ? AND type = ? AND state >= ? AND visibility >= ?', $category->getId(), 'Discussion', $min_state, $min_v$
'order' => 'boolean_field_1, datetime_field_1 DESC',
), $page, $per_page);
} // paginateByCategory

} // Discussions

Change to:

function paginateByCategory($category, $page = 1, $per_page = 30, $min_state = STATE_VISIBLE, $min_visibility = VISIBILITY_NORMAL) {
return ProjectObjects::paginate(array(
'conditions' => array('parent_id = ? AND type = ? AND state >= ? AND visibility >= ?', $category->getId(), 'Discussion', $min_state, $min_v$
'order' => 'name ASC',
), $page, $per_page);
} // paginateByCategory

} // Discussions

------------------------------------
This allows you to sort only the discussions that have been categorized and quickly find the one your looking for, since categorized discussions are sorted by the name (title) of the discussion.

A nice improvement would be to simply go the the Discussions page in a project, then click on the word "Discussion", and have the Discussion list sort by discussion name, then click on "Last Reply", and have the list re-sort by date. Just a suggestion for a future release.