Page 1 of 1
Sorting News Module Category List
Posted: Sat May 26, 2007 12:07 am
by Anastasis
When you add new categories into the News module, it appends each new item to the end of the list. It would be useful if there was the option to display this list sorted or even better to determine the order, but even a simple sort would be better than now. For the end user adding new news items with a lot of different categories it would speed entry and reduce the likelihood of error by missing a category.
Is this possible or does it require a code change? Maybe it could be worked around by having a script to sort the categories records in the database that could be used every time categories are updated as a sort of housekeeping task?
Re: Sorting News Module Category List
Posted: Sun May 27, 2007 9:07 pm
by Anastasis
Any thoughts on this anyone?
Re: Sorting News Module Category List
Posted: Sun May 27, 2007 9:48 pm
by alby
Anastasis wrote:
When you add new categories into the News module, it appends each new item to the end of the list. It would be useful if there was the option to display this list sorted or even better to determine the order, but even a simple sort would be better than now. For the end user adding new news items with a lot of different categories it would speed entry and reduce the likelihood of error by missing a category.
Is this possible or does it require a code change? Maybe it could be worked around by having a script to sort the categories records in the database that could be used every time categories are updated as a sort of housekeeping task?
Add in call module {news sortby="news_category" browsecat="1"}
From help:
Code: Select all
sortby="news_date" - Field to sort by. Options are: "news_date", "summary", "news_data", "news_category", "news_title". Defaults to "news_date".
browsecat="1" - Shows a browseable category list.
Alby
Re: Sorting News Module Category List
Posted: Sun May 27, 2007 9:59 pm
by Anastasis
Thanks Alby for your reply.
However, doesn't this only affect the output of the website page in the browser. I want to be able to sort the category list in the admin when adding news articles so when a new category gets added it doesn't appear last in the list of categories.
Or have I misunderstood?
Re: Sorting News Module Category List
Posted: Mon May 28, 2007 7:25 am
by alby
Anastasis wrote:
Thanks Alby for your reply.
However, doesn't this only affect the output of the website page in the browser. I want to be able to sort the category list in the admin when adding news articles so when a new category gets added it doesn't appear last in the list of categories.
Or have I misunderstood?
Ok, I have misunderstood in frontend.
Categories are sorting with hierarchy.
If you don't use categories hierarchy (
current svn News or in rc2) in function.admin_categoriestab.php:
Code: Select all
substitute:
$query = "SELECT * FROM ".cms_db_prefix()."module_news_categories ORDER BY hierarchy";
with:
$query = "SELECT * FROM ".cms_db_prefix()."module_news_categories ORDER BY long_name";
Alby
Re: Sorting News Module Category List
Posted: Mon May 28, 2007 10:45 am
by Anastasis
Alby
Thanks again. I cannot find a function.admin_categoriestab.php in my /modules/News folder. There are some action. and method. php files but not this one. Am I looking in the wrong place?
Re: Sorting News Module Category List
Posted: Mon May 28, 2007 11:10 am
by alby
Anastasis wrote:
Thanks again. I cannot find a function.admin_categoriestab.php in my /modules/News folder. There are some action. and method. php files but not this one. Am I looking in the wrong place?
No, it's correct but it's valid for News SVN version or in rc2 version.
Ok, for old

version file:
action.defaultadmin.php
check:
Code: Select all
echo $this->StartTab('categories', $params);
#Put together a list of current categories...
$entryarray = array();
$query = "SELECT * FROM ".cms_db_prefix()."module_news_categories ORDER BY hierarchy";
substitute last row with:
Code: Select all
$query = "SELECT * FROM ".cms_db_prefix()."module_news_categories ORDER BY long_name";
I don't test on this release but must work, I think
Alby
Re: Sorting News Module Category List
Posted: Wed May 30, 2007 11:00 pm
by Anastasis
Alby - thanks again.
Just got round to changing and testing this and it doesn't seem to make any difference. The category list is displayed in the same order in the Categories combo on the Articles tab and likewise on the Categories tab.
EDIT: I tell a lie - well an honest mistake!
The list on the Categories tab is now sorted but not on the Articles tab - which would be the place an Editor selects from - is not. Is there a way to get that to sort the same?
Re: Sorting News Module Category List
Posted: Thu May 31, 2007 10:26 am
by alby
Anastasis wrote:
Alby - thanks again.
Just got round to changing and testing this and it doesn't seem to make any difference. The category list is displayed in the same order in the Categories combo on the Articles tab and likewise on the Categories tab.
EDIT: I tell a lie - well an honest mistake!
The list on the Categories tab is now sorted but not on the Articles tab - which would be the place an Editor selects from - is not. Is there a way to get that to sort the same?
Ok, for full sort replacement, substitute:
$query = "SELECT * FROM ".cms_db_prefix()."module_news_categories ORDER BY hierarchy";
with:
$query = "SELECT * FROM ".cms_db_prefix()."module_news_categories ORDER BY long_name";
there are:
1 substitute in action.addarticle.php
1 substitute in action.editarticle.php
3 substitute in action.defaultadmin.php
Alby
Re: Sorting News Module Category List
Posted: Thu May 31, 2007 1:03 pm
by Anastasis
alby wrote:
Ok, for full sort replacement, substitute:
$query = "SELECT * FROM ".cms_db_prefix()."module_news_categories ORDER BY hierarchy";
with:
$query = "SELECT * FROM ".cms_db_prefix()."module_news_categories ORDER BY long_name";
there are:
1 substitute in action.addarticle.php
1 substitute in action.editarticle.php
3 substitute in action.defaultadmin.php
Absolutely perfect - thanks Alby. Brilliant!
I cannot understand why the default sort order for this is by hierarchy. It makes no sense either when adding categories or using them when working as an editor. You would always want them to be sorted alphabetically wouldn't you, particularly as the sort respects the parent/child categories as well?
For what reason are they sorted the way they are by default?
Re: Sorting News Module Category List
Posted: Thu May 31, 2007 2:22 pm
by alby
Anastasis wrote:
alby wrote:
Ok, for full sort replacement, substitute:
$query = "SELECT * FROM ".cms_db_prefix()."module_news_categories ORDER BY hierarchy";
with:
$query = "SELECT * FROM ".cms_db_prefix()."module_news_categories ORDER BY long_name";
there are:
1 substitute in action.addarticle.php
1 substitute in action.editarticle.php
3 substitute in action.defaultadmin.php
Absolutely perfect - thanks Alby. Brilliant!
I cannot understand why the default sort order for this is by hierarchy. It makes no sense either when adding categories or using them when working as an editor. You would always want them to be sorted alphabetically wouldn't you, particularly as the sort respects the parent/child categories as well?
For what reason are they sorted the way they are by default?
Categories are building with hierarchy in mind (type structure of site page) and view reflects this way too.
In News I don't use category hierarchy but, in general, is better. I think
Alby