Forums / General / Trying to fetch related objects

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 ?

eZ debug

Timing: Jan 30 2025 21:14:12
Script start
Timing: Jan 30 2025 21:14:12
Module start 'content'
Timing: Jan 30 2025 21:14:12
Module end 'content'
Timing: Jan 30 2025 21:14:12
Script end

Main resources:

Total runtime0.1793 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0061 587.9219370.3047
Module start 'content' 0.00610.0139 958.22661,009.6094
Module end 'content' 0.01990.1593 1,967.83593,898.1875
Script end 0.1792  5,866.0234 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00442.4641200.0002
Check MTime0.00130.7145200.0001
Mysql Total
Database connection0.00060.347510.0006
Mysqli_queries0.089249.72841410.0006
Looping result0.00120.66611390.0000
Template Total0.158988.610.1589
Template load0.00070.389810.0007
Template processing0.158288.245510.1582
Override
Cache load0.00050.275510.0005
Sytem overhead
Fetch class attribute can translate value0.00150.815910.0015
XML
Image XML parsing0.00020.113810.0002
General
dbfile0.00955.2961200.0005
String conversion0.00000.002830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs