How to use fetch with attribute_filter?

Author Message

Milad P

Wednesday 14 June 2006 2:52:58 am

I have a date object in my class 'scholarship and i want to use 'attribute_filter' to sort my items after the month value in my date object. How do i do that?

{set list_items=fetch_alias( children, hash( parent_node_id, $node.node_id,
offset, $view_parameters.offset, sort_by, array( array('attribute', false(), 'scholarship/seekdate')),
attribute_filter, array(array('scholarship/seekdate.month', '<', $now)), limit, $page_limit ) )}

I can make it work for the whole date object, but i want to filter after month.

Kristof Coomans

Wednesday 14 June 2006 3:44:05 am

Hi

You can make a date with the makedate template operator ( http://ez.no/doc/ez_publish/technical_manual/3_8/reference/template_operators/miscellaneous/makedate ). and put it in $now.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Milad P

Wednesday 14 June 2006 4:45:20 am

My problem is to convert

'scholarship/seekdate.month'

to only month. $now is defined as $now = maketime().

i tried

  attribute_filter, array(array(makedate(currentdate()|datetime('scholarship/seekdate','%m')), '<', currentdate('custom', '%m') ))

but it didn't work. My plan was to take out month from seekdate and compare it with current month.

Kristof Coomans

Wednesday 14 June 2006 5:30:49 am

{let $now=makedate()
    $timeStruct=gettime( $now )
    $firstDayOfTheMonth=makedate( $timeStruct.month, 1, $timeStruct.year )}

Now use an attribute filter like:

array( 'and', array( 'scholarship/seekdate', '<' , $firstDayOfTheMonth ) )

This will give you all scholarships before the current month.

It's not possible to fetch everything of a specific month ( without specifying the year ).

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.