Forums / Setup & design / Fetch sort via specific field?

Fetch sort via specific field?

Author Message

arthur foelsche

Sunday 27 April 2003 8:47:46 am

I'm working on a news site where articles are published on a daily basis. However, some of those articles are "back dated" ie: that their actual publish date is before the actual date that they are entered into ez publish.

To make sure that each article has the correct date, i created a article_date field in the article class. Now I want to display articles not based on pubilshed, but based on article_date. I can't seem to figure out how to do this.

Here's the code that i'm using to do it by 'published' What modifications do i need to make to make it sort by my defined field?

20 most recent stories: <br>
{let test=fetch( 'content',
'list',
hash(parent_node_id, 158, class_filter_type, "include", class_filter_array, array(2), "sort_by", array("published", false()), "depth", 0))
}
<table>
{section name=Child loop=$test max=20}
<tr><td><font size=-1>{attribute_view_gui attribute=$Child:item.data_map.article_date}</td><td><font size=-1>
<a href={concat("/content/view/full/",$Child:item.node_id)|ezurl}>{$Child:item.name}</a></td></tr>
{/section}
</table>

As a side note, i would also like to add the "next previous" links (ala google) so that one can browse stories in this mode. I used the following code, but am unsure of how to relate the two pieces of code together:

{include name=navigator uri='design:navigator/google.tpl'
page_uri=concat('/content/view','/full/',$node.node_id)
item_count=10
view_parameters=hash(offset,20)
item_limit=5}

anybody have any thoughts?

thanks!

arthur

Paulo Almeida

Sunday 27 April 2003 2:38:50 pm

Hi

I think fetch doen't support defined fields. Look at http://ezwiki.blanko.info/index.php/3XHT_FetchFunction .
In your case, the best i found is modified field, could be an solution.

Paulo

PACPI.COM Internet Consulting
http://pacpi.com

Jan Borsodi

Sunday 27 April 2003 11:03:32 pm

You could create a post publish workflow which would read the date from an attribute in the object and then set it as publish date.
This would ofcourse require writing a custom workflow type in PHP.

What's the url of your page?

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

arthur foelsche

Monday 28 April 2003 12:49:02 am

The url that i'm working at is here:

http://red.eggplantmedia.com/~fluoride/ez/index.php

what is the difference between: "class_identifier" and "class_name" ? If I'm doing a fetch based on either of these, what would be the results?

any tips on writing the work flow to do this? I haven't experimented with workflows at all yet, and am a bit unsure of how to start....

It seems like this would a really useful piece of code.... is there away to define one of the classes in article to relate to published? I guess ultimately having a fetch support specific fields would be pretty important.

thanks

arthur

Paal Are Solberg

Wednesday 28 May 2003 6:35:08 am

I have no good solution, if you find one please post it :)

A poor solution could be to specify the Object name pattern for your article class as article_date, and then sort_by name in the fetch-statement?

...but you wold have to republish all your articles(?), and also the change could make it difficult to identify your articles in the admin-site (since they would be listed by article_date there as well)...

Sorry if this is not very clever, i'm new to this

Teemu Vesala

Wednesday 04 June 2003 2:00:07 pm

This goes a bit hackish way but this is what I did to get sorted by the datetime field:
Object name pattern of the class were changed to
<date><title> and then sorting can be done based to 'name'. It works fine. (I've got datetime field with identified 'date')

Teemu =)

Matthew Knell

Tuesday 08 July 2003 9:08:31 pm

Has anyone tried Teemu's solution? Has it worked for you? I tried this, and it didn't work for me. I'm in the same bind, and if I can't come up with anything better, I'm going to have to figure out how to join like 4 tables in the database and manually change the publish date, or go through and make sure to publish everything again in the correct order.

I love ez3 - but this is a huge issue for me at this point.. any ideas would be greatly appreciated (ez crew, especially ;) )

Chris Winchester

Friday 08 August 2003 3:37:52 am

If you can find a way to live with it you could make it a convention that the news article name starts with your article date written in reverse order (yyyy-mm-dd, e.g. 2003-07-21 for 21 July 2003). It's a bit awkward, but it does then allow you to sort on name to get a date sort.

I'm currently doing this on my news pages until the improved fetch function comes out in 3.2, which I understand will allow sorting on your own fields.

- Chris

eZ debug

Timing: Jan 29 2025 23:49:25
Script start
Timing: Jan 29 2025 23:49:25
Module start 'content'
Timing: Jan 29 2025 23:49:25
Module end 'content'
Timing: Jan 29 2025 23:49:25
Script end

Main resources:

Total runtime0.1088 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.0052 587.9297180.8359
Module start 'content' 0.00520.0058 768.7656101.8672
Module end 'content' 0.01110.0976 870.6328533.3047
Script end 0.1087  1,403.9375 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00333.0247200.0002
Check MTime0.00131.1983200.0001
Mysql Total
Database connection0.00060.588410.0006
Mysqli_queries0.071465.60501410.0005
Looping result0.00070.68181390.0000
Template Total0.097389.410.0973
Template load0.00080.747310.0008
Template processing0.096588.694310.0965
Override
Cache load0.00060.516510.0006
Sytem overhead
Fetch class attribute can translate value0.00050.415510.0005
XML
Image XML parsing0.00020.162810.0002
General
dbfile0.00656.0115200.0003
String conversion0.00000.004830.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.0001 secs