Fetching an object using contentobject_id

Fetching an object using contentobject_id

Friday 30 January 2004 7:22:33 am - 2 replies

Author Message

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

You must be logged in to post messages in this topic!

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