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.