Trying to fetch related objects

Author Message

Franck T.

Friday 07 April 2006 12:12:11 am

Hello all,
I'm trying to fetch all objects related to articles. So I've add this in my articles full view template:

 {let objects=fetch( 'content', 'related_objects', 
                       hash( 'object_id', $node.contentobject_id ) )}
   {section loop=$objects}
       <a href="{$objects.main_node.url_alias}">{$objects.name}</a>
   {/section}

I get this error:

Module start 'content' 
Error: eZModuleFunctionInfo::execute Apr 07 2006 09:05:43 
No such function 'related_objects' in module 'content' 

I'm surelly missing something ...

Kristof Coomans

Friday 07 April 2006 12:38:04 am

Which version of eZ publish are you using?

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

Franck T.

Friday 07 April 2006 12:48:05 am

I'm running the 3.6.0 on Win2K.

Franck T.

Friday 07 April 2006 1:07:19 am

Hum...
When I remove the simple quotes in <i>'content'</i> and <i>'related_objects'</i>, the system returns no error but it doesn't display the related objetcs.
What does it mean ??

Jo Henrik Endrerud

Friday 07 April 2006 1:26:56 am

according to kernel/content/function_definition.php it is no 'related_objects' functions for the fetch in the content module. You should rather do:

{let objects=$node.object.related_contentobject_array}

Jo Henrik Endrerud | System Developer @ Seeds Consulting | http://www.seeds.no

Franck T.

Friday 07 April 2006 1:50:23 am

Thanks Jo but where did you find this?
Is the doc out-of-date? http://ez.no/doc_hidden/ez_publish/technical_manual/3_6/reference/modules/content/fetch_functions/related_objects

...
{* For related objects: *}
 
{let objects=$node.object.related_contentobject_array}
   {section loop=$objects}
       <a href="{$objects.main_node.url_alias}">{$objects.name}</a>
   {/section}

...

No debug error but still no objects displayed !!

Kristof Coomans

Friday 07 April 2006 2:02:44 am

The related_objects and related_objects_count fetch functions were introduced in version 3.6.3 ( http://pubsvn.ez.no/nextgen/stable/3.6/doc/changelogs/3.6/CHANGELOG-3.6.2-to-3.6.3 ).

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

Jo Henrik Endrerud

Friday 07 April 2006 2:05:27 am

Hmm... I checked in the code for 3.5. Looks like the fetch function you use was created for 3.6, so it should work for you the way you tried.
The problem might be your loop. Can you check the source of the output and see if the links actually are there, but without any link text?
If so, the problem is that you have just forgot to add a var-name for your loop. The loop should be something like this:

{section loop=$objects var=myloop}
     <a href={$myloop.item.main_node.url_alias|ezurl}>{$myloop.item.name}</a>
{/section}

The ezurl i added is not related to this problem, but it's best practice to use, so I added it for you.

Jo Henrik Endrerud | System Developer @ Seeds Consulting | http://www.seeds.no

Franck T.

Friday 07 April 2006 3:14:49 am

OK Jo, you're right: the var-name was missing in my loop. Now it works fine.
Amazed ...
Thanks a lot. Really.

A last question just to be complete: in my template, is there a way to inform users with something like "No additional info" when the given artice has no related object ?

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 31 2025 00:24:13
Script start
Timing: Jan 31 2025 00:24:13
Module start 'layout'
Timing: Jan 31 2025 00:24:13
Module start 'content'
Timing: Jan 31 2025 00:24:14
Module end 'content'
Timing: Jan 31 2025 00:24:14
Script end

Main resources:

Total runtime1.1933 sec
Peak memory usage8,192.0000 KB
Database Queries77

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0067 588.1250151.2109
Module start 'layout' 0.00670.0046 739.3359220.6875
Module start 'content' 0.01131.1811 960.02344,546.2734
Module end 'content' 1.19240.0009 5,506.296919.8516
Script end 1.1933  5,526.1484 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.3094160.0002
Check MTime0.00130.1079160.0001
Mysql Total
Database connection0.00080.067010.0008
Mysqli_queries1.095691.8116770.0142
Looping result0.00080.0650750.0000
Template Total1.125994.320.5629
Template load0.00180.150520.0009
Template processing1.124194.193720.5620
Template load and register function0.00150.129810.0015
states
state_id_array0.00210.174210.0021
state_identifier_array0.00240.197020.0012
Override
Cache load0.00160.1329400.0000
Sytem overhead
Fetch class attribute can translate value0.00180.148230.0006
Fetch class attribute name0.00190.1617100.0002
XML
Image XML parsing0.00080.067930.0003
class_abstraction
Instantiating content class attribute0.00000.0019110.0000
General
dbfile0.00240.2004160.0001
String conversion0.00000.000640.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
9content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
13content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 36
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs