fetching objects from php based on attributes

Author Message

Patrice Fortin

Tuesday 08 May 2007 6:32:34 pm

I people,
I want to create a function that can be called from a template which fetches events for a single month in some/all calendars in a site. The function will return a array of arrays having each day as an element to be able to display it like webcalendar (displaying event names in each table cell with links or popup on mouseover).

Anyway, here is where I'm having trouble: I don't know how to fetch objects depending on attributes. I can easily do it from a template, but I can't figure out how to do it from a php function.

Here is a simplified fetch that would be enough for testing. Logically, this should return nothing, but it returns the same thing, no matter if the "array( 'or', array('event/from_time', '<', 0) )" condition is there:

        $events =  eZPersistentObject::fetchObjectList( eZContentObject::definition(),
                                                                   null, 
                                                                   array( 'contentclass_id' => 30,
                                                                          array( 'or', array('event/from_time', '<', 0) ) ),
                                                                   false,
                                                                   false,
                                                                   true );

What is incorrect in my condition parameter ?

Kristof Coomans

Tuesday 08 May 2007 11:26:20 pm

Hi Patrice

I think you are using the wrong function for what you are trying to do. Use eZContentObjectTreeNode::subTree or instead. &#321;ukasz wrote a nice blog article in which you can find a few examples: http://serwatka.net/en/blog/fetching_ez_publish_content_objects_with_php.

The conditions parameter to eZPersistentObject::fetchObjectList is documented well with Doxygen (the API docs are at http://pubsvn.ez.no/doxygen/3.9/html/index.html ).

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.