Page 1 of 2
[solved] news categories: sorting options?
Posted: Thu Jan 01, 2009 6:08 pm
by aura
i need to change the order in which categories are displayed on my news index page. currently, the newest category shows up at the bottom of the list, which is a problem seeing as my categories are years(!) and i need to have 2009 displayed at the top

can anyone please tell me how to do this? ideally i'd need to order the categories numerically so the years show up in descending order from the top.
the page in question:
http://www.bdmlr.org.uk/index.php?page=news
many thanks + happy new year!
aura.
Re: news categories: sorting options?
Posted: Thu Jan 01, 2009 6:13 pm
by Nullig
Have you tried adding:
sortasc="false"
to your tag?
Nullig
Re: news categories: sorting options?
Posted: Thu Jan 01, 2009 6:23 pm
by aura
hi nullig - thanks for the quick reply, really appreciate it. i'm not entirely sure where i need to add what you suggest. is it in the browse category template? sorry i'm not very technical.
aura.
Re: news categories: sorting options?
Posted: Thu Jan 01, 2009 6:34 pm
by Nullig
In your page template, where you have the news tag:
{news}
Not knowing what parameters you've already included, I can only show you how to add this param.
{news sortasc="false"}
Also, if you read the News Help, you may find a combo of parameters that will sort the articles as you wish.
Nullig
Re: news categories: sorting options?
Posted: Thu Jan 01, 2009 6:45 pm
by aura
hi nullig, thanks again. in the news page template, i use the following:
Code: Select all
{content dateformat="%b %d, %Y" summarytemplate="BDMLR news"}
the summary template looks like this:
Code: Select all
{if $pagecount > 1}
<p>
{if $pagenumber > 1}
{$firstpage} {$prevpage}
{/if}
{$pagetext} {$pagenumber} {$oftext} {$pagecount}
{if $pagenumber < $pagecount}
{$nextpage} {$lastpage}
{/if}
</p>
{/if}
{foreach from=$items item=entry}
<p>
{if $entry->formatpostdate}
{$entry->formatpostdate}
{/if}
<br />
{$entry->titlelink}
<br />
{if isset($entry->extra)}
<div class="NewsSummaryExtra">
{eval var=$entry->extra}
{* {cms_module module='Uploads' mode='simpleurl' upload_id=$entry->extravalue} *}
</div>
{/if}
{if isset($entry->fields)}
{foreach from=$entry->fields item='field'}
<div class="NewsSummaryField">
{if $field->type == 'file'}
<img src="{$entry->file_location}/{$field->value}"/>
{else}
{$field->name}: {eval var=$field->value}
{/if}
</div>
{/foreach}
{/if}
{/foreach}
i added
to the page but it didn't change the order of the categories, just the order of the articles which was never the problem. i know i'm missing something, but i just don't know where to look nor what file to edit. i've had a look at the help files and on the forum before posting, but again just not sure where/how to make the changes.
aura.
Re: news categories: sorting options?
Posted: Thu Jan 01, 2009 7:15 pm
by Dr.CSS
If this is your news call I'm surprised it even shows...
{content dateformat="%b %d, %Y" summarytemplate="BDMLR news"}
It should be...
{news dateformat="%b %d, %Y" summarytemplate="BDMLR"}
But that will only show your news in a summary view, all articles with the summary...
Have you tried calling it as (optional) browsecat="1" - Shows a browseable category list. like it says in the News Help or category=?...
Re: news categories: sorting options?
Posted: Thu Jan 01, 2009 7:19 pm
by aura
hi mark -- my mistake, my news call on the news index page is:
Code: Select all
{news sortby="news_category" browsecat="1" sortasc="false"}
but any changes i make to the tag seem to only affect the news article order when i click on a category but doesn't seem to affect the order in which the categories appear on the page:
http://www.bdmlr.org.uk/index.php?page=news
i've therefore reverted to what i had before.
update: perhaps i've set this up incorrectly from the beginning, but this is the set-up:
i have a news page, which uses a template called 'news'. in the news page itself, the only content i have is the following:
the news template is as follows:
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<__html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{sitename} - {title}</title>
{metadata}
{stylesheet}
</head>
</__body>
<!-- start wrapper -->
<div id="wrapper">
<!-- start header -->
{global_content name='header-left'}
<div id="middleheader">{content block="bannerpic"}</div>
{global_content name='header-right'}
<!-- end header -->
<!-- start left column -->
<div id="leftcolumn">
<div id="search">
{search resultpage='results'}
</div>
<div id="menu">
{menu template='BDMLR' collapse='1'}
</div>
{global_content name='banners'}
</div>
<!-- end left column -->
<!-- start content column -->
<div id="midcolumn">
[b]<h1>News</h1>
{content dateformat="%b %d, %Y" summarytemplate="BDMLR news"}[/b]
</div>
<!-- end content column -->
<!-- start right column -->
<div id="rightcolumn">
<div class="newsheader">
<p>{cms_selflink page="News" text="Latest News »"}</p>
</div>
<div class="news">
{news number='4' detailpage="news" dateformat="%b %d, %Y"}
</div>
</div>
<!-- end right column -->
<!-- start footer -->
{global_content name='footer'}
<!-- end footer -->
</div>
<!-- end wrapper -->
<__body>
</__html>
hope this helps?
aura.
Re: news categories: sorting options?
Posted: Thu Jan 01, 2009 7:29 pm
by Dr.CSS
Maybe it's the order in which you made the categories?...
Re: news categories: sorting options?
Posted: Thu Jan 01, 2009 7:34 pm
by aura
yes that's the problem. the categories are years, so this will always be an issue since the latest year should be at the top but will always be created later. sigh

have updated my previous post with code in the hope that it will expose some fatal flaw which i can fix.
aura.
Re: news categories: sorting options?
Posted: Thu Jan 01, 2009 7:55 pm
by Nullig
I think the only way you're going to get this to work the way you want, is by editing the action.browsecat.php file and changing this (around line 31):
$query .= ' ORDER by hierarchy';
to:
$query .= ' ORDER by long_name DESC';
Nullig
Re: news categories: sorting options?
Posted: Thu Jan 01, 2009 7:58 pm
by aura
hi nullig -- thanks very much, will give it a go. fingers crossed!
aura.
Re: news categories: sorting options?
Posted: Fri Jan 02, 2009 9:45 am
by aura
unfortunately this didn't work. please have a look at the test site:
http://www.grumpyfrombirth.com/cmsmades ... ?page=news
although the latest category (2009) is now displaying above 2008, the associated articles are no longer displaying below their respective categories (for instance, while january is part of the 2009 category, it now displays on its own at the top of the page and the 2008 articles display right below the 2009 category, which is misleading).
surely there must be an easy way of ordering categories? please help, i really need to sort this out for the charity.
thank you again.
aura.
Re: news categories: sorting options?
Posted: Fri Jan 02, 2009 7:23 pm
by Dr.CSS
And what does the tag look like now?...
Re: news categories: sorting options?
Posted: Fri Jan 02, 2009 7:36 pm
by Nullig
You could try:
$query .= ' ORDER by news_category_name DESC';
instead.
Nullig
Re: news categories: sorting options?
Posted: Sat Jan 03, 2009 10:40 am
by aura
mark wrote:
And what does the tag look like now?...
hi mark -- please see my earlier post where i copied in the code i'm using and how i've set things up.
thanks,
aura.