Forums / Setup & design / template language - fetch and print content

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

eZ debug

Timing: Jan 18 2025 04:22:22
Script start
Timing: Jan 18 2025 04:22:22
Module start 'content'
Timing: Jan 18 2025 04:22:22
Module end 'content'
Timing: Jan 18 2025 04:22:22
Script end

Main resources:

Total runtime0.2578 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0105 589.2734180.8125
Module start 'content' 0.01050.0065 770.0859106.0234
Module end 'content' 0.01700.2406 876.1094536.3750
Script end 0.2577  1,412.4844 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00441.6925200.0002
Check MTime0.00160.6123200.0001
Mysql Total
Database connection0.00311.199210.0031
Mysqli_queries0.196976.38021410.0014
Looping result0.00160.61801390.0000
Template Total0.240193.210.2401
Template load0.00100.376410.0010
Template processing0.239292.783110.2392
Override
Cache load0.00060.226210.0006
Sytem overhead
Fetch class attribute can translate value0.00100.385310.0010
XML
Image XML parsing0.00030.100110.0003
General
dbfile0.00281.0886200.0001
String conversion0.00000.014330.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