eZ Community » Forums » Developer » ezfind + object relations filter
expandshrink

ezfind + object relations filter

ezfind + object relations filter

Tuesday 05 November 2013 7:41:24 pm - 2 replies

Hi all,

I am stuck with a frustrating problem.

I can't find a way to add an object relations filters with ez find.

I have users and badges. User have a badges attribute (objectrelationlist).

I am looking for a way to retrieve users with a given badge but I can't find the right syntax/example.

It is possible ? (using ez5 in legacy mode).

Thank you so much

Wednesday 06 November 2013 10:31:56 am

eZFind index some extra params for objects relations.

Exemple for objects relations "workplace" of my user class of user Salvador.

<doc>
<!-- ... -->
<str name="attr_firstname_s">Salvador</str>
<arr name="submeta_workplace___class_identifier_ms"><str>parameter</str></arr>
<arr name="submeta_workplace___class_name_ms"><str>Paramètre</str></arr>
<arr name="submeta_workplace___contentclass_id_si"><int>53</int></arr>
<arr name="submeta_workplace___current_version_si"><int>1</int></arr>
<arr name="submeta_workplace___id_si"><int>48738</int></arr>
<arr name="submeta_workplace___main_node_id_si"><int>48698</int></arr>
<arr name="submeta_workplace___main_parent_node_id_si"><int>10437</int></arr>
<arr name="submeta_workplace___modified_dt"><date>2013-07-01T10:22:19Z</date></arr>
<arr name="submeta_workplace___owner_id_si"><int>14</int></arr>
<arr name="submeta_workplace___published_dt"><date>2013-07-01T10:22:19Z</date></arr>
<arr name="submeta_workplace___remote_id_ms"><str>....</str></arr>
<arr name="submeta_workplace___section_id_si"><int>8</int></arr>
<!-- ... -->
</doc>

 

So you can trie 

 

{def $workplace_content_object_id = 115}

{def $filter_workplace = concat('submeta_workplace___id_si:', $workplace_content_object_id)}

{def $user_node_list = fetch(ezfind, search, hash('filter', array(filter_workplace)))}

 

/ not tested /

/ eZ4 /

Modified on Wednesday 06 November 2013 10:35:10 am by Rémy PHP

Wednesday 06 November 2013 12:30:48 pm

Rémy I owe you a beer ! Thank you very much.

I just had to adapt a bit to match with the name of the badge (not the id). In the index, there is only one id stored but the names are all there.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from