Display Contents of Item in Object Relation List

Author Message

Alex Jones

Saturday 14 February 2004 11:08:24 am

How can I display the contents of any related items in a template? For example, I have set up an Info Page which lists some contact information, I would like to add this to another page (we'll call it Company Info) via the ORL. So, what code do I need to insert in the page template for Company Info to ensure the information is displayed on that page? I've tried multiple methods and can't seem to get it to work. I am using 3.3.2.

Your help is truly appreciated!

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Alex Jones

Wednesday 05 May 2004 1:50:29 pm

Anyone?

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Paul Forsyth

Thursday 06 May 2004 1:14:13 am

Hi Alex,

Is this what you are after?

{default content_object=$node.object
         content_version=$node.contentobject_version_object}

{section loop=$content_version.data_map.related_objects.content.relation_list}

        {set relation_object=fetch(content,object,hash(object_id,$:item.contentobject_id,
                                                       object_version,$:item.contentobject_version))}

        {* Test for some class *}
        {section show=eq($relation_object.contentclass_id, $contact_us_class_id)}
                 {content_view_gui view=full content_object=$relation_object}
        {/section}

{/section}

{/default}

paul

--
http://www.visionwt.com

Alex Jones

Thursday 06 May 2004 6:22:06 am

Thanks for the reply Paul. That doesn't seem to do the trick. Perhaps I have an odd setup: I have extended the <i>Info Page</i> class by adding an <i>Object Relation List</i> to it. The <i>ORL</i> is named "Additional Images" (additional_images). What I would like is for the display loop through all of the images that may have been associated via the <i>ORL</i> and display them. I will also have another <i>ORL</i> to include text like contact info. Again, I will want this embedded in the page. At the moment I am testing with the images and am able to get a link to display when using <i>{attribute_view_gui attribute=$node.data_map.additional_images}</i>. I was hoping there was a simple way to embed the info, but I think I will have to set up a fetch loop like the one you posted above.

When I inserted the code you provided nothing was returned. So, I tried <i>{section loop=$content_version.data_map.related_objects.content.additional_images}</i> and <i>{section loop=$content_version.data_map.related_objects.content.relation_list}</i> to no avail. I am sure that I am missing something obvious here...

Thanks again for your help!

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Paul Forsyth

Thursday 06 May 2004 6:38:39 am

Ah, the obvious thing is, and you will kick yourself:

related_objects is my attribute name, so:

$content_version.data_map.additional_images.content.relation_list

should do the trick.

paul

--
http://www.visionwt.com

Alex Jones

Thursday 06 May 2004 7:44:14 am

Actually I had a typo in my post above, the second example should have read <i>{section $content_version.data_map.additional_images.content.relation_list}</i> not <i>{section loop=$content_version.data_map.related_objects.content.relation_list}</i>. Sorry about that. I did double-check to make sure there weren't any typos, but everything looks to be right and yet nothing is output when I use <i>$content_version.data_map.additional_images.content.relation_list</i>. Here is the code that I am using. I cut it down a bit from what you provided by removing the class check

{default content_object=$node.object
         content_version=$node.contentobject_version_object}

{section loop=$content_version.data_map.additional_images.content.relation_list}
        {set relation_object=fetch(content,object,hash(object_id,$:item.contentobject_id,
                                                       object_version,$:item.contentobject_version))}
                 {content_view_gui view=full content_object=$relation_object}
				 
{/section}

{/default}

What am I missing?

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Paul Forsyth

Thursday 06 May 2004 7:57:46 am

Probably a couple of other things that i missed out at the start ;)

I forgot to create the related_object variable, which might be showing up on your debug output. Plus, check if you have a valid node object - I use this code within views, which always have a node.

{default content_object=$node.object
         content_version=$node.contentobject_version_object
         relation_object=0}

{section loop=$content_version.data_map.additional_images.content.relation_list}
        {set relation_object=fetch(content,object,hash(object_id,$:item.contentobject_id,
                                                       object_version,$:item.contentobject_version))}
                 {content_view_gui view=full content_object=$relation_object}
				 
{/section}

{/default}

paul

--
http://www.visionwt.com

Alex Jones

Thursday 06 May 2004 8:05:58 am

There we go, I'm much closer now! Thanks! The error was related to <i>relation_object</i> having not been set ahead of time. Not sure how I missed that. :P It's been a long day, and it's only 10AM here. :D

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Paul Forsyth

Thursday 06 May 2004 8:35:33 am

Indeed, i forsee lots of problems during your day ;)

paul

Alex Jones

Thursday 06 May 2004 8:57:21 am

Thanks for the kind reassurance. ;)

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Clay Pereira

Thursday 06 May 2004 10:38:29 am

Could you please tell me how I would display the images.
when I use this code I see the image name and image version.

thank you
clay

Alex Jones

Thursday 06 May 2004 11:35:22 am

Clay, try changing the line <i>{content_view_gui view=full content_object=$relation_object}</i> to use a different <i>view</i>. For example, try using <i>{content_view_gui view=message content_object=$relation_object}</i> which should show you the picture alond with the rest of the information. I used that template as the basis for a new view.

You can do this by copying <i>design/standard/templates/content/view/message.tpl</i> into <i>design/YOURSITE/templates/content/view/YOUR_VIEW_TEMPLATE_NAME.tpl</i> where you can then modify to fit your needs. Then all you have to do is plug this line into your templates: <i>{content_view_gui view=your_view_template_name content_object=$relation_object}</i>.

My templates use: <i>{content_view_gui view=embed_related content_object=$relation_object}</i> as I named my view template <i>embed_related.tpl</i>. You will need to modify this template to meet your needs.

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

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

eZ debug

Timing: Jan 19 2025 01:10:07
Script start
Timing: Jan 19 2025 01:10:07
Module start 'layout'
Timing: Jan 19 2025 01:10:07
Module start 'content'
Timing: Jan 19 2025 01:10:08
Module end 'content'
Timing: Jan 19 2025 01:10:08
Script end

Main resources:

Total runtime0.8545 sec
Peak memory usage4,096.0000 KB
Database Queries86

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 589.3047152.6406
Module start 'layout' 0.00630.0033 741.945339.4766
Module start 'content' 0.00950.8434 781.4219681.7109
Module end 'content' 0.85300.0015 1,463.132828.1250
Script end 0.8544  1,491.2578 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00290.3347160.0002
Check MTime0.00120.1444160.0001
Mysql Total
Database connection0.00070.081610.0007
Mysqli_queries0.767789.8424860.0089
Looping result0.00130.1471840.0000
Template Total0.823796.420.4119
Template load0.00210.248720.0011
Template processing0.821696.150520.4108
Template load and register function0.00010.010910.0001
states
state_id_array0.00060.072310.0006
state_identifier_array0.00120.141620.0006
Override
Cache load0.00190.2200670.0000
Sytem overhead
Fetch class attribute can translate value0.00060.066230.0002
Fetch class attribute name0.00150.1771130.0001
XML
Image XML parsing0.00060.068230.0002
class_abstraction
Instantiating content class attribute0.00000.0058190.0000
General
dbfile0.00070.0818160.0000
String conversion0.00000.001040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
12content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
19content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 48
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs