Forums / Setup & design / Fetching an object using contentobject_id

Fetching an object using contentobject_id

Author Message

Jason Filby

Friday 30 January 2004 7:22:33 am

Hi all

I need to fetch an object for which I have only the contentobject_id. In the database, I can see that the contectobject_id I have maps to ez_contentobject's id column. But how do I, in a template, fetch the object using this contentobject_id?

This actually goes back to my attempts to fetch the object contained in an ezobjectrelation.

Thanks
Jason

James Packham

Friday 30 January 2004 9:32:39 am

Oh! Sorry Jason, I didn't understand what you meant before! Try something like this:

{let myobject=fetch('content','object',hash('object_id',239}

239 can be replaced by whatever your object id happens to be, or $object.id if it's the object you're looking at :) . Run

"find design/standard/ | xargs grep fetch | grep object"

In your ez publish root directory (assuming you're using Linux) to get some examples. kernel/content/function_definition.php tells you how it's defined and what parameters you can use :)

Regards,

James

Jason Filby

Wednesday 04 February 2004 10:19:37 am

Hi James

Thanks for your help. I was using this to get to a blog's relatd person object - and get the related user object. I used this approach instead of sections because I don't want hundreds of sections. Here's my code - for anyone that may want this in the future.

Cheers
Jason

{let current_user=fetch('user','current_user') }

{* Retrieve blog owner's user id *}
{let blog_person_rel=$node.object.data_map.blog_owner.content.id}
{let blog_person=fetch('content','object',hash('object_id',$blog_person_rel))}

{let blog_user_rel=$blog_person.data_map.person_user.content.id}
{let blog_user=fetch('content','object',hash('object_id',$blog_user_rel))}

<h1>Blog of {content_view_gui view=text_linked content_object=$blog_person}</h1>

<form method="post" action={"/content/action/"|ezurl}>
<div class="buttonblock">
{section show=$current_user.contentobject_id|eq($blog_user.data_map.user_acc
ount.contentobject_id)}
<input type="hidden" name="NodeID" value="{$node.node_id}" />
<input type="hidden" name="ClassID" value="2">
<input class="button" type="submit" name="NewButton" value="New Article"
>
{/section}
</div>
</form>

{section name=Articles loop=fetch('content', 'list',
hash( parent_node_id, $node.node_id,
limit, $page_limit,
sort_by,array(array(published,false())),
offset, $view_parameters.offset) ) }
<p>
<b><a href={concat('content/view/full/', $Articles:item.node_id,'/')|ezurl}>{
$Articles:item.name|wash}</a></b>
</p>
<p>
{attribute_view_gui attribute=$Articles:item.data_map.intro}
</p>
<br>
{/section}

{/let} {* end of fetch blog_user *}
{/let} {* end of fetch blog_user_rel *}

{/let} {* end of fetch blog_person *}
{/let} {* end of fetch blog_person_rel *}

{/let} {* end of fetch current user *}

eZ debug

Timing: Jan 31 2025 01:15:22
Script start
Timing: Jan 31 2025 01:15:22
Module start 'content'
Timing: Jan 31 2025 01:15:22
Module end 'content'
Timing: Jan 31 2025 01:15:22
Script end

Main resources:

Total runtime0.2645 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.0095 588.0625370.2734
Module start 'content' 0.00960.0153 958.33591,005.5781
Module end 'content' 0.02490.2395 1,963.91413,893.9141
Script end 0.2644  5,857.8281 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00491.8565200.0002
Check MTime0.00150.5551200.0001
Mysql Total
Database connection0.00090.322110.0009
Mysqli_queries0.152357.59441410.0011
Looping result0.00170.63381390.0000
Template Total0.239090.310.2390
Template load0.00080.300910.0008
Template processing0.238190.046610.2381
Override
Cache load0.00050.201110.0005
Sytem overhead
Fetch class attribute can translate value0.00190.711210.0019
XML
Image XML parsing0.00020.093010.0002
General
dbfile0.01264.7549200.0006
String conversion0.00000.003230.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