Forums / Developer / Attribute_filter

Attribute_filter

Author Message

Patrice DUCLAUD

Wednesday 24 August 2005 6:17:31 am

Is there a problem with attributes filtering on eZp 3.6.0 ?

This code don't work for me

{let children=fetch( 'content', 'list',
        hash( 'parent_node_id',   969,
              'attribute_filter', array( 'or',
                                         array( 'ann/ann_rub', '=', $param1 ),
                                         array( 'ann/ann_rub', '=', $param2 ) ) ) )}

where <b>ann</b> is a classe and <b>ann_rub</b> is an atrribute of this class. <b>$param1</b> and <b>$param2</b> are two parameters , that i pass with url. ($param1 et $param2 contain s good value).
Without attribute_filter there is no problem.

Thanks
Patrice

Patrice DUCLAUD

Wednesday 24 August 2005 7:36:11 am

ann_rub is an attribute [Selection]
with Type: Single choice.

Xavier Dutoit

Wednesday 24 August 2005 8:13:22 am

Some type of attributes aren't supported as filter.

I think the selection attribute is one of them (have a look at the doc to confirm).

X+

http://www.sydesy.com

Kristof Coomans

Wednesday 24 August 2005 11:06:45 pm

The selection datatype seems to have support for attribute filtering (checked in eZ 3.6.1):

function &sortKey( &$contentObjectAttribute )
{
    return strtolower( $contentObjectAttribute->attribute( 'data_text' ) );
}

function sortKeyType()
{
    return 'string';
}

You can search a datatype's class code for the functions sortKeyType and sortKey, if you want to find out if they support attribute sorting and filtering. Or you can take a look at the ezcontentobject_attribute table of your database to see if there's something stored in either the sort_key_int or sort_key_string field.

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

Patrice DUCLAUD

Wednesday 24 August 2005 11:32:10 pm

hi xavier,

Thanks for your reply.
Here is a part of the ezpublish documentation according to attribute filter. http://ez.no/doc/ez_publish/technical_manual/3_6/reference/modules/content/fetch_functions/list
<i>
<b>Attribute filtering</b>

The attribute filter mechanism is controlled by the "attribute_filter" parameter. Attribute filtering makes it possible to fetch a set of nodes where an attribute (or several attributes) contains some specific data. Filtering on the attribute level is supported for the following datatypes:

* Checkbox
* Date
* Date and time
* E-mail
* Integer
* Object relation
* <b>Selection
(will not work when used as multiple selector)</b>
* Text line
* Time
</i>
my selection is single choice and the problem is still there.

Patrice

Marko Žmak

Thursday 25 August 2005 12:04:07 am

Does your code generate an error or warning (see debug output)?

What does "don't work" exactly mean? Does it return more or less results than it should?

P.S. Did you clear the cache recently?

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Patrice DUCLAUD

Thursday 25 August 2005 1:55:05 am

hi Kristof,
thanks for your reply,
In my case, there is something in most of the sort_key_string field of the attribute concerned with my search.

If i use the search function http://ez.no/doc/ez_publish/technical_manual/3_6/reference/modules/content/fetch_functions/search
<i>
fetch( content, search,
hash( text, text,
[ offset, offset, ]
[ limit, limit, ]
[ section_id, id, ]
[ subtree_array, array, ]
[ publish_timestamp, time, ]
[ publish_date, date, ]
[ section_id, id, ]
[ class_id, id, ]</i>
<b>[ class_attribute_id, id, ]</b>
<i>[ sort_by, sort_by ] ) )</i>

it's good.

Patrice

Marko Žmak

Thursday 25 August 2005 2:07:38 am

You can use attribute_id also in attribute_filter for "fetch(content, list,..." like it is described here:

http://ez.no/products/ez_publish_cms/documentation/reference/data_fetching/content/list

So you might try this instead.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Kristof Coomans

Thursday 25 August 2005 2:38:06 am

Maybe the class "ann" (or the class attribute "ann_rub") isn't cached yet in the class identifier cache. You can try to clear the class identifier cache through the admin interface.

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

Dominik Stoeppel

Thursday 25 August 2005 4:13:40 am

I have the same problem. (using 3.6.1)

http://ez.no/community/forum/setup_design/filter_content_passing_values_from_url

Patrice DUCLAUD

Thursday 25 August 2005 7:54:59 am

hi Marko,Kristof

<i>Does your code generate an error or warning (see debug output)?</i>
no error according to this request.

<i>What does "don't work" exactly mean? Does it return more or less results than it should?</i>
the request return noting.

<i>P.S. Did you clear the cache recently?</i>
yes,

i see that Dominik have the same pb. The pb should be with Selection attribute.

Patrice

Kristof Coomans

Thursday 25 August 2005 11:01:02 pm

Possible solution posted at http://ez.no/community/forum/setup_design/filter_content_passing_values_from_url

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

Mazen Alsibai

Wednesday 14 September 2005 2:50:44 am

thanks Kristof,it works now by using your notes
{let children=fetch( 'content', 'list',
hash( 'parent_node_id', 969,
'attribute_filter', array( 'or',
array( 'class_name/attribute_name', '=',id of the select(not the value) ),
array( 'ann/ann_rub', '=', $param2 ) ) ) )}

Fabricio Guerrero

Friday 20 January 2006 7:08:35 am

(will not work when used as multiple selector)

Hi,

I've seen that comment all over the forum and documentation section but my problem :( is that i indeed have a Class with a multiple selector and an important part is for me to fetch and filter on that field.

To give a bit more detail we're creating a site based on articles and these articles can have various categories. As an user you can be able to view articles by categories. The fetch works if that Article only belongs to one category but if the article has various categories(multiple selector working here) the fetch just wont return the article...

I've tested various ways of filtering(like, in) but none seem to work. Here's the fetch:

{let
filter_cat=fetch( 'content', 'tree', hash( 'parent_node_id', 77,
class_filter_type, "include", class_filter_array, array(25),
attribute_filter, array( array( 'article_issue/category', '=', $selected ) ),
'sort_by', array( 'published', false() ),
'offset', $view_parameters.offset,
'limit', $numberOfObjects
))
}

anybody has any idea how to fetch with a multiple selector???

any help will be very appreciated.

Regards,
Fabricio

http://www.solobromasychistes.com <<Joomla Site :P
http://www.recipesforhealthyfood.com/ <<Drupal Site :P
http://www.ezforge.com/ <<future ezCommunity, Articles, forums and more...