Forums / Setup & design / Sort listings by date

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.

eZ debug

Timing: Jan 19 2025 00:11:34
Script start
Timing: Jan 19 2025 00:11:34
Module start 'content'
Timing: Jan 19 2025 00:11:34
Module end 'content'
Timing: Jan 19 2025 00:11:34
Script end

Main resources:

Total runtime0.2602 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0059 591.7734180.8438
Module start 'content' 0.00590.0070 772.6172101.8672
Module end 'content' 0.01290.2472 874.4844530.0000
Script end 0.2602  1,404.4844 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00361.3788200.0002
Check MTime0.00150.5908200.0001
Mysql Total
Database connection0.00080.291710.0008
Mysqli_queries0.205979.11751410.0015
Looping result0.00170.65701390.0000
Template Total0.246894.910.2468
Template load0.00090.350810.0009
Template processing0.245994.500410.2459
Override
Cache load0.00060.246010.0006
Sytem overhead
Fetch class attribute can translate value0.00070.276710.0007
XML
Image XML parsing0.00030.102210.0003
General
dbfile0.00592.2703200.0003
String conversion0.00000.001830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs