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.

eZ debug

Timing: Jan 18 2025 22:32:22
Script start
Timing: Jan 18 2025 22:32:22
Module start 'layout'
Timing: Jan 18 2025 22:32:22
Module start 'content'
Timing: Jan 18 2025 22:32:23
Module end 'content'
Timing: Jan 18 2025 22:32:23
Script end

Main resources:

Total runtime1.4348 sec
Peak memory usage4,096.0000 KB
Database Queries69

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 589.3359152.6250
Module start 'layout' 0.00540.0025 741.960939.4453
Module start 'content' 0.00791.4253 781.4063560.7500
Module end 'content' 1.43320.0015 1,342.156316.1719
Script end 1.4347  1,358.3281 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.2167160.0002
Check MTime0.00130.0929160.0001
Mysql Total
Database connection0.00080.056710.0008
Mysqli_queries1.375195.8368690.0199
Looping result0.00060.0441670.0000
Template Total1.401197.720.7006
Template load0.00170.119820.0009
Template processing1.399497.531620.6997
Template load and register function0.00020.014610.0002
states
state_id_array0.00200.137410.0020
state_identifier_array0.00190.133320.0010
Override
Cache load0.00150.1059470.0000
Sytem overhead
Fetch class attribute can translate value0.00070.050620.0004
Fetch class attribute name0.00120.081270.0002
XML
Image XML parsing0.00030.017920.0001
class_abstraction
Instantiating content class attribute0.00000.000970.0000
General
dbfile0.00060.0421100.0001
String conversion0.00000.000640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
15content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
9content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
5content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 38
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs