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

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 04:59:02
Script start
Timing: Jan 18 2025 04:59:02
Module start 'layout'
Timing: Jan 18 2025 04:59:02
Module start 'content'
Timing: Jan 18 2025 04:59:02
Module end 'content'
Timing: Jan 18 2025 04:59:02
Script end

Main resources:

Total runtime0.0169 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0061 589.3438152.6250
Module start 'layout' 0.00610.0037 741.968839.4453
Module start 'content' 0.00980.0049 781.414197.3203
Module end 'content' 0.01480.0021 878.734442.3047
Script end 0.0169  921.0391 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002615.5168140.0002
Check MTime0.00116.6995140.0001
Mysql Total
Database connection0.00116.775510.0011
Mysqli_queries0.002816.791730.0009
Looping result0.00000.147810.0000
Template Total0.001810.310.0018
Template load0.00095.264210.0009
Template processing0.00095.040510.0009
Override
Cache load0.00063.564310.0006
General
dbfile0.00021.388980.0000
String conversion0.00000.059140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_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