[solved] news categories: sorting options?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
aura
Forum Members
Forum Members
Posts: 21
Joined: Mon Sep 01, 2008 9:48 am

[solved] news categories: sorting options?

Post 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.
Last edited by aura on Thu Jan 08, 2009 10:00 am, edited 1 time in total.
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm

Re: news categories: sorting options?

Post by Nullig »

Have you tried adding:

sortasc="false"

to your tag?

Nullig
aura
Forum Members
Forum Members
Posts: 21
Joined: Mon Sep 01, 2008 9:48 am

Re: news categories: sorting options?

Post 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.
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm

Re: news categories: sorting options?

Post 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
aura
Forum Members
Forum Members
Posts: 21
Joined: Mon Sep 01, 2008 9:48 am

Re: news categories: sorting options?

Post 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

Code: Select all

sortasc="false"
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.
Last edited by aura on Thu Jan 01, 2009 6:59 pm, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: news categories: sorting options?

Post 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=?...
aura
Forum Members
Forum Members
Posts: 21
Joined: Mon Sep 01, 2008 9:48 am

Re: news categories: sorting options?

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

Code: Select all

{news browsecat="1"}
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.
Last edited by aura on Thu Jan 01, 2009 7:32 pm, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: news categories: sorting options?

Post by Dr.CSS »

Maybe it's the order in which you made the categories?...
aura
Forum Members
Forum Members
Posts: 21
Joined: Mon Sep 01, 2008 9:48 am

Re: news categories: sorting options?

Post 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.
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm

Re: news categories: sorting options?

Post 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
aura
Forum Members
Forum Members
Posts: 21
Joined: Mon Sep 01, 2008 9:48 am

Re: news categories: sorting options?

Post by aura »

hi nullig -- thanks very much, will give it a go. fingers crossed!

aura.
aura
Forum Members
Forum Members
Posts: 21
Joined: Mon Sep 01, 2008 9:48 am

Re: news categories: sorting options?

Post 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.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: news categories: sorting options?

Post by Dr.CSS »

And what does the tag look like now?...
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm

Re: news categories: sorting options?

Post by Nullig »

You could try:

$query .= ' ORDER by news_category_name DESC';

instead.

Nullig
aura
Forum Members
Forum Members
Posts: 21
Joined: Mon Sep 01, 2008 9:48 am

Re: news categories: sorting options?

Post 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.
Post Reply

Return to “Modules/Add-Ons”