Forums / Setup & design / Get media library tree from a template

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