how to fetch the object relation(attributes)..?

Author Message

Satheesh R

Saturday 09 December 2006 5:08:22 am

hello all,

how to fetch object relations attribute,
for example
i have a 2 class called Teacher & Subect

Subject contains
-------------------
Name : aaa
Standard : 5th
and Teacher_name (This is "object relation" to Teacher) : bbb

Teacher contains
---------------------
Name : bbb
Qualification : MCA
Experience : 5yrs
..... etc

i want to get all the infos of teacher "bbb" (infos like MCA , 5 Yrs...etc) when i select the info of student "aaa"

please any one guide me to achieve the above

--
Satheesh R

Thanks and Regards
R Satheesh

Jacobo Quiles

Monday 11 December 2006 12:40:46 am

Hi, you could try something like this:

Assuming we are watching the full view of a subject:

{* Fetch all the related objects from the node that is being viewed *}

{def $teachers=fetch('content','related_objects',hash('object_id', $node.object.id, 'all_relations', true()))}

{* Foreach related teacher, show the attributes *}

{foreach $teachers as $teacher}
    {attribute_view_gui attribute=$teacher.main_node.data_map.name}<br/>
    {attribute_view_gui attribute=$teacher.main_node.data_map.qualification}<br/>
    {attribute_view_gui attribute=$teacher.main_node.data_map.experience}<br/><br/>
{/foreach}

Hope it helps.
Cheers.

Microblau SL
http://www.microblau.net

Xavier Dutoit

Monday 11 December 2006 8:10:41 am

Hi,

No need of the extra loop through the main node of the object,

{attribute_view_gui attribute=$teacher.data_map.name}<br/>

http://www.sydesy.com

Satheesh R

Tuesday 12 December 2006 2:13:47 am

Hi Jacobo Quiles, Xavier Dutoit

It works well, Thanks for the solutions

Thanks and regards
Satheesh R

Thanks and Regards
R Satheesh

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