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 *}

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 18 2025 19:32:23
Script start
Timing: Jan 18 2025 19:32:23
Module start 'layout'
Timing: Jan 18 2025 19:32:23
Module start 'content'
Timing: Jan 18 2025 19:32:24
Module end 'content'
Timing: Jan 18 2025 19:32:24
Script end

Main resources:

Total runtime1.5411 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 589.1797152.6406
Module start 'layout' 0.00630.0033 741.820339.4766
Module start 'content' 0.00961.5300 781.2969522.6172
Module end 'content' 1.53960.0015 1,303.914112.1250
Script end 1.5411  1,316.0391 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.2176160.0002
Check MTime0.00130.0872160.0001
Mysql Total
Database connection0.00060.041910.0006
Mysqli_queries1.484596.3271570.0260
Looping result0.00060.0379550.0000
Template Total1.510698.020.7553
Template load0.00180.117620.0009
Template processing1.508897.902820.7544
Template load and register function0.00020.011310.0002
states
state_id_array0.00090.057210.0009
state_identifier_array0.00080.054120.0004
Override
Cache load0.00150.0997590.0000
Sytem overhead
Fetch class attribute can translate value0.00050.034720.0003
Fetch class attribute name0.00140.089240.0003
XML
Image XML parsing0.00070.045820.0004
class_abstraction
Instantiating content class attribute0.00000.000640.0000
General
dbfile0.00080.0511160.0000
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
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
8content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/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: 25
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs