'advanced' fetch function problem

Author Message

Alessandro Cipriani

Thursday 22 April 2004 2:55:45 am

hi all
i have 2 classes: article and article2, both with a checkbox attribute called "publish_on_frontpage".
in my home page i'd like to have a fetch function that fetches articles and articles2 with the 'publish_on_frontpage' checkbox checked.
that's the fetch function code:

{let news_list=fetch( content, tree, hash( parent_node_id, 2,
                                           limit, 1,
                                           attribute_filter, array(array( 'article/primo_piano', '=', true(),
                                                                          'article2/primo_piano', '=', true() ) ),
                                           sort_by, array( published, false() ) ) )}

 

no problem if there is an article checked as published on frontpage, but if i'd like to have an article2 it isn't published there.

how can i fetch object of these 2 classes by the 'publish_on_frontpage' checkbox?

best regards
alessandro

Paul Forsyth

Thursday 22 April 2004 3:06:48 am

I think you need a conditional operator as part of your attribute_filter.

Eg

attribute_filter, array(array( 'or', 'article/primo_piano', '=', true(),
                                     'article2/primo_piano', '=', true() ) )

See the doco for this:

http://ez.no/ez_publish/documentation/development/libraries/ez_template/operators/data_fetch

Without this i think the filter just matches on the first condition, though i could be wrong. I haven't used it yet.

paul

--
http://www.visionwt.com

Alessandro Cipriani

Thursday 22 April 2004 3:43:04 am

hi paul

following your suggestion i wrote:


				   {let news_list=fetch( content, tree, hash( parent_node_id, 2,
															  limit, 1,
															  attribute_filter, array('or', array( 'article/primo_piano', '=', true()), array( 'article/prodotti', '=', true() ) ),
															  sort_by, array( published, false() ) ) )}

and it's working.
but this code fetches objects by 2 attributes of the SAME object (article)
if i try to write 'article2/primo_piano' instead 'article/prodotti' i don't get anything...

any suggestion?

best regards
alessandro

Paul Forsyth

Thursday 22 April 2004 4:05:36 am

As you have added a new class have you added this class to your permissions for your current user? If you dont have the role permissions set it wont be returned.

paul

--
http://www.visionwt.com

Alessandro Cipriani

Thursday 22 April 2004 4:53:17 am

yes paul
the new class (article2) is displayed without problems by all. The example you suggested me is about two attributes of the same class, while my need is to fetch two attributes of two different classes.
i think that this a sintax problem...

any hint?
cheers
alessandro

Paul Forsyth

Thursday 22 April 2004 5:05:18 am

Ah, i see. Well, the best thing is to use two fetchs then, one for each class. Once you have this you can check the arrays and do the appropriate action.

paul

--
http://www.visionwt.com

Paul Forsyth

Thursday 22 April 2004 5:07:48 am

Might also be worth filing a bug about this. The fetch doesn't seem to be doing what it should be doing.

paul

--
http://www.visionwt.com

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