template language - fetch and print content

Author Message

nicholas king

Wednesday 11 August 2010 3:09:36 am

Hello all i am really struggling with fetching and printing content from ezpublish.

i can grab content objects with code such as

{def $blogupdates = fetch('content','list',
hash(
'parent_node_id',269,
'limit',5))}
{foreach $blogupdates as $update}
<a href="{$update.url}">{$update.name|wash}</a>
{/foreach}

which works however i want to have granular control over all the attributes used in the print. So in one content object i have some attributes called image,title,link and content.

when i do the following

{let rotators = fetch('content','list',
hash(
'parent_node_id',324,
'class_filter_type','include',
'class_filter_array',array('frontpage_rotator'),
'limit',4))}
{debug-log var=$rotators msg='var dumping $rotators'}
{foreach $rotators as $rotator}
<a href="{$rotator.url}">{$rotator.content|wash}</a>
{/foreach}

it does not display the content, any idea of how i control granular printing of content object attributes.

Thanks

Nicholas

Romeo Antony

Wednesday 11 August 2010 5:12:42 am

Hi,

{foreach $rotators as $rotator}
<a href="{$rotator.url}">{$rotator.content|wash}</a>
{/foreach}

Above means , you have only content objects now. to get title, image , linkattributes

You should fetch it using data_map

Like this

{$rotator.object.data_map.title.content}

This links will be helpfull

http://ez.no/doc/ez_publish/technical_manual/4_x/reference/objects/ezcontentobject

http://ez.no/doc/ez_publish/technical_manual/4_x/reference/objects/ezcontentobjectattribute

hope this helps

Reagards Romeo

nicholas king

Wednesday 11 August 2010 5:20:19 am

Brilliant thanks so much for the help Romeo :-)

nicholas king

Wednesday 11 August 2010 5:41:32 am

Sorry to bother you Romeo,

but how do i get my image url out of the contnet item for a image attribute and also a link to the internal [Object relation]?

Thanks

nicholas

Romeo Antony

Wednesday 11 August 2010 6:01:05 am

Nicholas,

Try this this url to read http://ez.no/doc/ez_publish/technical_manual/4_x/reference/objects/ezimageobject

{attribute_view_gui href=$node.url_alias|ezurl() attribute=$node.data_map.image image_class=small}

image_class is defined in mage.ini , it is used by image resizing library .

Romeo Antony

Wednesday 11 August 2010 6:08:12 am

other wise you u cantry somewhat like these

<img src={$valid_nodes[0].object.data_map.image.content[original].full_path} width="39" height="30"/>

nicholas king

Wednesday 11 August 2010 6:39:05 am

Hello Romeo,

Thanks again for your help

i think i am starting to understand.

so the structure is

$rotator.object.data_map.<attribute>.<what you want to extract from the attribute>

Thanks again for your help.

Nicholas

nicholas king

Wednesday 11 August 2010 8:31:21 am

my solution to printing out the image url from a content object is as follows

{def $i=1}
{foreach $rotators as $rotator}
<!-- Content number {$i} -->
<div id="fragment-{$i}" class="1)}ui-tabs-hide{/if} !eq($i, {if ui-tabs-panel" style="">
<img src="{$rotator.object.data_map.image.content.rotatormain.url}" alt="{$rotator.object.data_map.image.content.rotatormain.text}" />
<div class="info">
<h2><a href="#" >{$rotator.object.data_map.title.content}</a></h2>
<p>{$rotator.object.data_map.content.content} <a href="{$rotator.object.data_map.link.url}" >read more</a></p>
</div>
</div>
<!-- End content number {$i} //-->
{set $i=inc($i)}
{/foreach}

where rotatormain is a ezimagealias as set in the image.ini file. other values that are default are original, small, medium.

for example

{$rotator.object.data_map.image.content.small.url}

will link to the small version of the image.

im now trying to find out how to link out the url to the related object in the content attribute. Any insight on that would be fantastic.

Thanks

Nicholas

Romeo Antony

Thursday 12 August 2010 12:50:14 am

Nicholas, http://ez.no/downlo

Please go through following link

ad/ez_publish/changelogs/ez_publish_3_6/new_features/template_functions_for_fetching_related_objects

http://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/related_objects

If you want to fetch the relted objects specified by the keyword attribute , you can find out results from forum.

nicholas king

Thursday 12 August 2010 3:10:35 am

Hello Romeo,

Thanks for the links, i will have a look over them. Brilliant.

Thanks alot.

Nicholas

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