Sorting News Module Category List

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
Anastasis

Sorting News Module Category List

Post 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?
Anastasis

Re: Sorting News Module Category List

Post by Anastasis »

Any thoughts on this anyone?
alby

Re: Sorting News Module Category List

Post 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
Anastasis

Re: Sorting News Module Category List

Post 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?
alby

Re: Sorting News Module Category List

Post 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
Anastasis

Re: Sorting News Module Category List

Post 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?
alby

Re: Sorting News Module Category List

Post 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  ;D 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  8)

Alby
Anastasis

Re: Sorting News Module Category List

Post 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?
Last edited by Anastasis on Wed May 30, 2007 11:11 pm, edited 1 time in total.
alby

Re: Sorting News Module Category List

Post 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
Anastasis

Re: Sorting News Module Category List

Post 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?
alby

Re: Sorting News Module Category List

Post 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  :D

Alby
Locked

Return to “CMSMS Core”