problem displaying eZObjectRelation datatype

Author Message

Roberta Gatti

Wednesday 24 March 2004 3:31:08 am

Hi,
I create a new class which contains these fields:

name --> string
description --> string
orario --> ezobjectrelation datatype

The class linked to the field "orario" is composed by:

day --> string
hour --> string

I want to display all fields of my new class but I have same problems displaying the data contained in ezobjectrelation datatype with fetch function.

TIA
R.

John Dalton

Saturday 27 March 2004 6:15:59 pm

I'm having a similar problem - I need to be able to access related objects of items I've fetched.

How do I either access those objects directly from the value returned by fetch, or get the object id so that I can grab it some other way?

I have several related objects, one of them is called "band". Let's say I want to grab the attribute "description" from the band object which is related to the current item - in the loop I've tried:

$item.band.description
$item.object.band.description
$item.object.data_map.band.description
$item.object.data_map.band.data_map.description
$item.object.data_map.band.object.data_map.description

$item.object.data_map.band gives me formatted output, but not access to attributes.

This must be simple, but I can't find an example in the documentation.

Lauren Matheson

Monday 05 April 2004 9:43:50 pm

Check out: http://www.ez.no/community/forum/setup_design/accessing_an_attribute_of_a_class_s_objectrelation

John Dalton

Tuesday 13 April 2004 7:45:02 pm

Hi Roberta,

I solved my own problem, and hopefully I've solved yours as well. I eventually found an attribute which works pretty much by trial and error, using the attribute(show) command to view them all.

The object id of the related object is stored in the data_int attribute of the object relation field. This seems pretty counter-intuitive to me.

Here's an example that should suit the situation you've described above, assuming the template is for the node that displays the 'container' object:

  {let orario=fetch( 'content', 'object',
                        hash( 'object_id', $node.object.data_map.orario.data_int )
                       )
  }
  
  
  Name: {$node.object.data_map.name}
  Description: {$node.object.data_map.description}
  Day: {$orario.object.data_map.day}
  Hour: {$orario.object.data_map.hour}

This can be used (modified) inside a loop or whereever you like - once you know that you can find the required value inside data_int, the rest is easy.

I hope this helps,

John Dalton

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