Sort listings by date

Author Message

Matt Brady

Wednesday 24 May 2006 12:13:57 am

I'm still pretty new with ezpublish but learning quickly... I am in the process of building a site and I have run into a problem when trying to sort listings by date (see: http://www.byrongigs.com/bbgigs/index.php?/giguser/gigguide). I'm not sure how to sort these dates so that the latest date is at the top. I've tried to sort by the object id but it doesn't seem to work. Can someone help?

It's not easy being easy.

Marcin Drozd

Friday 26 May 2006 1:02:07 am

Hi Matt
Try with:

'sort_by', array( 'published', false() )

or

'sort_by', array( 'attribute', false(), 'CLASS_NAME/ATTRIBUTE_NAME' )

- fetch() function

see more: http://ez.no/doc/ez_publish/technical_manual/3_7/reference/modules/content/fetch_functions/list

http://ez-publish.pl

Matt Brady

Saturday 27 May 2006 12:41:47 am

Thanks Marcin however, I'm afraid I need a little more info....
I could be wrong, but I'm assuming that I write the code into the template for that page. For example, the Gig list on the page appears in the line.tpl override and I have set this up as follows:

 {let giglist=fetch( 'content', 'list',
        hash( 'parent_node_id', 19,
              'sort_by',        array( 'attribute', false(), 'gig/date' )  ) ) } 

      <div  class="gigtable">
<table>          
                 <tr>
                       <td width="69">{attribute_view_gui attribute=$node.object.data_map.date} </td>
                       <td width="45">{attribute_view_gui attribute=$node.object.data_map.time} </td>
                       <td width="130">{attribute_view_gui attribute=$node.object.data_map.band} </td>
                       
                       <td width="150">{attribute_view_gui attribute=$node.object.data_map.venue} </td>
                       <td width="45">{attribute_view_gui attribute=$node.object.data_map.price} </td>
                       <td width="45">{attribute_view_gui attribute=$node.object.data_map.ticket_link}</td>
                 </tr>
</table></div>  {/let} 

Have I done this correctly or am I way off?

It's not easy being easy.

Marcin Drozd

Saturday 27 May 2006 11:42:23 am

Hi, sorry but I do not understand your part of code. You have var giglist but you never use it (and there is not {section loop=...}). but you use $node variable.

I think you should use:
in line_override_file (view line.tpl)

     <div class="gigtable">
<table>          
                <tr>
                      <td width="69">{attribute_view_gui attribute=$node.object.data_map.date} </td>
...
                </tr>
</table></div>

but in full.tpl (full_override_file):

{let giglist=fetch( 'content', 'list',
       hash( 'parent_node_id', 19,
             'sort_by',       array( 'attribute', false(), 'gig/date' ) ) ) } 
 {section loop=$giglist}
  {node_view_gui view=line content_node=$:item}
 {/section}
{/let}

http://ez-publish.pl

Matt Brady

Sunday 28 May 2006 6:01:53 pm

Hi Marcin, Thanks for that... however, I tried and failed :(
I'm not sure which "full.tpl" I should be overriding, I would assume folder_full.tpl as this is the tpl the line tpl sits within.
I am probably missing something obvious.
What about through the admin interface... you seem to be able to sort sub items but are limited to: Class Identifier, Class Name, Depth, Modified, Name, Priorty, Published, Section. Can I add an attribute of "Date" to this in order to sort by date?

It's not easy being easy.

Marcin Drozd

Monday 29 May 2006 1:14:03 am

> I'm not sure which "full.tpl" I should be overriding
create new template for node /giguser/gigguide (node/view/full.tpl)

> Can I add an attribute of "Date" to this in order to sort by date?
yes U can but I in my humble opinion it is more difficult.

http://ez-publish.pl

Matt Brady

Monday 29 May 2006 4:49:11 pm

OK, I've tried that, and a series of other things but no change... this is very strange.
All I need to do is have it so that the gigs appear in order of the date (object id:212). I need to be able to sort this in the folder view of the gigguide where the list is viewed (through the line.tpl) and in the right menu through the listitem.tpl. The actaul gig_full.tpl does not need to list by date as it contains only single gig information.
If I create a new full.tpl for class_identifier:gig and put nothing else in but:

{let giglist=fetch( 'content', 'list',
hash( 'parent_node_id', 19,
'sort_by', array( 'attribute', false(), 'gig/date' ) ) ) }
{section loop=$giglist}
{node_view_gui view=line content_node=$:item}
{/section}
{/let}

I get no output in the full gig view and it changes nothing in the line view.
I appreciate your help with this Marcin, I have a fully dogeared "Learning ezpublish 3" book on my desk and extensive time searching the forums on this one but it's got me stumped.

It's not easy being easy.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.