On peut utiliser attribute_view_gui mais dans certains cas on doit faire autrement.
Insérer une image :
{if $node.data_map.image.has_content}
<img src={$node.data_map.image.content[original].full_path|ezroot}
alt="{$node.data_map.image.content[original].alternative_text}" />
{/if}
Inclure un fichier :
{if $node.data_map.file.has_content}
{def $file=$node.data_map.file
$type=$file.content.original_filename|explode('.')
}
<a href={concat("content/download/", $file.contentobject_id, "/", $file.id, "/file/", $file.content.original_filename)|ezurl}>
{$file.content.original_filename|wash(xhtml)}</a> ({$type[$type|count|dec]} - {$file.content.filesize|si(byte)})
</a>
{/if}
Liens vers les éléments d'un attribut relation d'objets :
{foreach $node.data_map.liens.content.relation_list as $lien}
{def $myLinkNode = fetch('content', 'node', hash('node_id', $lien.node_id))}
{if $myLinkNode}
<a href={$myLinkNode.url_alias|ezurl}>{$myLinkNode.name|wash}</a>
{/if}
{undef $myLinkNode}
{/foreach}
Lien interne/externe :
{if $node.data_map.lien_interne.has_content}
{def $myLinkNode=fetch(content,node, hash('node_id', $node.data_map.lien_interne.value.main_node_id))
$link=$myLinkNode.url_alias|ezurl("no")
$nom=$myLinkNode.name
}
{elseif $node.data_map.lien_externe.has_content}
{def $link=$node.data_map.lien_externe.value
$nom=$node.data_map.lien_externe.data_text
}
{/if}
{if is_set($link)}
<a href="{$link}" title="{$nom|wash}" {if $node.data_map.lien_externe.has_content}target="_blank"{/if}>En savoir plus...</a>
{/if}
Eviter les fetch :
- Obtenir les noeuds enfants : $node.children
- Obtenir le noeud parent : $node.parent
- Obtenir le count d'un fetch : ne pas faire un fetch list puis count, mais un fetch list_count !