Get media library tree from a template

Author Message

Yasen Georgiev

Thursday 13 May 2010 7:00:06 am

Hi,

I have to extract the Media Library structure from a template.

I've tried a lot of things, but not getting the targeted result :)

The nearest I got is with this statement:

{def $nodes=fetch( 'content', 'node',
hash( 'parent_node_id', 43,
'depth', 4,
'limit', 0,
'ignore_visibility', true(),
) )}
{foreach $nodes as $node}
{$node.name|wash} - {$node.class_identifier} <br />
{/foreach}

but it doesn't show the nodes of class 'Folder', even though they are not filtered.

Could somebody help with this issue?

Regards,
Yasen Georgiev

Håvard Bergersen

Saturday 15 May 2010 12:49:07 pm

Hi Yasen.

The fetch function you are using here is to fetch one single node, and it does not support parent_node_id as a parameter, but a node_id....

Depending on what you need it for i would suggest the 'list' or the 'tree' fetch function.

These are documented here under 'content' http://ez.no/doc_hidden/ez_publish/technical_manual/4_x/reference/template_fetch_functions.

So, one of these should do the trick.

{def $nodes=fetch( 'content', 'tree', hash( 'parent_node_id', 43,
'depth', 4,
'limit', 0,
'ignore_visibility', true(),
) )}

{foreach $nodes as $node}
  {$node.name|wash()}
{/foreach}
{def $nodes=fetch('content', 'list', hash( 'parent_node_id', 43,
'depth', 4,
'limit', 10,
'ignore_visibility', true(),
 ))}

{foreach $nodes as $node}
   {$node.name|wash()}
{/foreach}

Good luck :)

Yasen Georgiev

Monday 17 May 2010 12:25:39 am

Both examples work like a charm ;)

Thanks a lot Håvard!

Regards,
Yasen Georgiev

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 31 2025 03:28:26
Script start
Timing: Jan 31 2025 03:28:26
Module start 'layout'
Timing: Jan 31 2025 03:28:26
Module start 'content'
Timing: Jan 31 2025 03:28:26
Module end 'content'
Timing: Jan 31 2025 03:28:26
Script end

Main resources:

Total runtime0.0373 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 588.2500151.2266
Module start 'layout' 0.00560.0036 739.4766220.7188
Module start 'content' 0.00930.0263 960.1953998.0234
Module end 'content' 0.03560.0017 1,958.218833.9922
Script end 0.0373  1,992.2109 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00277.3101140.0002
Check MTime0.00112.8792140.0001
Mysql Total
Database connection0.00082.235610.0008
Mysqli_queries0.00287.566430.0009
Looping result0.00000.034510.0000
Template Total0.00123.310.0012
Template load0.00102.584510.0010
Template processing0.00030.720910.0003
Override
Cache load0.00071.787610.0007
General
dbfile0.012633.689780.0016
String conversion0.00000.021740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_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